virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
To: rusty@rustcorp.com.au, mst@redhat.com,
	virtualization@lists.linux-foundation.org
Cc: borntraeger@de.ibm.com
Subject: [PATCH V2 RFC 2/9] virtio_ring: let virtqueue_{kick()/notify()} return a bool
Date: Thu, 24 Oct 2013 17:23:13 +0200	[thread overview]
Message-ID: <1382628200-42956-3-git-send-email-graalfs@linux.vnet.ibm.com> (raw)
In-Reply-To: <1382628200-42956-1-git-send-email-graalfs@linux.vnet.ibm.com>

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>
---
 drivers/virtio/virtio_ring.c | 20 ++++++++++++++++----
 include/linux/virtio.h       |  4 ++--
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index aa40f6c..a7e0eec 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -459,13 +459,22 @@ EXPORT_SYMBOL_GPL(virtqueue_kick_prepare);
  * @vq: the struct virtqueue
  *
  * This does not need to be serialized.
+ *
+ * Returns false if host notify failed or queue is broken, otherwise true.
  */
-void virtqueue_notify(struct virtqueue *_vq)
+bool virtqueue_notify(struct virtqueue *_vq)
 {
 	struct vring_virtqueue *vq = to_vvq(_vq);
 
+	if (unlikely(vq->broken))
+		return false;
+
 	/* Prod other side to tell it about changes. */
-	vq->notify(_vq);
+	if (vq->notify(_vq) < 0) {
+		vq->broken = true;
+		return false;
+	}
+	return true;
 }
 EXPORT_SYMBOL_GPL(virtqueue_notify);
 
@@ -478,11 +487,14 @@ EXPORT_SYMBOL_GPL(virtqueue_notify);
  *
  * Caller must ensure we don't call this with other virtqueue
  * operations at the same time (except where noted).
+ *
+ * Returns false if kick failed, otherwise true.
  */
-void virtqueue_kick(struct virtqueue *vq)
+bool virtqueue_kick(struct virtqueue *vq)
 {
 	if (virtqueue_kick_prepare(vq))
-		virtqueue_notify(vq);
+		return virtqueue_notify(vq);
+	return true;
 }
 EXPORT_SYMBOL_GPL(virtqueue_kick);
 
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 9ff8645..4557e8a 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -58,11 +58,11 @@ int virtqueue_add_sgs(struct virtqueue *vq,
 		      void *data,
 		      gfp_t gfp);
 
-void virtqueue_kick(struct virtqueue *vq);
+bool virtqueue_kick(struct virtqueue *vq);
 
 bool virtqueue_kick_prepare(struct virtqueue *vq);
 
-void virtqueue_notify(struct virtqueue *vq);
+bool virtqueue_notify(struct virtqueue *vq);
 
 void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
 
-- 
1.8.3.1

  parent reply	other threads:[~2013-10-24 15:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24 15:23 [PATCH V2 RFC 0/9] virtio: fix hang(loop) after hot-unplug vlan Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 1/9] virtio_ring: change host notification API Heinz Graalfs
2013-10-27 23:27   ` Rusty Russell
2013-10-24 15:23 ` Heinz Graalfs [this message]
2013-10-24 15:23 ` [PATCH V2 RFC 3/9] virtio_net: verify if virtqueue_kick() succeeded Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 4/9] virtio_test: " Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 5/9] virtio_ring: add new function virtqueue_is_broken() Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 6/9] virtio_blk: verify if queue is broken after virtqueue_get_buf() Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 7/9] virtio_console: " Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 8/9] virtio_net: " Heinz Graalfs
2013-10-24 15:23 ` [PATCH V2 RFC 9/9] virtio_scsi: " Heinz Graalfs
2013-10-27 23:29   ` Rusty Russell
2013-10-29  1:04   ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1382628200-42956-3-git-send-email-graalfs@linux.vnet.ibm.com \
    --to=graalfs@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=mst@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).