This patch introduces a new method to enable the callbacks for config and virtqueues. This will be used for making sure the virtqueue callbacks are only enabled after virtio_device_ready() if transport implements this method.
Unified · Split
| @@ -23,6 +23,8 @@ struct virtio_shm_region { · 22 unmodified lines | |||
| 23 | * any of @get/@set, @get_status/@set_status, or @get_features/ | 23 | * any of @get/@set, @get_status/@set_status, or @get_features/ |
| 24 | * @finalize_features are NOT safe to be called from an atomic | 24 | * @finalize_features are NOT safe to be called from an atomic |
| 25 | * context. | 25 | * context. |
| 26 | * @enable_cbs: enable the callbacks | ||
| 27 | * vdev: the virtio_device | ||
| 26 | * @get: read the value of a configuration field | 28 | * @get: read the value of a configuration field |
| 27 | * vdev: the virtio_device | 29 | * vdev: the virtio_device |
| 28 | * offset: the offset of the configuration field | 30 | * offset: the offset of the configuration field |
| @@ -75,6 +77,7 @@ struct virtio_shm_region { · 46 unmodified lines | |||
| 75 | */ | 77 | */ |
| 76 | typedef void vq_callback_t(struct virtqueue *); | 78 | typedef void vq_callback_t(struct virtqueue *); |
| 77 | struct virtio_config_ops { | 79 | struct virtio_config_ops { |
| 80 | void (*enable_cbs)(struct virtio_device *vdev); | ||
| 78 | void (*get)(struct virtio_device *vdev, unsigned offset, | 81 | void (*get)(struct virtio_device *vdev, unsigned offset, |
| 79 | void *buf, unsigned len); | 82 | void *buf, unsigned len); |
| 80 | void (*set)(struct virtio_device *vdev, unsigned offset, | 83 | void (*set)(struct virtio_device *vdev, unsigned offset, |
| @@ -229,6 +232,9 @@ void virtio_device_ready(struct virtio_device *dev) · 148 unmodified lines | |||
| 229 | { | 232 | { |
| 230 | unsigned status = dev->config->get_status(dev); | 233 | unsigned status = dev->config->get_status(dev); |
| 231 | 234 | ||
| 235 | if (dev->config->enable_cbs) | ||
| 236 | dev->config->enable_cbs(dev); | ||
| 237 | |||
| 232 | BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); | 238 | BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); |
| 233 | dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK); | 239 | dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK); |
| 234 | } | 240 | } |