History

net/mlx5: cmdif, Avoid skipping reclaim pages if FW is not accessible

In case of pci is offline reclaim_pages_cmd() will still try to call the FW to release FW pages, cmd_exec() in this case will return a silent success without actually calling the FW. This is wrong and will cause page leaks, what we should do is to detect pci offline or command interface un-available before tying to access the FW and manually release the FW pages in the driver. In this patch we share the code to check for FW command interface availability and we call it in sensitive places e.g. reclaim_pages_cmd(). Alternative fix: 1. Remove MLX5_CMD_OP_MANAGE_PAGES form mlx5_internal_err_ret_value, command success simulation list. 2. Always Release FW pages even if cmd_exec fails in reclaim_pages_cmd().

Saeed Mahameed committed 6 years ago

Commit b898ce71 parent 410bd753 files · +11 −9Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/mellanox/mlx5/core/cmd.c +9 −8
  2. drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +1 −1
  3. include/linux/mlx5/driver.h +1 −0
drivers/net/ethernet/mellanox/mlx5/core/cmd.c+9−8
@@ -902,6 +902,13 @@ retry: · 901 unmodified lines
902 return idx;902 return idx;
903}903}
904 904
905bool mlx5_cmd_is_down(struct mlx5_core_dev *dev)
906{
907 return pci_channel_offline(dev->pdev) ||
908 dev->cmd.state != MLX5_CMDIF_STATE_UP ||
909 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR;
910}
911
905static void cmd_work_handler(struct work_struct *work)912static void cmd_work_handler(struct work_struct *work)
906{913{
907 struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);914 struct mlx5_cmd_work_ent *ent = container_of(work, struct mlx5_cmd_work_ent, work);
@@ -967,10 +974,7 @@ static void cmd_work_handler(struct work_struct *work) · 59 unmodified lines
967 set_bit(MLX5_CMD_ENT_STATE_PENDING_COMP, &ent->state);974 set_bit(MLX5_CMD_ENT_STATE_PENDING_COMP, &ent->state);
968 975
969 /* Skip sending command to fw if internal error */976 /* Skip sending command to fw if internal error */
970 if (pci_channel_offline(dev->pdev) ||977 if (mlx5_cmd_is_down(dev) || !opcode_allowed(&dev->cmd, ent->op)) {
971 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR ||
972 cmd->state != MLX5_CMDIF_STATE_UP ||
973 !opcode_allowed(&dev->cmd, ent->op)) {
974 u8 status = 0;978 u8 status = 0;
975 u32 drv_synd;979 u32 drv_synd;
976 980
@@ -1800,10 +1804,7 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, · 823 unmodified lines
1800 u8 token;1804 u8 token;
1801 1805
1802 opcode = MLX5_GET(mbox_in, in, opcode);1806 opcode = MLX5_GET(mbox_in, in, opcode);
1803 if (pci_channel_offline(dev->pdev) ||1807 if (mlx5_cmd_is_down(dev) || !opcode_allowed(&dev->cmd, opcode)) {
1804 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR ||
1805 dev->cmd.state != MLX5_CMDIF_STATE_UP ||
1806 !opcode_allowed(&dev->cmd, opcode)) {
1807 err = mlx5_internal_err_ret_value(dev, opcode, &drv_synd, &status);1808 err = mlx5_internal_err_ret_value(dev, opcode, &drv_synd, &status);
1808 MLX5_SET(mbox_out, out, status, status);1809 MLX5_SET(mbox_out, out, status, status);
1809 MLX5_SET(mbox_out, out, syndrome, drv_synd);1810 MLX5_SET(mbox_out, out, syndrome, drv_synd);
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c+1−1
@@ -432,7 +432,7 @@ static int reclaim_pages_cmd(struct mlx5_core_dev *dev, · 431 unmodified lines
432 u32 npages;432 u32 npages;
433 u32 i = 0;433 u32 i = 0;
434 434
435 if (dev->state != MLX5_DEVICE_STATE_INTERNAL_ERROR)435 if (!mlx5_cmd_is_down(dev))
436 return mlx5_cmd_exec(dev, in, in_size, out, out_size);436 return mlx5_cmd_exec(dev, in, in_size, out, out_size);
437 437
438 /* No hard feelings, we want our pages back! */438 /* No hard feelings, we want our pages back! */
include/linux/mlx5/driver.h+1−0
@@ -935,6 +935,7 @@ int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, · 934 unmodified lines
935int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,935int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
936 void *out, int out_size);936 void *out, int out_size);
937void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);937void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);
938bool mlx5_cmd_is_down(struct mlx5_core_dev *dev);
938 939
939int mlx5_core_get_caps(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type);940int mlx5_core_get_caps(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type);
940int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn);941int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t