aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-06-13 00:16:35 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-06-12 08:46:35 -0400
commitef688e151c00e5d529703be9a04fd506df8bc54e (patch)
tree841d0b0bcd8a5f72f8d8bdc455672d9a6e7468ca /drivers/virtio/virtio.c
parent20f77f5654042cf484d8964b618faf9d620f639b (diff)
virtio: meet virtio spec by finalizing features before using device
Virtio devices are supposed to negotiate features before they start using the device, but the current code doesn't do this. This is because the driver's probe() function invariably has to add buffers to a virtqueue, or probe the disk (virtio_blk). This currently doesn't matter since no existing backend is strict about the feature negotiation. But it's possible to imagine a future feature which completely changes how a device operates: in this case, we'd need to acknowledge it before using the device. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r--drivers/virtio/virtio.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 018c070a357f..6b6810364860 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -118,13 +118,14 @@ static int virtio_dev_probe(struct device *_d)
118 if (device_features & (1 << i)) 118 if (device_features & (1 << i))
119 set_bit(i, dev->features); 119 set_bit(i, dev->features);
120 120
121 dev->config->finalize_features(dev);
122
121 err = drv->probe(dev); 123 err = drv->probe(dev);
122 if (err) 124 if (err)
123 add_status(dev, VIRTIO_CONFIG_S_FAILED); 125 add_status(dev, VIRTIO_CONFIG_S_FAILED);
124 else { 126 else
125 dev->config->finalize_features(dev);
126 add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); 127 add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
127 } 128
128 return err; 129 return err;
129} 130}
130 131