set FEATURES_OK as per virtio 1.0 spec
Unified · Split
| @@ -160,6 +160,7 @@ static int virtio_dev_probe(struct device *_d) · 159 unmodified lines | |||
| 160 | struct virtio_device *dev = dev_to_virtio(_d); | 160 | struct virtio_device *dev = dev_to_virtio(_d); |
| 161 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); | 161 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
| 162 | u64 device_features; | 162 | u64 device_features; |
| 163 | unsigned status; | ||
| 163 | 164 | ||
| 164 | /* We have a driver! */ | 165 | /* We have a driver! */ |
| 165 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); | 166 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); |
| @@ -183,18 +184,32 @@ static int virtio_dev_probe(struct device *_d) · 17 unmodified lines | |||
| 183 | 184 | ||
| 184 | dev->config->finalize_features(dev); | 185 | dev->config->finalize_features(dev); |
| 185 | 186 | ||
| 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 | |||
| 186 | err = drv->probe(dev); | 198 | err = drv->probe(dev); |
| 187 | if (err) | 199 | if (err) |
| 188 | add_status(dev, VIRTIO_CONFIG_S_FAILED); | 200 | goto err; |
| 189 | else { | ||
| 190 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); | ||
| 191 | if (drv->scan) | ||
| 192 | drv->scan(dev); | ||
| 193 | 201 | ||
| 194 | virtio_config_enable(dev); | 202 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); |
| 195 | } | 203 | if (drv->scan) |
| 204 | drv->scan(dev); | ||
| 205 | |||
| 206 | virtio_config_enable(dev); | ||
| 196 | 207 | ||
| 208 | return 0; | ||
| 209 | err: | ||
| 210 | add_status(dev, VIRTIO_CONFIG_S_FAILED); | ||
| 197 | return err; | 211 | return err; |
| 212 | |||
| 198 | } | 213 | } |
| 199 | 214 | ||
| 200 | static int virtio_dev_remove(struct device *_d) | 215 | static int virtio_dev_remove(struct device *_d) |
| @@ -38,6 +38,8 @@ · 37 unmodified lines | |||
| 38 | #define VIRTIO_CONFIG_S_DRIVER 2 | 38 | #define VIRTIO_CONFIG_S_DRIVER 2 |
| 39 | /* Driver has used its parts of the config, and is happy */ | 39 | /* Driver has used its parts of the config, and is happy */ |
| 40 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 | 40 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 |
| 41 | /* Driver has finished configuring features */ | ||
| 42 | #define VIRTIO_CONFIG_S_FEATURES_OK 8 | ||
| 41 | /* We've given up on this device. */ | 43 | /* We've given up on this device. */ |
| 42 | #define VIRTIO_CONFIG_S_FAILED 0x80 | 44 | #define VIRTIO_CONFIG_S_FAILED 0x80 |
| 43 | 45 | ||