[SRU P][PATCH 1/1] net: devmem: don't call queue stop / start when the interface is down
Stefan Bader
stefan.bader at canonical.com
Fri Oct 10 09:43:21 UTC 2025
From: Jakub Kicinski <kuba at kernel.org>
BugLink: https://bugs.launchpad.net/bugs/2121866
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 <almasrymina at google.com>
Link: https://patch.msgid.link/20250206225638.1387810-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
Fixes: 285b3f78eabd "(netdevsim: allow normal queue reset while down)"
(backported from commit 3e7efc3f4f03bca0ea630c302e7c79cf807476bb)
[smb: Adjusted for missing dev->queue_mgmt_ops alias]
Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
---
include/net/netdev_queues.h | 4 ++++
net/core/netdev_rx_queue.c | 18 +++++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index 88598e14ecfa..e0921465a1d2 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -123,6 +123,10 @@ void netdev_stat_queue_sum(struct net_device *netdev,
*
* @ndo_queue_stop: Stop the RX queue at the specified index. The stopped
* queue's memory is written at the specified address.
+ *
+ * Note that @ndo_queue_mem_alloc and @ndo_queue_mem_free may be called while
+ * the interface is closed. @ndo_queue_start and @ndo_queue_stop will only
+ * be called for an interface which is open.
*/
struct netdev_queue_mgmt_ops {
size_t ndo_queue_mem_size;
diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c
index 0784de243a65..eecaef195067 100644
--- a/net/core/netdev_rx_queue.c
+++ b/net/core/netdev_rx_queue.c
@@ -38,13 +38,17 @@ int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx)
if (err)
goto err_free_new_queue_mem;
- err = dev->queue_mgmt_ops->ndo_queue_stop(dev, old_mem, rxq_idx);
- if (err)
- goto err_free_new_queue_mem;
-
- err = dev->queue_mgmt_ops->ndo_queue_start(dev, new_mem, rxq_idx);
- if (err)
- goto err_start_queue;
+ if (netif_running(dev)) {
+ err = dev->queue_mgmt_ops->ndo_queue_stop(dev, old_mem, rxq_idx);
+ if (err)
+ goto err_free_new_queue_mem;
+
+ err = dev->queue_mgmt_ops->ndo_queue_start(dev, new_mem, rxq_idx);
+ if (err)
+ goto err_start_queue;
+ } else {
+ swap(new_mem, old_mem);
+ }
dev->queue_mgmt_ops->ndo_queue_mem_free(dev, old_mem);
--
2.43.0
More information about the kernel-team
mailing list