From 7bf7c4367db690087a144c0e54efed8d2df5b11b Mon Sep 17 00:00:00 2001 From: Yevgeny Kliteynik Date: Tue, 15 Sep 2026 14:19:10 +0300 Subject: [PATCH] net/mlx5: HWS, Add timeout mechanism to draining send queues HWS has a timeout mechanism for usual polling for completion, but it was missing such a mechanism for draining the send queues. Signed-off-by: Yevgeny Kliteynik Reviewed-by: Erez Shitrit Signed-off-by: Tariq Toukan Link: https://patch.msgid.link/20260915111912.3926585-5-tariqt@nvidia.com Signed-off-by: Jakub Kicinski --- .../ethernet/mellanox/mlx5/core/steering/hws/bwc.c | 4 +++- .../ethernet/mellanox/mlx5/core/steering/hws/send.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c index 3bcf412a08c4..14a2bb9167a4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c @@ -460,7 +460,9 @@ int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx, got_comp = !!ret; if (unlikely(!got_comp && time_after(jiffies, timeout))) { - mlx5hws_err(ctx, "BWC poll error: polling queue %d - TIMEOUT\n", queue_id); + mlx5hws_err(ctx, + "BWC poll error: polling queue %d - TIMEOUT (%d sec)\n", + queue_id, MLX5HWS_BWC_POLLING_TIMEOUT); return -ETIMEDOUT; } } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c index 49dee44d0bef..9ff109fc8230 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c @@ -1192,6 +1192,8 @@ int mlx5hws_send_queue_action(struct mlx5hws_context *ctx, u16 queue_id, u32 actions) { + unsigned long timeout = jiffies + + secs_to_jiffies(MLX5HWS_BWC_POLLING_TIMEOUT); struct mlx5hws_send_ring_sq *send_sq; struct mlx5hws_send_engine *queue; bool wait_comp = false; @@ -1213,9 +1215,18 @@ int mlx5hws_send_queue_action(struct mlx5hws_context *ctx, mlx5hws_send_engine_flush_queue(queue); /* Poll queue until empty */ - while (wait_comp && !mlx5hws_send_engine_empty(queue)) + while (wait_comp && !mlx5hws_send_engine_empty(queue)) { hws_send_engine_poll_cq(queue, NULL, &polled, 0); + if (unlikely(time_after(jiffies, timeout))) { + mlx5hws_err(ctx, + "Error draining send queue %d - TIMEOUT (%d sec)\n", + queue_id, + MLX5HWS_BWC_POLLING_TIMEOUT); + return -ETIMEDOUT; + } + } + break; default: return -EINVAL;