diff options
author | Jason Wang <jasowang@redhat.com> | 2012-08-28 07:54:13 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-09-28 01:35:15 -0400 |
commit | 17bb6d40880d4178f5f8a75900ed8c9ff47d3fb2 (patch) | |
tree | f9888385b33c144f909eff14713a328dc72296f2 /drivers/virtio/virtio_mmio.c | |
parent | 7a23eb28fa645f1f0c2ec38274c11bc78c50c047 (diff) |
virtio-ring: move queue_index to vring_virtqueue
Instead of storing the queue index in transport-specific virtio structs,
this patch moves them to vring_virtqueue and introduces an helper to get
the value. This lets drivers simplify their management and tracing of
virtqueues.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio_mmio.c')
-rw-r--r-- | drivers/virtio/virtio_mmio.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 453db0c403d8..008bf58bdaae 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c | |||
@@ -131,9 +131,6 @@ struct virtio_mmio_vq_info { | |||
131 | /* the number of entries in the queue */ | 131 | /* the number of entries in the queue */ |
132 | unsigned int num; | 132 | unsigned int num; |
133 | 133 | ||
134 | /* the index of the queue */ | ||
135 | int queue_index; | ||
136 | |||
137 | /* the virtual address of the ring queue */ | 134 | /* the virtual address of the ring queue */ |
138 | void *queue; | 135 | void *queue; |
139 | 136 | ||
@@ -225,11 +222,10 @@ static void vm_reset(struct virtio_device *vdev) | |||
225 | static void vm_notify(struct virtqueue *vq) | 222 | static void vm_notify(struct virtqueue *vq) |
226 | { | 223 | { |
227 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev); | 224 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev); |
228 | struct virtio_mmio_vq_info *info = vq->priv; | ||
229 | 225 | ||
230 | /* We write the queue's selector into the notification register to | 226 | /* We write the queue's selector into the notification register to |
231 | * signal the other end */ | 227 | * signal the other end */ |
232 | writel(info->queue_index, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY); | 228 | writel(virtqueue_get_queue_index(vq), vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY); |
233 | } | 229 | } |
234 | 230 | ||
235 | /* Notify all virtqueues on an interrupt. */ | 231 | /* Notify all virtqueues on an interrupt. */ |
@@ -270,6 +266,7 @@ static void vm_del_vq(struct virtqueue *vq) | |||
270 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev); | 266 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev); |
271 | struct virtio_mmio_vq_info *info = vq->priv; | 267 | struct virtio_mmio_vq_info *info = vq->priv; |
272 | unsigned long flags, size; | 268 | unsigned long flags, size; |
269 | unsigned int index = virtqueue_get_queue_index(vq); | ||
273 | 270 | ||
274 | spin_lock_irqsave(&vm_dev->lock, flags); | 271 | spin_lock_irqsave(&vm_dev->lock, flags); |
275 | list_del(&info->node); | 272 | list_del(&info->node); |
@@ -278,7 +275,7 @@ static void vm_del_vq(struct virtqueue *vq) | |||
278 | vring_del_virtqueue(vq); | 275 | vring_del_virtqueue(vq); |
279 | 276 | ||
280 | /* Select and deactivate the queue */ | 277 | /* Select and deactivate the queue */ |
281 | writel(info->queue_index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL); | 278 | writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL); |
282 | writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); | 279 | writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); |
283 | 280 | ||
284 | size = PAGE_ALIGN(vring_size(info->num, VIRTIO_MMIO_VRING_ALIGN)); | 281 | size = PAGE_ALIGN(vring_size(info->num, VIRTIO_MMIO_VRING_ALIGN)); |
@@ -324,7 +321,6 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index, | |||
324 | err = -ENOMEM; | 321 | err = -ENOMEM; |
325 | goto error_kmalloc; | 322 | goto error_kmalloc; |
326 | } | 323 | } |
327 | info->queue_index = index; | ||
328 | 324 | ||
329 | /* Allocate pages for the queue - start with a queue as big as | 325 | /* Allocate pages for the queue - start with a queue as big as |
330 | * possible (limited by maximum size allowed by device), drop down | 326 | * possible (limited by maximum size allowed by device), drop down |
@@ -356,7 +352,7 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index, | |||
356 | vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); | 352 | vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); |
357 | 353 | ||
358 | /* Create the vring */ | 354 | /* Create the vring */ |
359 | vq = vring_new_virtqueue(info->num, VIRTIO_MMIO_VRING_ALIGN, vdev, | 355 | vq = vring_new_virtqueue(index, info->num, VIRTIO_MMIO_VRING_ALIGN, vdev, |
360 | true, info->queue, vm_notify, callback, name); | 356 | true, info->queue, vm_notify, callback, name); |
361 | if (!vq) { | 357 | if (!vq) { |
362 | err = -ENOMEM; | 358 | err = -ENOMEM; |