diff mbox series

mlx5: simplify EQ interrupt polling logic

Message ID 20241023205113.255866-1-csander@purestorage.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series mlx5: simplify EQ interrupt polling logic | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 48 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-29--06-00 (tests: 777)

Commit Message

Caleb Sander Oct. 23, 2024, 8:51 p.m. UTC
Use a while loop in mlx5_eq_comp_int() and mlx5_eq_async_int() to
clarify the EQE polling logic. This consolidates the next_eqe_sw() calls
for the first and subequent iterations. It also avoids a goto. Turn the
num_eqes < MLX5_EQ_POLLING_BUDGET check into a break condition.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c | 22 +++++++-------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

Tariq Toukan Oct. 24, 2024, 4:59 p.m. UTC | #1
On 23/10/2024 23:51, Caleb Sander Mateos wrote:
> Use a while loop in mlx5_eq_comp_int() and mlx5_eq_async_int() to
> clarify the EQE polling logic. This consolidates the next_eqe_sw() calls
> for the first and subequent iterations. It also avoids a goto. Turn the
> num_eqes < MLX5_EQ_POLLING_BUDGET check into a break condition.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/eq.c | 22 +++++++-------------
>   1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> index 68cb86b37e56..859dcf09b770 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> @@ -114,15 +114,11 @@ static int mlx5_eq_comp_int(struct notifier_block *nb,
>   	struct mlx5_eq *eq = &eq_comp->core;
>   	struct mlx5_eqe *eqe;
>   	int num_eqes = 0;
>   	u32 cqn = -1;
>   
> -	eqe = next_eqe_sw(eq);
> -	if (!eqe)
> -		goto out;
> -
> -	do {
> +	while ((eqe = next_eqe_sw(eq))) {
>   		struct mlx5_core_cq *cq;
>   
>   		/* Make sure we read EQ entry contents after we've
>   		 * checked the ownership bit.
>   		 */
> @@ -140,13 +136,14 @@ static int mlx5_eq_comp_int(struct notifier_block *nb,
>   					    "Completion event for bogus CQ 0x%x\n", cqn);
>   		}
>   
>   		++eq->cons_index;
>   
> -	} while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe = next_eqe_sw(eq)));
> +		if (++num_eqes >= MLX5_EQ_POLLING_BUDGET)
> +			break;
> +	}
>   
> -out:
>   	eq_update_ci(eq, 1);
>   
>   	if (cqn != -1)
>   		tasklet_schedule(&eq_comp->tasklet_ctx.task);
>   
> @@ -213,15 +210,11 @@ static int mlx5_eq_async_int(struct notifier_block *nb,
>   	eqt = dev->priv.eq_table;
>   
>   	recovery = action == ASYNC_EQ_RECOVER;
>   	mlx5_eq_async_int_lock(eq_async, recovery, &flags);
>   
> -	eqe = next_eqe_sw(eq);
> -	if (!eqe)
> -		goto out;
> -
> -	do {
> +	while ((eqe = next_eqe_sw(eq))) {
>   		/*
>   		 * Make sure we read EQ entry contents after we've
>   		 * checked the ownership bit.
>   		 */
>   		dma_rmb();
> @@ -229,13 +222,14 @@ static int mlx5_eq_async_int(struct notifier_block *nb,
>   		atomic_notifier_call_chain(&eqt->nh[eqe->type], eqe->type, eqe);
>   		atomic_notifier_call_chain(&eqt->nh[MLX5_EVENT_TYPE_NOTIFY_ANY], eqe->type, eqe);
>   
>   		++eq->cons_index;
>   
> -	} while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe = next_eqe_sw(eq)));
> +		if (++num_eqes >= MLX5_EQ_POLLING_BUDGET)
> +			break;
> +	}
>   
> -out:
>   	eq_update_ci(eq, 1);
>   	mlx5_eq_async_int_unlock(eq_async, recovery, &flags);
>   
>   	return unlikely(recovery) ? num_eqes : 0;
>   }

LGTM.
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>

Thanks.
Simon Horman Oct. 25, 2024, 9:03 a.m. UTC | #2
On Wed, Oct 23, 2024 at 02:51:12PM -0600, Caleb Sander Mateos wrote:
> Use a while loop in mlx5_eq_comp_int() and mlx5_eq_async_int() to
> clarify the EQE polling logic. This consolidates the next_eqe_sw() calls
> for the first and subequent iterations. It also avoids a goto. Turn the
> num_eqes < MLX5_EQ_POLLING_BUDGET check into a break condition.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Jakub Kicinski Oct. 30, 2024, 12:29 a.m. UTC | #3
On Wed, 23 Oct 2024 14:51:12 -0600 Caleb Sander Mateos wrote:
> Use a while loop in mlx5_eq_comp_int() and mlx5_eq_async_int() to
> clarify the EQE polling logic. This consolidates the next_eqe_sw() calls
> for the first and subequent iterations. It also avoids a goto. Turn the
> num_eqes < MLX5_EQ_POLLING_BUDGET check into a break condition.

Applied, thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index 68cb86b37e56..859dcf09b770 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -114,15 +114,11 @@  static int mlx5_eq_comp_int(struct notifier_block *nb,
 	struct mlx5_eq *eq = &eq_comp->core;
 	struct mlx5_eqe *eqe;
 	int num_eqes = 0;
 	u32 cqn = -1;
 
-	eqe = next_eqe_sw(eq);
-	if (!eqe)
-		goto out;
-
-	do {
+	while ((eqe = next_eqe_sw(eq))) {
 		struct mlx5_core_cq *cq;
 
 		/* Make sure we read EQ entry contents after we've
 		 * checked the ownership bit.
 		 */
@@ -140,13 +136,14 @@  static int mlx5_eq_comp_int(struct notifier_block *nb,
 					    "Completion event for bogus CQ 0x%x\n", cqn);
 		}
 
 		++eq->cons_index;
 
-	} while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe = next_eqe_sw(eq)));
+		if (++num_eqes >= MLX5_EQ_POLLING_BUDGET)
+			break;
+	}
 
-out:
 	eq_update_ci(eq, 1);
 
 	if (cqn != -1)
 		tasklet_schedule(&eq_comp->tasklet_ctx.task);
 
@@ -213,15 +210,11 @@  static int mlx5_eq_async_int(struct notifier_block *nb,
 	eqt = dev->priv.eq_table;
 
 	recovery = action == ASYNC_EQ_RECOVER;
 	mlx5_eq_async_int_lock(eq_async, recovery, &flags);
 
-	eqe = next_eqe_sw(eq);
-	if (!eqe)
-		goto out;
-
-	do {
+	while ((eqe = next_eqe_sw(eq))) {
 		/*
 		 * Make sure we read EQ entry contents after we've
 		 * checked the ownership bit.
 		 */
 		dma_rmb();
@@ -229,13 +222,14 @@  static int mlx5_eq_async_int(struct notifier_block *nb,
 		atomic_notifier_call_chain(&eqt->nh[eqe->type], eqe->type, eqe);
 		atomic_notifier_call_chain(&eqt->nh[MLX5_EVENT_TYPE_NOTIFY_ANY], eqe->type, eqe);
 
 		++eq->cons_index;
 
-	} while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe = next_eqe_sw(eq)));
+		if (++num_eqes >= MLX5_EQ_POLLING_BUDGET)
+			break;
+	}
 
-out:
 	eq_update_ci(eq, 1);
 	mlx5_eq_async_int_unlock(eq_async, recovery, &flags);
 
 	return unlikely(recovery) ? num_eqes : 0;
 }