From: Shirley Ma <mashirle@us.ibm.com>
To: David Miller <davem@davemloft.net>, mst@redhat.com
Cc: netdev@vger.kernel.org, jasowang@redhat.com
Subject: [PATCH] vhost: clean up outstanding buffers before setting vring
Date: Tue, 19 Jul 2011 11:02:26 -0700 [thread overview]
Message-ID: <1311098546.8573.13.camel@localhost.localdomain> (raw)
The outstanding DMA buffers need to be clean up before setting vring in
vhost. Otherwise the vring would be out of sync.
Signed-off-by: Shirley Ma<xma@us.ibm.com>
---
drivers/vhost/vhost.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index c14c42b..d6315b4 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -445,8 +445,10 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
vhost_poll_flush(&dev->vqs[i].poll);
}
/* Wait for all lower device DMAs done. */
- if (dev->vqs[i].ubufs)
+ if (dev->vqs[i].ubufs) {
vhost_ubuf_put_and_wait(dev->vqs[i].ubufs);
+ kfree(dev->vqs[i].ubufs);
+ }
/* Signal guest as appropriate. */
vhost_zerocopy_signal_used(&dev->vqs[i]);
@@ -651,6 +653,12 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
vq = d->vqs + idx;
mutex_lock(&vq->mutex);
+ /* Wait for all lower device DMAs done. */
+ if (vq->ubufs)
+ vhost_ubuf_put_and_wait(vq->ubufs);
+
+ /* Signal guest as appropriate. */
+ vhost_zerocopy_signal_used(vq);
switch (ioctl) {
case VHOST_SET_VRING_NUM:
@@ -1592,7 +1600,6 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
{
kref_put(&ubufs->kref, vhost_zerocopy_done_signal);
wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount));
- kfree(ubufs);
}
void vhost_zerocopy_callback(void *arg)
next reply other threads:[~2011-07-19 18:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-19 18:02 Shirley Ma [this message]
2011-07-19 19:49 ` [PATCH] vhost: clean up outstanding buffers before setting vring Michael S. Tsirkin
2011-07-19 20:50 ` Shirley Ma
2011-07-20 10:41 ` Michael S. Tsirkin
2011-07-20 18:12 ` Shirley Ma
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=1311098546.8573.13.camel@localhost.localdomain \
--to=mashirle@us.ibm.com \
--cc=davem@davemloft.net \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.