Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio-net: disable NAPI only when enabled during XDP set

We try to disable NAPI to prevent a single XDP TX queue being used by
multiple cpus. But we don't check if device is up (NAPI is enabled),
this could result stall because of infinite wait in
napi_disable(). Fixing this by checking device state through
netif_running() before.

Fixes: 4941d472bf95b ("virtio-net: do not reset during XDP set")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jason Wang and committed by
David S. Miller
4e09ff53 ecc83275

+5 -3
+5 -3
drivers/net/virtio_net.c
··· 2185 2185 } 2186 2186 2187 2187 /* Make sure NAPI is not using any XDP TX queues for RX. */ 2188 - for (i = 0; i < vi->max_queue_pairs; i++) 2189 - napi_disable(&vi->rq[i].napi); 2188 + if (netif_running(dev)) 2189 + for (i = 0; i < vi->max_queue_pairs; i++) 2190 + napi_disable(&vi->rq[i].napi); 2190 2191 2191 2192 netif_set_real_num_rx_queues(dev, curr_qp + xdp_qp); 2192 2193 err = _virtnet_set_queues(vi, curr_qp + xdp_qp); ··· 2206 2205 } 2207 2206 if (old_prog) 2208 2207 bpf_prog_put(old_prog); 2209 - virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); 2208 + if (netif_running(dev)) 2209 + virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi); 2210 2210 } 2211 2211 2212 2212 return 0;