diff options
author | Heinz Graalfs <graalfs@linux.vnet.ibm.com> | 2013-10-28 19:09:48 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-10-28 20:58:12 -0400 |
commit | 5b1bf7cb673ade0ab5c75f200dce911d9fb91c21 (patch) | |
tree | c90e760edaf94d91d94ff366e881fe5562e4478d /drivers/virtio | |
parent | 46f9c2b925ac12e5ad8b8b7c90c71dacc9d5db37 (diff) |
virtio_ring: let virtqueue_{kick()/notify()} return a bool
virtqueue_{kick()/notify()} should exploit the new host notification API.
If the notify call returned with a negative value the host kick failed
(e.g. a kick triggered after a device was hot-unplugged). In this case
the virtqueue is set to 'broken' and false is returned, otherwise true.
Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_ring.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 97dd51619b55..b47142723119 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -430,13 +430,22 @@ EXPORT_SYMBOL_GPL(virtqueue_kick_prepare); | |||
430 | * @vq: the struct virtqueue | 430 | * @vq: the struct virtqueue |
431 | * | 431 | * |
432 | * This does not need to be serialized. | 432 | * This does not need to be serialized. |
433 | * | ||
434 | * Returns false if host notify failed or queue is broken, otherwise true. | ||
433 | */ | 435 | */ |
434 | void virtqueue_notify(struct virtqueue *_vq) | 436 | bool virtqueue_notify(struct virtqueue *_vq) |
435 | { | 437 | { |
436 | struct vring_virtqueue *vq = to_vvq(_vq); | 438 | struct vring_virtqueue *vq = to_vvq(_vq); |
437 | 439 | ||
440 | if (unlikely(vq->broken)) | ||
441 | return false; | ||
442 | |||
438 | /* Prod other side to tell it about changes. */ | 443 | /* Prod other side to tell it about changes. */ |
439 | vq->notify(_vq); | 444 | if (vq->notify(_vq) < 0) { |
445 | vq->broken = true; | ||
446 | return false; | ||
447 | } | ||
448 | return true; | ||
440 | } | 449 | } |
441 | EXPORT_SYMBOL_GPL(virtqueue_notify); | 450 | EXPORT_SYMBOL_GPL(virtqueue_notify); |
442 | 451 | ||
@@ -449,11 +458,14 @@ EXPORT_SYMBOL_GPL(virtqueue_notify); | |||
449 | * | 458 | * |
450 | * Caller must ensure we don't call this with other virtqueue | 459 | * Caller must ensure we don't call this with other virtqueue |
451 | * operations at the same time (except where noted). | 460 | * operations at the same time (except where noted). |
461 | * | ||
462 | * Returns false if kick failed, otherwise true. | ||
452 | */ | 463 | */ |
453 | void virtqueue_kick(struct virtqueue *vq) | 464 | bool virtqueue_kick(struct virtqueue *vq) |
454 | { | 465 | { |
455 | if (virtqueue_kick_prepare(vq)) | 466 | if (virtqueue_kick_prepare(vq)) |
456 | virtqueue_notify(vq); | 467 | return virtqueue_notify(vq); |
468 | return true; | ||
457 | } | 469 | } |
458 | EXPORT_SYMBOL_GPL(virtqueue_kick); | 470 | EXPORT_SYMBOL_GPL(virtqueue_kick); |
459 | 471 | ||