Skip to content

Commit d50497e

Browse files
jasowangmstsirkin
authored andcommitted
virtio_config: introduce a new .enable_cbs method
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. Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 28962ec commit d50497e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/linux/virtio_config.h

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ struct virtio_shm_region {
2323
* any of @get/@set, @get_status/@set_status, or @get_features/
2424
* @finalize_features are NOT safe to be called from an atomic
2525
* context.
26+
* @enable_cbs: enable the callbacks
27+
* vdev: the virtio_device
2628
* @get: read the value of a configuration field
2729
* vdev: the virtio_device
2830
* offset: the offset of the configuration field
@@ -75,6 +77,7 @@ struct virtio_shm_region {
7577
*/
7678
typedef void vq_callback_t(struct virtqueue *);
7779
struct virtio_config_ops {
80+
void (*enable_cbs)(struct virtio_device *vdev);
7881
void (*get)(struct virtio_device *vdev, unsigned offset,
7982
void *buf, unsigned len);
8083
void (*set)(struct virtio_device *vdev, unsigned offset,
@@ -229,6 +232,9 @@ void virtio_device_ready(struct virtio_device *dev)
229232
{
230233
unsigned status = dev->config->get_status(dev);
231234

235+
if (dev->config->enable_cbs)
236+
dev->config->enable_cbs(dev);
237+
232238
BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK);
233239
dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK);
234240
}

0 commit comments

Comments
 (0)