virtio: explicit advertisement of driver features
A recent proposed feature addition to the virtio block driver revealed
some flaws in the API: in particular, we assume that feature
negotiation is complete once a driver's probe function returns.
There is nothing in the API to require this, however, and even I
didn't notice when it was violated.
So instead, we require the driver to specify what features it supports
in a table, we can then move the feature negotiation into the virtio
core. The intersection of device and driver features are presented in
a new 'features' bitmap in the struct virtio_device.
Note that this highlights the difference between Linux unsigned-long
bitmaps where each unsigned long is in native endian, and a
straight-forward little-endian array of bytes.
Drivers can still remove feature bits in their probe routine if they
really have to.
API changes:
- dev->config->feature() no longer gets and acks a feature.
- drivers should advertise their features in the 'feature_table' field
- use virtio_has_feature() for extra sanity when checking feature bits
Signed-off-by:
Rusty Russell <rusty@rustcorp.com.au>
Showing
- drivers/block/virtio_blk.c 7 additions, 1 deletiondrivers/block/virtio_blk.c
- drivers/lguest/lguest_device.c 28 additions, 20 deletionsdrivers/lguest/lguest_device.c
- drivers/net/virtio_net.c 15 additions, 7 deletionsdrivers/net/virtio_net.c
- drivers/virtio/virtio.c 36 additions, 2 deletionsdrivers/virtio/virtio.c
- drivers/virtio/virtio_balloon.c 5 additions, 1 deletiondrivers/virtio/virtio_balloon.c
- drivers/virtio/virtio_pci.c 15 additions, 15 deletionsdrivers/virtio/virtio_pci.c
- include/linux/virtio.h 7 additions, 0 deletionsinclude/linux/virtio.h
- include/linux/virtio_config.h 29 additions, 7 deletionsinclude/linux/virtio_config.h
Loading
Please register or sign in to comment