History

virtio: set FEATURES_OK

set FEATURES_OK as per virtio 1.0 spec

Michael S. Tsirkin committed 12 years ago

Commit cb3f6d91 parent 89062652 files · +24 −7Browse files

Unified · Split

2 files
  1. drivers/virtio/virtio.c +22 −7
  2. include/uapi/linux/virtio_config.h +2 −0
drivers/virtio/virtio.c+22−7
@@ -160,6 +160,7 @@ static int virtio_dev_probe(struct device *_d) · 159 unmodified lines
160160 struct virtio_device *dev = dev_to_virtio(_d);
161161 struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
162162 u64 device_features;
163+ unsigned status;
163164
164165 /* We have a driver! */
165166 add_status(dev, VIRTIO_CONFIG_S_DRIVER);
@@ -183,18 +184,32 @@ static int virtio_dev_probe(struct device *_d) · 17 unmodified lines
183184
184185 dev->config->finalize_features(dev);
185186
187+ if (virtio_has_feature(dev, VIRTIO_F_VERSION_1)) {
188+ add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
189+ status = dev->config->get_status(dev);
190+ if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
191+ dev_err(_d, "virtio: device refuses features: %x\n",
192+ status);
193+ err = -ENODEV;
194+ goto err;
195+ }
196+ }
197+
186198 err = drv->probe(dev);
187199 if (err)
188− add_status(dev, VIRTIO_CONFIG_S_FAILED);
189− else {
190− add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
191− if (drv->scan)
192− drv->scan(dev);
200+ goto err;
193201
194− virtio_config_enable(dev);
195− }
202+ add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
203+ if (drv->scan)
204+ drv->scan(dev);
205+
206+ virtio_config_enable(dev);
196207
208+ return 0;
209+err:
210+ add_status(dev, VIRTIO_CONFIG_S_FAILED);
197211 return err;
212+
198213 }
199214
200215 static int virtio_dev_remove(struct device *_d)
include/uapi/linux/virtio_config.h+2−0
@@ -38,6 +38,8 @@ · 37 unmodified lines
3838 #define VIRTIO_CONFIG_S_DRIVER 2
3939 /* Driver has used its parts of the config, and is happy */
4040 #define VIRTIO_CONFIG_S_DRIVER_OK 4
41+/* Driver has finished configuring features */
42+#define VIRTIO_CONFIG_S_FEATURES_OK 8
4143 /* We've given up on this device. */
4244 #define VIRTIO_CONFIG_S_FAILED 0x80
4345