diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2009-06-13 00:16:36 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-06-12 08:46:36 -0400 |
commit | d2a7ddda9ffb1c8961abff6714b0f1eb925c120f (patch) | |
tree | 1090884fd260d042255255467367e4e6b6193e5d /drivers/virtio/virtio_pci.c | |
parent | 9499f5e7ed5224c40706f0cec6542a9916bc7606 (diff) |
virtio: find_vqs/del_vqs virtio operations
This replaces find_vq/del_vq with find_vqs/del_vqs virtio operations,
and updates all drivers. This is needed for MSI support, because MSI
needs to know the total number of vectors upfront.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (+ lguest/9p compile fixes)
Diffstat (limited to 'drivers/virtio/virtio_pci.c')
-rw-r--r-- | drivers/virtio/virtio_pci.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index be4047abd5ba..027f13fbe493 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -276,11 +276,7 @@ static void vp_del_vq(struct virtqueue *vq) | |||
276 | { | 276 | { |
277 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); | 277 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); |
278 | struct virtio_pci_vq_info *info = vq->priv; | 278 | struct virtio_pci_vq_info *info = vq->priv; |
279 | unsigned long flags, size; | 279 | unsigned long size; |
280 | |||
281 | spin_lock_irqsave(&vp_dev->lock, flags); | ||
282 | list_del(&info->node); | ||
283 | spin_unlock_irqrestore(&vp_dev->lock, flags); | ||
284 | 280 | ||
285 | vring_del_virtqueue(vq); | 281 | vring_del_virtqueue(vq); |
286 | 282 | ||
@@ -293,14 +289,41 @@ static void vp_del_vq(struct virtqueue *vq) | |||
293 | kfree(info); | 289 | kfree(info); |
294 | } | 290 | } |
295 | 291 | ||
292 | static void vp_del_vqs(struct virtio_device *vdev) | ||
293 | { | ||
294 | struct virtqueue *vq, *n; | ||
295 | |||
296 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) | ||
297 | vp_del_vq(vq); | ||
298 | } | ||
299 | |||
300 | static int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs, | ||
301 | struct virtqueue *vqs[], | ||
302 | vq_callback_t *callbacks[], | ||
303 | const char *names[]) | ||
304 | { | ||
305 | int i; | ||
306 | |||
307 | for (i = 0; i < nvqs; ++i) { | ||
308 | vqs[i] = vp_find_vq(vdev, i, callbacks[i], names[i]); | ||
309 | if (IS_ERR(vqs[i])) | ||
310 | goto error; | ||
311 | } | ||
312 | return 0; | ||
313 | |||
314 | error: | ||
315 | vp_del_vqs(vdev); | ||
316 | return PTR_ERR(vqs[i]); | ||
317 | } | ||
318 | |||
296 | static struct virtio_config_ops virtio_pci_config_ops = { | 319 | static struct virtio_config_ops virtio_pci_config_ops = { |
297 | .get = vp_get, | 320 | .get = vp_get, |
298 | .set = vp_set, | 321 | .set = vp_set, |
299 | .get_status = vp_get_status, | 322 | .get_status = vp_get_status, |
300 | .set_status = vp_set_status, | 323 | .set_status = vp_set_status, |
301 | .reset = vp_reset, | 324 | .reset = vp_reset, |
302 | .find_vq = vp_find_vq, | 325 | .find_vqs = vp_find_vqs, |
303 | .del_vq = vp_del_vq, | 326 | .del_vqs = vp_del_vqs, |
304 | .get_features = vp_get_features, | 327 | .get_features = vp_get_features, |
305 | .finalize_features = vp_finalize_features, | 328 | .finalize_features = vp_finalize_features, |
306 | }; | 329 | }; |