Skip to content

Commit aaf2e65

Browse files
mosheshemesh2Saeed Mahameed
authored and
Saeed Mahameed
committed
net/mlx5: Fix handling of entry refcount when command is not issued to FW
In case command interface is down, or the command is not allowed, driver did not increment the entry refcount, but might have decrement as part of forced completion handling. Fix that by always increment and decrement the refcount to make it symmetric for all flows. Fixes: 50b2412 ("net/mlx5: Avoid possible free of command entry while timeout comp handler") Signed-off-by: Eran Ben Elisha <[email protected]> Signed-off-by: Moshe Shemesh <[email protected]> Reported-by: Jack Wang <[email protected]> Tested-by: Jack Wang <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 870c248 commit aaf2e65

File tree

1 file changed

+3
-3
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,14 +1005,14 @@ static void cmd_work_handler(struct work_struct *work)
10051005
cmd_ent_get(ent);
10061006
set_bit(MLX5_CMD_ENT_STATE_PENDING_COMP, &ent->state);
10071007

1008+
cmd_ent_get(ent); /* for the _real_ FW event on completion */
10081009
/* Skip sending command to fw if internal error */
10091010
if (mlx5_cmd_is_down(dev) || !opcode_allowed(&dev->cmd, ent->op)) {
10101011
ent->ret = -ENXIO;
10111012
mlx5_cmd_comp_handler(dev, 1ULL << ent->idx, true);
10121013
return;
10131014
}
10141015

1015-
cmd_ent_get(ent); /* for the _real_ FW event on completion */
10161016
/* ring doorbell after the descriptor is valid */
10171017
mlx5_core_dbg(dev, "writing 0x%x to command doorbell\n", 1 << ent->idx);
10181018
wmb();
@@ -1661,8 +1661,8 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
16611661
cmd_ent_put(ent); /* timeout work was canceled */
16621662

16631663
if (!forced || /* Real FW completion */
1664-
pci_channel_offline(dev->pdev) || /* FW is inaccessible */
1665-
dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
1664+
mlx5_cmd_is_down(dev) || /* No real FW completion is expected */
1665+
!opcode_allowed(cmd, ent->op))
16661666
cmd_ent_put(ent);
16671667

16681668
ent->ts2 = ktime_get_ns();

0 commit comments

Comments
 (0)