From: Rusty Russell Date: Sat, 13 Jun 2009 04:16:35 +0000 (-0600) Subject: virtio: meet virtio spec by finalizing features before using device X-Git-Tag: v3.12-rc1~14357^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef688e151c00e5d529703be9a04fd506df8bc54e;p=kernel%2Fkernel-generic.git 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 --- diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 018c070..6b68103 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -118,13 +118,14 @@ static int virtio_dev_probe(struct device *_d) if (device_features & (1 << i)) set_bit(i, dev->features); + dev->config->finalize_features(dev); + err = drv->probe(dev); if (err) add_status(dev, VIRTIO_CONFIG_S_FAILED); - else { - dev->config->finalize_features(dev); + else add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); - } + return err; }