]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/mlx5: Fix a race when moving command interface to events mode
authorEran Ben Elisha <eranbe@mellanox.com>
Wed, 18 Mar 2020 19:44:32 +0000 (21:44 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Sat, 23 May 2020 00:28:36 +0000 (17:28 -0700)
commitd43b7007dbd1195a5b6b83213e49b1516aaf6f5e
tree2de29011ba9f66e3883e37253b06e87baaf23a34
parent17d00e839d3b592da9659c1977d45f85b77f986a
net/mlx5: Fix a race when moving command interface to events mode

After driver creates (via FW command) an EQ for commands, the driver will
be informed on new commands completion by EQE. However, due to a race in
driver's internal command mode metadata update, some new commands will
still be miss-handled by driver as if we are in polling mode. Such commands
can get two non forced completion, leading to already freed command entry
access.

CREATE_EQ command, that maps EQ to the command queue must be posted to the
command queue while it is empty and no other command should be posted.

Add SW mechanism that once the CREATE_EQ command is about to be executed,
all other commands will return error without being sent to the FW. Allow
sending other commands only after successfully changing the driver's
internal command mode metadata.
We can safely return error to all other commands while creating the command
EQ, as all other commands might be sent from the user/application during
driver load. Application can rerun them later after driver's load was
finished.

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
drivers/net/ethernet/mellanox/mlx5/core/eq.c
include/linux/mlx5/driver.h