All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: Enter error state on surprise removal
@ 2026-12-02 19:43 Tariq Toukan
  2026-12-02 19:48 ` netdev-bot+sinfo
  2026-12-02 19:54 ` sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Tariq Toukan @ 2026-12-02 19:43 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	netdev, Paolo Abeni, Willem de Bruijn
  Cc: Gal Pressman, Leon Romanovsky, linux-rdma, Mark Bloch,
	Moshe Shemesh, Moshe Shemesh, Parav Pandit, Saeed Mahameed,
	Saeed Mahameed, Tariq Toukan, Uri Dar

From: Uri Dar <udar@nvidia.com>

On PCI surprise removal, remove_one() drains the health work before
tearing the device down, so the fatal health work never puts the dead
device in error state. Work already posted to the device, such as the
IPoIB multicast leave MADs sent during IB unregister, then never
completes and the removal hangs in mcast_remove_one().

On remove_one(), after draining the health work, enter error state if
the device is dead. Do it without the "previous error is still being
handled" check of mlx5_enter_error_state(): once the health work is
drained, nobody else will handle an error that poll_health() already
marked. Skip it when the device is not loaded, for example after a
failed reload: the command interface may not be set up, and no driver
is left waiting on the device.

Fixes: 41798df9bfca ("net/mlx5: Drain wq first during PCI device removal")
Signed-off-by: Uri Dar <udar@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/health.c    | 12 ++++++++++++
 drivers/net/ethernet/mellanox/mlx5/core/main.c      |  1 +
 drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h |  1 +
 3 files changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index aeeb136f5ebc..622c9e0f065d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -224,6 +224,18 @@ void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force)
 	mutex_unlock(&dev->intf_state_mutex);
 }
 
+/* Caller must drain the fw_reset and health work before calling this */
+void mlx5_health_enter_error_state_drained(struct mlx5_core_dev *dev)
+{
+	if (!mlx5_health_check_fatal_sensors(dev))
+		return;
+
+	mutex_lock(&dev->intf_state_mutex);
+	if (test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state))
+		enter_error_state(dev, false);
+	mutex_unlock(&dev->intf_state_mutex);
+}
+
 void mlx5_error_sw_reset(struct mlx5_core_dev *dev)
 {
 	unsigned long end, delay_ms = mlx5_tout_ms(dev, PCI_TOGGLE);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 0439fcfb9ce5..567df9d8eb52 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -2014,6 +2014,7 @@ static void remove_one(struct pci_dev *pdev)
 	set_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state);
 	mlx5_drain_fw_reset(dev);
 	mlx5_drain_health_wq(dev);
+	mlx5_health_enter_error_state_drained(dev);
 	mlx5_sriov_disable(pdev, false);
 	mlx5_uninit_one(dev);
 	mlx5_shd_uninit(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index d84d0424d04e..9edbf190683e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -231,6 +231,7 @@ int mlx5_cmd_teardown_hca(struct mlx5_core_dev *dev);
 int mlx5_cmd_force_teardown_hca(struct mlx5_core_dev *dev);
 int mlx5_cmd_fast_teardown_hca(struct mlx5_core_dev *dev);
 void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force);
+void mlx5_health_enter_error_state_drained(struct mlx5_core_dev *dev);
 void mlx5_error_sw_reset(struct mlx5_core_dev *dev);
 u32 mlx5_health_check_fatal_sensors(struct mlx5_core_dev *dev);
 int mlx5_health_wait_pci_up(struct mlx5_core_dev *dev);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02 19:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 19:43 [PATCH net] net/mlx5: Enter error state on surprise removal Tariq Toukan
2026-12-02 19:48 ` netdev-bot+sinfo
2026-12-02 19:54 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.