diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-06-13 00:16:35 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-06-12 08:46:36 -0400 |
commit | 9499f5e7ed5224c40706f0cec6542a9916bc7606 (patch) | |
tree | 3e4e1b36d3d549ea356e88e6e44359a887c6ee01 /drivers/virtio | |
parent | ef688e151c00e5d529703be9a04fd506df8bc54e (diff) |
virtio: add names to virtqueue struct, mapping from devices to queues.
Add a linked list of all virtqueues for a virtio device: this helps for
debugging and is also needed for upcoming interface change.
Also, add a "name" field for clearer debug messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio.c | 2 | ||||
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 4 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci.c | 5 | ||||
-rw-r--r-- | drivers/virtio/virtio_ring.c | 27 |
4 files changed, 27 insertions, 11 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 6b6810364860..3f52c767dfe9 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -186,6 +186,8 @@ int register_virtio_device(struct virtio_device *dev) | |||
186 | /* Acknowledge that we've seen the device. */ | 186 | /* Acknowledge that we've seen the device. */ |
187 | add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE); | 187 | add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE); |
188 | 188 | ||
189 | INIT_LIST_HEAD(&dev->vqs); | ||
190 | |||
189 | /* device_register() causes the bus infrastructure to look for a | 191 | /* device_register() causes the bus infrastructure to look for a |
190 | * matching driver. */ | 192 | * matching driver. */ |
191 | err = device_register(&dev->dev); | 193 | err = device_register(&dev->dev); |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 9c76a061a04d..0fa73b4d18b0 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -218,13 +218,13 @@ static int virtballoon_probe(struct virtio_device *vdev) | |||
218 | vb->vdev = vdev; | 218 | vb->vdev = vdev; |
219 | 219 | ||
220 | /* We expect two virtqueues. */ | 220 | /* We expect two virtqueues. */ |
221 | vb->inflate_vq = vdev->config->find_vq(vdev, 0, balloon_ack); | 221 | vb->inflate_vq = vdev->config->find_vq(vdev, 0, balloon_ack, "inflate"); |
222 | if (IS_ERR(vb->inflate_vq)) { | 222 | if (IS_ERR(vb->inflate_vq)) { |
223 | err = PTR_ERR(vb->inflate_vq); | 223 | err = PTR_ERR(vb->inflate_vq); |
224 | goto out_free_vb; | 224 | goto out_free_vb; |
225 | } | 225 | } |
226 | 226 | ||
227 | vb->deflate_vq = vdev->config->find_vq(vdev, 1, balloon_ack); | 227 | vb->deflate_vq = vdev->config->find_vq(vdev, 1, balloon_ack, "deflate"); |
228 | if (IS_ERR(vb->deflate_vq)) { | 228 | if (IS_ERR(vb->deflate_vq)) { |
229 | err = PTR_ERR(vb->deflate_vq); | 229 | err = PTR_ERR(vb->deflate_vq); |
230 | goto out_del_inflate_vq; | 230 | goto out_del_inflate_vq; |
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index 330aacbdec1f..be4047abd5ba 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -208,7 +208,8 @@ static irqreturn_t vp_interrupt(int irq, void *opaque) | |||
208 | 208 | ||
209 | /* the config->find_vq() implementation */ | 209 | /* the config->find_vq() implementation */ |
210 | static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index, | 210 | static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index, |
211 | void (*callback)(struct virtqueue *vq)) | 211 | void (*callback)(struct virtqueue *vq), |
212 | const char *name) | ||
212 | { | 213 | { |
213 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 214 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
214 | struct virtio_pci_vq_info *info; | 215 | struct virtio_pci_vq_info *info; |
@@ -247,7 +248,7 @@ static struct virtqueue *vp_find_vq(struct virtio_device *vdev, unsigned index, | |||
247 | 248 | ||
248 | /* create the vring */ | 249 | /* create the vring */ |
249 | vq = vring_new_virtqueue(info->num, VIRTIO_PCI_VRING_ALIGN, | 250 | vq = vring_new_virtqueue(info->num, VIRTIO_PCI_VRING_ALIGN, |
250 | vdev, info->queue, vp_notify, callback); | 251 | vdev, info->queue, vp_notify, callback, name); |
251 | if (!vq) { | 252 | if (!vq) { |
252 | err = -ENOMEM; | 253 | err = -ENOMEM; |
253 | goto out_activate_queue; | 254 | goto out_activate_queue; |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 5c52369ab9bb..579fa693d5d0 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -23,21 +23,30 @@ | |||
23 | 23 | ||
24 | #ifdef DEBUG | 24 | #ifdef DEBUG |
25 | /* For development, we want to crash whenever the ring is screwed. */ | 25 | /* For development, we want to crash whenever the ring is screwed. */ |
26 | #define BAD_RING(_vq, fmt...) \ | 26 | #define BAD_RING(_vq, fmt, args...) \ |
27 | do { dev_err(&(_vq)->vq.vdev->dev, fmt); BUG(); } while(0) | 27 | do { \ |
28 | dev_err(&(_vq)->vq.vdev->dev, \ | ||
29 | "%s:"fmt, (_vq)->vq.name, ##args); \ | ||
30 | BUG(); \ | ||
31 | } while (0) | ||
28 | /* Caller is supposed to guarantee no reentry. */ | 32 | /* Caller is supposed to guarantee no reentry. */ |
29 | #define START_USE(_vq) \ | 33 | #define START_USE(_vq) \ |
30 | do { \ | 34 | do { \ |
31 | if ((_vq)->in_use) \ | 35 | if ((_vq)->in_use) \ |
32 | panic("in_use = %i\n", (_vq)->in_use); \ | 36 | panic("%s:in_use = %i\n", \ |
37 | (_vq)->vq.name, (_vq)->in_use); \ | ||
33 | (_vq)->in_use = __LINE__; \ | 38 | (_vq)->in_use = __LINE__; \ |
34 | mb(); \ | 39 | mb(); \ |
35 | } while(0) | 40 | } while (0) |
36 | #define END_USE(_vq) \ | 41 | #define END_USE(_vq) \ |
37 | do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0) | 42 | do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0) |
38 | #else | 43 | #else |
39 | #define BAD_RING(_vq, fmt...) \ | 44 | #define BAD_RING(_vq, fmt, args...) \ |
40 | do { dev_err(&_vq->vq.vdev->dev, fmt); (_vq)->broken = true; } while(0) | 45 | do { \ |
46 | dev_err(&_vq->vq.vdev->dev, \ | ||
47 | "%s:"fmt, (_vq)->vq.name, ##args); \ | ||
48 | (_vq)->broken = true; \ | ||
49 | } while (0) | ||
41 | #define START_USE(vq) | 50 | #define START_USE(vq) |
42 | #define END_USE(vq) | 51 | #define END_USE(vq) |
43 | #endif | 52 | #endif |
@@ -284,7 +293,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, | |||
284 | struct virtio_device *vdev, | 293 | struct virtio_device *vdev, |
285 | void *pages, | 294 | void *pages, |
286 | void (*notify)(struct virtqueue *), | 295 | void (*notify)(struct virtqueue *), |
287 | void (*callback)(struct virtqueue *)) | 296 | void (*callback)(struct virtqueue *), |
297 | const char *name) | ||
288 | { | 298 | { |
289 | struct vring_virtqueue *vq; | 299 | struct vring_virtqueue *vq; |
290 | unsigned int i; | 300 | unsigned int i; |
@@ -303,10 +313,12 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, | |||
303 | vq->vq.callback = callback; | 313 | vq->vq.callback = callback; |
304 | vq->vq.vdev = vdev; | 314 | vq->vq.vdev = vdev; |
305 | vq->vq.vq_ops = &vring_vq_ops; | 315 | vq->vq.vq_ops = &vring_vq_ops; |
316 | vq->vq.name = name; | ||
306 | vq->notify = notify; | 317 | vq->notify = notify; |
307 | vq->broken = false; | 318 | vq->broken = false; |
308 | vq->last_used_idx = 0; | 319 | vq->last_used_idx = 0; |
309 | vq->num_added = 0; | 320 | vq->num_added = 0; |
321 | list_add_tail(&vq->vq.list, &vdev->vqs); | ||
310 | #ifdef DEBUG | 322 | #ifdef DEBUG |
311 | vq->in_use = false; | 323 | vq->in_use = false; |
312 | #endif | 324 | #endif |
@@ -327,6 +339,7 @@ EXPORT_SYMBOL_GPL(vring_new_virtqueue); | |||
327 | 339 | ||
328 | void vring_del_virtqueue(struct virtqueue *vq) | 340 | void vring_del_virtqueue(struct virtqueue *vq) |
329 | { | 341 | { |
342 | list_del(&vq->list); | ||
330 | kfree(to_vvq(vq)); | 343 | kfree(to_vvq(vq)); |
331 | } | 344 | } |
332 | EXPORT_SYMBOL_GPL(vring_del_virtqueue); | 345 | EXPORT_SYMBOL_GPL(vring_del_virtqueue); |