aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2013-09-02 04:41:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-14 09:54:56 -0400
commitbd35c1a7f659dfa01179e456881285a9f057d30c (patch)
tree7791a1129e0cde18db6a52ae71e232fd8b0a95d6
parent84a38c47c2bbcb361caa1631c92eaf5916e178d6 (diff)
vhost_net: poll vhost queue after marking DMA is done
[ Upstream commit 19c73b3e08d16ee923f3962df4abf6205127896a ] We used to poll vhost queue before making DMA is done, this is racy if vhost thread were waked up before marking DMA is done which can result the signal to be missed. Fix this by always polling the vhost thread before DMA is done. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/vhost/net.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 8ca5ac71b845..d6a518ce4d6d 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -307,6 +307,11 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
307 struct vhost_virtqueue *vq = ubufs->vq; 307 struct vhost_virtqueue *vq = ubufs->vq;
308 int cnt = atomic_read(&ubufs->kref.refcount); 308 int cnt = atomic_read(&ubufs->kref.refcount);
309 309
310 /* set len to mark this desc buffers done DMA */
311 vq->heads[ubuf->desc].len = success ?
312 VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN;
313 vhost_net_ubuf_put(ubufs);
314
310 /* 315 /*
311 * Trigger polling thread if guest stopped submitting new buffers: 316 * Trigger polling thread if guest stopped submitting new buffers:
312 * in this case, the refcount after decrement will eventually reach 1 317 * in this case, the refcount after decrement will eventually reach 1
@@ -317,10 +322,6 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
317 */ 322 */
318 if (cnt <= 2 || !(cnt % 16)) 323 if (cnt <= 2 || !(cnt % 16))
319 vhost_poll_queue(&vq->poll); 324 vhost_poll_queue(&vq->poll);
320 /* set len to mark this desc buffers done DMA */
321 vq->heads[ubuf->desc].len = success ?
322 VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN;
323 vhost_net_ubuf_put(ubufs);
324} 325}
325 326
326/* Expects to be always run from workqueue - which acts as 327/* Expects to be always run from workqueue - which acts as