Commit ef688e15 authored by Rusty Russell's avatar Rusty Russell

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: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 20f77f56
...@@ -118,13 +118,14 @@ static int virtio_dev_probe(struct device *_d) ...@@ -118,13 +118,14 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1 << i)) if (device_features & (1 << i))
set_bit(i, dev->features); set_bit(i, dev->features);
dev->config->finalize_features(dev);
err = drv->probe(dev); err = drv->probe(dev);
if (err) if (err)
add_status(dev, VIRTIO_CONFIG_S_FAILED); add_status(dev, VIRTIO_CONFIG_S_FAILED);
else { else
dev->config->finalize_features(dev);
add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment