Skip to content

Commit 3e7efc3

Browse files
committed
net: devmem: don't call queue stop / start when the interface is down
We seem to be missing a netif_running() check from the devmem installation path. Starting a queue on a stopped device makes no sense. We still want to be able to allocate the memory, just to test that the device is indeed setting up the page pools in a memory provider compatible way. This is not a bug fix, because existing drivers check if the interface is down as part of the ops. But new drivers shouldn't have to do this, as long as they can correctly alloc/free while down. Reviewed-by: Mina Almasry <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1eb824d commit 3e7efc3

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

include/net/netdev_queues.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ struct netdev_stat_ops {
117117
*
118118
* @ndo_queue_stop: Stop the RX queue at the specified index. The stopped
119119
* queue's memory is written at the specified address.
120+
*
121+
* Note that @ndo_queue_mem_alloc and @ndo_queue_mem_free may be called while
122+
* the interface is closed. @ndo_queue_start and @ndo_queue_stop will only
123+
* be called for an interface which is open.
120124
*/
121125
struct netdev_queue_mgmt_ops {
122126
size_t ndo_queue_mem_size;

net/core/netdev_rx_queue.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx)
3838
if (err)
3939
goto err_free_new_queue_mem;
4040

41-
err = qops->ndo_queue_stop(dev, old_mem, rxq_idx);
42-
if (err)
43-
goto err_free_new_queue_mem;
44-
45-
err = qops->ndo_queue_start(dev, new_mem, rxq_idx);
46-
if (err)
47-
goto err_start_queue;
41+
if (netif_running(dev)) {
42+
err = qops->ndo_queue_stop(dev, old_mem, rxq_idx);
43+
if (err)
44+
goto err_free_new_queue_mem;
45+
46+
err = qops->ndo_queue_start(dev, new_mem, rxq_idx);
47+
if (err)
48+
goto err_start_queue;
49+
} else {
50+
swap(new_mem, old_mem);
51+
}
4852

4953
qops->ndo_queue_mem_free(dev, old_mem);
5054

0 commit comments

Comments
 (0)