]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/vhost/net.c
Merge tag 'drm-intel-next-fixes-2017-09-07' of git://anongit.freedesktop.org/git...
[linux.git] / drivers / vhost / net.c
index 06d044862e589ff05194d695bfdc610ed7e62195..58585ec8699e8d46100ff5f5e175ab39a7842154 100644 (file)
@@ -533,6 +533,7 @@ static void handle_tx(struct vhost_net *net)
                        ubuf->callback = vhost_zerocopy_callback;
                        ubuf->ctx = nvq->ubufs;
                        ubuf->desc = nvq->upend_idx;
+                       refcount_set(&ubuf->refcnt, 1);
                        msg.msg_control = ubuf;
                        msg.msg_controllen = sizeof(ubuf);
                        ubufs = nvq->ubufs;
@@ -634,8 +635,13 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk)
 
                preempt_enable();
 
-               if (vhost_enable_notify(&net->dev, vq))
+               if (!vhost_vq_avail_empty(&net->dev, vq))
                        vhost_poll_queue(&vq->poll);
+               else if (unlikely(vhost_enable_notify(&net->dev, vq))) {
+                       vhost_disable_notify(&net->dev, vq);
+                       vhost_poll_queue(&vq->poll);
+               }
+
                mutex_unlock(&vq->mutex);
 
                len = peek_head_len(rvq, sk);