Skip to content

Commit 79a0e32

Browse files
shayshyikuba-moo
authored andcommitted
net/mlx5: pagealloc: Fix reclaim race during command interface teardown
The reclaim_pages_cmd() function sends a command to the firmware to reclaim pages if the command interface is active. A race condition can occur if the command interface goes down (e.g., due to a PCI error) while the mlx5_cmd_do() call is in flight. In this case, mlx5_cmd_do() will return an error. The original code would propagate this error immediately, bypassing the software-based page reclamation logic that is supposed to run when the command interface is down. Fix this by checking whether mlx5_cmd_do() returns -ENXIO, which mark that command interface is down. If this is the case, fall through to the software reclamation path. If the command failed for any another reason, or finished successfully, return as before. Fixes: b898ce7 ("net/mlx5: cmdif, Avoid skipping reclaim pages if FW is not accessible") Signed-off-by: Shay Drory <[email protected]> Reviewed-by: Moshe Shemesh <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b1f0349 commit 79a0e32

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,12 @@ static int reclaim_pages_cmd(struct mlx5_core_dev *dev,
489489
u32 func_id;
490490
u32 npages;
491491
u32 i = 0;
492+
int err;
492493

493-
if (!mlx5_cmd_is_down(dev))
494-
return mlx5_cmd_do(dev, in, in_size, out, out_size);
494+
err = mlx5_cmd_do(dev, in, in_size, out, out_size);
495+
/* If FW is gone (-ENXIO), proceed to forceful reclaim */
496+
if (err != -ENXIO)
497+
return err;
495498

496499
/* No hard feelings, we want our pages back! */
497500
npages = MLX5_GET(manage_pages_in, in, input_num_entries);

0 commit comments

Comments
 (0)