Skip to content

Commit d554209

Browse files
gal-pressmangregkh
authored andcommitted
net/mlx5e: IPsec, fix ASO poll timeout with read_poll_timeout_atomic()
[ Upstream commit edccdd1 ] The do-while poll loop uses jiffies for its timeout: expires = jiffies + msecs_to_jiffies(10); jiffies is sampled at an arbitrary point within the current tick, so the first partial tick contributes anywhere from a full tick down to nearly zero real time. For small msecs_to_jiffies() results this is significant, the effective poll window can be much shorter than the requested 10ms, and in the worst case the loop exits after a single iteration (e.g., when HZ=100), well before the device has delivered the CQE. Replace the loop with read_poll_timeout_atomic(), which counts elapsed time via udelay() accounting rather than jiffies, guaranteeing the full poll window regardless of HZ. Additionally, read_poll_timeout_atomic() executes the poll operation one more time after the timeout has expired, giving the CQE a final chance to be detected. The old do-while loop could exit without a final poll if the timeout expired during the udelay() between iterations. Fixes: 76e463f ("net/mlx5e: Overcome slow response for first IPsec ASO WQE") Signed-off-by: Gal Pressman <gal@nvidia.com> Reviewed-by: Jianbo Liu <jianbol@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/20260409202852.158059-3-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4cdb61d commit d554209

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
22
/* Copyright (c) 2017, Mellanox Technologies inc. All rights reserved. */
33

4+
#include <linux/iopoll.h>
5+
46
#include "mlx5_core.h"
57
#include "en.h"
68
#include "ipsec.h"
@@ -593,7 +595,6 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,
593595
struct mlx5_wqe_aso_ctrl_seg *ctrl;
594596
struct mlx5e_hw_objs *res;
595597
struct mlx5_aso_wqe *wqe;
596-
unsigned long expires;
597598
u8 ds_cnt;
598599
int ret;
599600

@@ -615,13 +616,8 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,
615616
mlx5e_ipsec_aso_copy(ctrl, data);
616617

617618
mlx5_aso_post_wqe(aso->aso, false, &wqe->ctrl);
618-
expires = jiffies + msecs_to_jiffies(10);
619-
do {
620-
ret = mlx5_aso_poll_cq(aso->aso, false);
621-
if (ret)
622-
/* We are in atomic context */
623-
udelay(10);
624-
} while (ret && time_is_after_jiffies(expires));
619+
read_poll_timeout_atomic(mlx5_aso_poll_cq, ret, !ret, 10,
620+
10 * USEC_PER_MSEC, false, aso->aso, false);
625621
if (!ret)
626622
memcpy(sa_entry->ctx, aso->ctx, MLX5_ST_SZ_BYTES(ipsec_aso));
627623
spin_unlock_bh(&aso->lock);

0 commit comments

Comments
 (0)