net/mlx5e: Report a down device as -ENETDOWN to queue restarts
Subsystems (5)
PATCH 1/1 net/mlx5e: Report a down device as -ENETDOWN to queue restarts
Unbinding a memory provider from a queue of an mlx5 device that is down triggers the WARN_ON() in __netif_mp_close_rxq(). The core asks the driver for queue memory before it checks netif_running(), and takes only -ENETDOWN as nothing to restart, see commit 34f71de3f548 ("net: avoid false positive warnings in __net_mp_close_rxq()"). mlx5e_queue_mem_alloc() refuses a device that is not open with -ENODEV:
WARNING: net/core/netdev_rx_queue.c:303 at __netif_mp_close_rxq+0x18f/0x1b0 Call Trace: net_devmem_unbind_dmabuf+0x150/0x260 netdev_nl_sock_priv_destroy+0x11d/0x160 genl_release+0x107/0x130 netlink_release+0x8a6/0x13f0 sock_close+0x9c/0x1d0
io_uring zcrx unbind takes the same path.
Return -ENETDOWN for a device that is not open. The core has already cleared the provider of the queue when it asks, and the device opens without it, so nothing else changes.
Found by code review while adding a memory provider to mlx5. Reproduced on a ConnectX-7 (firmware 28.48.1000): bind a devmem dmabuf to a queue with ncdevmem, take the link down, then kill ncdevmem. With this patch the same steps are silent, and the device comes back up and receives.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -1
@@ -5735,8 +5735,11 @@ static int mlx5e_queue_mem_alloc(struct net_device *dev,int err;mutex_lock (&priv->state_lock); +/* Core takes -ENETDOWN as nothing to restart, as when a memory +* provider goes while the device is down +*/ if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) { - err = -ENODEV ; + err = -ENETDOWN ; goto unlock; }
base-commit: e2fb9368a41662bc54624f9be87ea8989b109306
Signature · 1 line
2.56.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 22 lines
Unbinding a memory provider from a queue of an mlx5 device that is down triggers the
WARN_ON()in__netif_mp_close_rxq(). The core asks the driver for queue memory before it checksnetif_running(), and takes only-ENETDOWNas nothing to restart, see commit34f71de3f548("net: avoid false positive warnings in__net_mp_close_rxq()").mlx5e_queue_mem_alloc()refuses a device that is not open with-ENODEV:WARNING: net/core/netdev_rx_queue.c:303 at __netif_mp_close_rxq+0x18f/0x1b0 Call Trace: net_devmem_unbind_dmabuf+0x150/0x260 netdev_nl_sock_priv_destroy+0x11d/0x160 genl_release+0x107/0x130 netlink_release+0x8a6/0x13f0 sock_close+0x9c/0x1d0
io_uringzcrx unbind takes the same path.Return
-ENETDOWNfor a device that is not open. The core has already cleared the provider of the queue when it asks, and the device opens without it, so nothing else changes.
Quoted 8 lines
Found by code review while adding a memory provider to mlx5. Reproduced on a ConnectX-7 (firmware 28.48.1000): bind a devmem dmabuf to a queue with ncdevmem, take the link down, then kill ncdevmem. With this patch the same steps are silent, and the device comes back up and receives.
Fixes b2588ea40ec9 ("net/mlx5e: Implement queue mgmt ops and single channel swap")Signed-off-by Björn Töpel <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 39 lines · Björn Töpel
Unbinding a memory provider from a queue of an mlx5 device that is down triggers the
WARN_ON()in__netif_mp_close_rxq(). The core asks the driver for queue memory before it checksnetif_running(), and takes only-ENETDOWNas nothing to restart, see commit34f71de3f548("net: avoid false positive warnings in__net_mp_close_rxq()").mlx5e_queue_mem_alloc()refuses a device that is not open with-ENODEV:WARNING: net/core/netdev_rx_queue.c:303 at __netif_mp_close_rxq+0x18f/0x1b0 Call Trace: net_devmem_unbind_dmabuf+0x150/0x260 netdev_nl_sock_priv_destroy+0x11d/0x160 genl_release+0x107/0x130 netlink_release+0x8a6/0x13f0 sock_close+0x9c/0x1d0
io_uringzcrx unbind takes the same path.Return
-ENETDOWNfor a device that is not open. The core has already cleared the provider of the queue when it asks, and the device opens without it, so nothing else changes.Found by code review while adding a memory provider to mlx5. Reproduced on a ConnectX-7 (firmware 28.48.1000): bind a devmem dmabuf to a queue with ncdevmem, take the link down, then kill ncdevmem. With this patch the same steps are silent, and the device comes back up and receives.
Fixes b2588ea40ec9 ("net/mlx5e: Implement queue mgmt ops and single channel swap")Signed-off-by Björn Töpel <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en_main.c static int mlx5e_queue_mem_alloc(struct net_device *dev, · line 5740
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3
-0@@ -5735,8 +5735,11 @@ static int mlx5e_queue_mem_alloc(struct net_device *dev,int err;mutex_lock (&priv->state_lock); +/* Core takes -ENETDOWN as nothing to restart, as when a memory +* provider goes while the device is down +*/
I'd drop this comment. Other than that:
Thanks,
Dragos
Quoted 8 lines · Dragos Tatulea
Quoted 7 lines · Björn Töpel
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0
-0@@ -5735,8 +5735,11 @@ static int mlx5e_queue_mem_alloc(struct net_device *dev,int err;
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c static int mlx5e_queue_mem_alloc(struct net_device *dev, · line 5740
Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3
-0mutex_lock (&priv->state_lock); +/* Core takes -ENETDOWN as nothing to restart, as when a memory +* provider goes while the device is down +*/ I'd drop this comment. Other than that:
Reviewed-by Dragos Tatulea <[email protected]>
Thanks, I'll spin a v2 w/o this.