Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20211019070152.8236-4-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Jason Wang and committed by
Michael S. Tsirkin
d50497eb 28962ec5

+6
+6
include/linux/virtio_config.h
··· 23 23 * any of @get/@set, @get_status/@set_status, or @get_features/ 24 24 * @finalize_features are NOT safe to be called from an atomic 25 25 * context. 26 + * @enable_cbs: enable the callbacks 27 + * vdev: the virtio_device 26 28 * @get: read the value of a configuration field 27 29 * vdev: the virtio_device 28 30 * offset: the offset of the configuration field ··· 77 75 */ 78 76 typedef void vq_callback_t(struct virtqueue *); 79 77 struct virtio_config_ops { 78 + void (*enable_cbs)(struct virtio_device *vdev); 80 79 void (*get)(struct virtio_device *vdev, unsigned offset, 81 80 void *buf, unsigned len); 82 81 void (*set)(struct virtio_device *vdev, unsigned offset, ··· 231 228 void virtio_device_ready(struct virtio_device *dev) 232 229 { 233 230 unsigned status = dev->config->get_status(dev); 231 + 232 + if (dev->config->enable_cbs) 233 + dev->config->enable_cbs(dev); 234 234 235 235 BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); 236 236 dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK);