aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/vhost/net.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 70ac60437d17..882a51fe7b3c 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -182,15 +182,21 @@ static void handle_tx(struct vhost_net *net)
182 break; 182 break;
183 /* Nothing new? Wait for eventfd to tell us they refilled. */ 183 /* Nothing new? Wait for eventfd to tell us they refilled. */
184 if (head == vq->num) { 184 if (head == vq->num) {
185 int num_pends;
186
185 wmem = atomic_read(&sock->sk->sk_wmem_alloc); 187 wmem = atomic_read(&sock->sk->sk_wmem_alloc);
186 if (wmem >= sock->sk->sk_sndbuf * 3 / 4) { 188 if (wmem >= sock->sk->sk_sndbuf * 3 / 4) {
187 tx_poll_start(net, sock); 189 tx_poll_start(net, sock);
188 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags); 190 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
189 break; 191 break;
190 } 192 }
191 /* If more outstanding DMAs, queue the work */ 193 /* If more outstanding DMAs, queue the work.
192 if (unlikely(vq->upend_idx - vq->done_idx > 194 * Handle upend_idx wrap around
193 VHOST_MAX_PEND)) { 195 */
196 num_pends = likely(vq->upend_idx >= vq->done_idx) ?
197 (vq->upend_idx - vq->done_idx) :
198 (vq->upend_idx + UIO_MAXIOV - vq->done_idx);
199 if (unlikely(num_pends > VHOST_MAX_PEND)) {
194 tx_poll_start(net, sock); 200 tx_poll_start(net, sock);
195 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags); 201 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
196 break; 202 break;
@@ -711,8 +717,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
711 717
712 mutex_unlock(&vq->mutex); 718 mutex_unlock(&vq->mutex);
713 719
714 if (oldubufs) 720 if (oldubufs) {
715 vhost_ubuf_put_and_wait(oldubufs); 721 vhost_ubuf_put_and_wait(oldubufs);
722 mutex_lock(&vq->mutex);
723 vhost_zerocopy_signal_used(vq);
724 mutex_unlock(&vq->mutex);
725 }
716 726
717 if (oldsock) { 727 if (oldsock) {
718 vhost_net_flush_vq(n, index); 728 vhost_net_flush_vq(n, index);