Hello Xuan Zhuo,
The patch 26ae35c46f93: "virtio_net: support rx/tx queue reset" from
Mar 8, 2022, leads to the following Smatch static checker warning:
drivers/net/virtio_net.c:1410 virtnet_napi_tx_disable()
warn: sleeping in atomic context
drivers/net/virtio_net.c
1829 static int virtnet_tx_vq_reset(struct virtnet_info *vi,
1830 struct send_queue *sq, u32
ring_num)
1831 {
1832 struct netdev_queue *txq;
1833 int err, qindex;
1834
1835 qindex = sq - vi->sq;
1836
1837 txq = netdev_get_tx_queue(vi->dev, qindex);
1838 __netif_tx_lock_bh(txq);
^^^^^^^^^^^^^^^^^^^^^^^
Disables preempt
1839
1840 /* stop tx queue and napi */
1841 netif_stop_subqueue(vi->dev, qindex);
1842 virtnet_napi_tx_disable(&sq->napi);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
napi_disable() is a might_sleep() function.
1843
1844 __netif_tx_unlock_bh(txq);
1845
1846 /* reset the queue */
1847 err = virtio_reset_vq(sq->vq);
1848 if (err) {
1849 netif_start_subqueue(vi->dev, qindex);
1850 goto err;
1851 }
regards,
dan carpenter
On Thu, 10 Mar 2022 18:12:21 +0300, Dan Carpenter <dan.carpenter at oracle.com> wrote:> Hello Xuan Zhuo, > > The patch 26ae35c46f93: "virtio_net: support rx/tx queue reset" from > Mar 8, 2022, leads to the following Smatch static checker warning:Yes, thanks to you, I also found this problem today.> > drivers/net/virtio_net.c:1410 virtnet_napi_tx_disable() > warn: sleeping in atomic context > > drivers/net/virtio_net.c > 1829 static int virtnet_tx_vq_reset(struct virtnet_info *vi, > 1830 struct send_queue *sq, u32 ring_num) > 1831 { > 1832 struct netdev_queue *txq; > 1833 int err, qindex; > 1834 > 1835 qindex = sq - vi->sq; > 1836 > 1837 txq = netdev_get_tx_queue(vi->dev, qindex); > 1838 __netif_tx_lock_bh(txq); > ^^^^^^^^^^^^^^^^^^^^^^^ > Disables preempt > > 1839 > 1840 /* stop tx queue and napi */ > 1841 netif_stop_subqueue(vi->dev, qindex); > 1842 virtnet_napi_tx_disable(&sq->napi); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > napi_disable() is a might_sleep() function. > > 1843 > 1844 __netif_tx_unlock_bh(txq); > 1845 > 1846 /* reset the queue */ > 1847 err = virtio_reset_vq(sq->vq); > 1848 if (err) { > 1849 netif_start_subqueue(vi->dev, qindex); > 1850 goto err; > 1851 } > > regards, > dan carpenter