History

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.

Jason Wang committed 5 years ago

Commit d50497e1 parent 28962ec1 file · +6 −0Browse files

Showing the changes to include (1 of 1 file). Show all

Unified · Split

include/linux/virtio_config.h+6−0
@@ -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 atomic24 * @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 field28 * @get: read the value of a configuration field
27 * vdev: the virtio_device29 * vdev: the virtio_device
28 * offset: the offset of the configuration field30 * offset: the offset of the configuration field
@@ -75,6 +77,7 @@ struct virtio_shm_region { · 46 unmodified lines
75 */77 */
76typedef void vq_callback_t(struct virtqueue *);78typedef void vq_callback_t(struct virtqueue *);
77struct virtio_config_ops {79struct 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}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t