]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mlx5: simplify EQ interrupt polling logic
authorCaleb Sander Mateos <csander@purestorage.com>
Wed, 23 Oct 2024 20:51:12 +0000 (14:51 -0600)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Oct 2024 23:20:00 +0000 (16:20 -0700)
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: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241023205113.255866-1-csander@purestorage.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/eq.c

index 68cb86b37e561f1058c0de6044d1373b7e506f78..859dcf09b7700754191657c56bb116b05ea59829 100644 (file)
@@ -116,11 +116,7 @@ static int mlx5_eq_comp_int(struct notifier_block *nb,
        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
@@ -142,9 +138,10 @@ static int mlx5_eq_comp_int(struct notifier_block *nb,
 
                ++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)
@@ -215,11 +212,7 @@ static int mlx5_eq_async_int(struct notifier_block *nb,
        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.
@@ -231,9 +224,10 @@ static int mlx5_eq_async_int(struct notifier_block *nb,
 
                ++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);