diff mbox series

[net,01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device

Message ID 20210519060523.17875-2-saeed@kernel.org (mailing list archive)
State Accepted
Commit 3410fbcd47dc6479af4309febf760ccaa5efb472
Delegated to: Netdev Maintainers
Headers show
Series [net,01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device | expand

Checks

Context Check Description
netdev/cover_letter success Pull request
netdev/fixes_present success Link
netdev/patch_count warning Series longer than 15 patches
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers fail 1 blamed authors not CCed: noaos@mellanox.com; 5 maintainers not CCed: jgg@ziepe.ca noaos@mellanox.com dledford@redhat.com linux-rdma@vger.kernel.org leon@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 111 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/header_inline success Link

Commit Message

Saeed Mahameed May 19, 2021, 6:05 a.m. UTC
From: Maor Gottlieb <maorg@nvidia.com>

mlx5_core_dev holds pointer to static profile, hence when the
log_max_qp of the profile is override by some device, then it
effect all other mlx5 devices that share the same profile.
Fix it by having a profile instance for every mlx5 device.

Fixes: 883371c453b9 ("net/mlx5: Check FW limitations on log_max_qp before setting it")
Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/infiniband/hw/mlx5/mr.c               |  4 +-
 .../net/ethernet/mellanox/mlx5/core/main.c    | 11 +++--
 include/linux/mlx5/driver.h                   | 44 +++++++++----------
 3 files changed, 29 insertions(+), 30 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org May 19, 2021, 7:30 p.m. UTC | #1
Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Tue, 18 May 2021 23:05:08 -0700 you wrote:
> From: Maor Gottlieb <maorg@nvidia.com>
> 
> mlx5_core_dev holds pointer to static profile, hence when the
> log_max_qp of the profile is override by some device, then it
> effect all other mlx5 devices that share the same profile.
> Fix it by having a profile instance for every mlx5 device.
> 
> [...]

Here is the summary with links:
  - [net,01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device
    https://git.kernel.org/netdev/net/c/3410fbcd47dc
  - [net,02/16] net/mlx5e: Fix nullptr in add_vlan_push_action()
    https://git.kernel.org/netdev/net/c/dca59f4a7919
  - [net,03/16] net/mlx5: Set reformat action when needed for termination rules
    https://git.kernel.org/netdev/net/c/442b3d7b671b
  - [net,04/16] net/mlx5: Fix err prints and return when creating termination table
    https://git.kernel.org/netdev/net/c/fca086617af8
  - [net,05/16] net/mlx5: SF, Fix show state inactive when its inactivated
    https://git.kernel.org/netdev/net/c/82041634d96e
  - [net,06/16] net/mlx5e: Fix nullptr in mlx5e_tc_add_fdb_flow()
    https://git.kernel.org/netdev/net/c/fe7738eb3ca3
  - [net,07/16] net/mlx5e: Fix null deref accessing lag dev
    https://git.kernel.org/netdev/net/c/83026d83186b
  - [net,08/16] net/mlx5e: Make sure fib dev exists in fib event
    https://git.kernel.org/netdev/net/c/eb96cc15926f
  - [net,09/16] net/mlx5e: reset XPS on error flow if netdev isn't registered yet
    https://git.kernel.org/netdev/net/c/77ecd10d0a8a
  - [net,10/16] net/mlx5e: Fix multipath lag activation
    https://git.kernel.org/netdev/net/c/97817fcc684e
  - [net,11/16] net/mlx5e: Reject mirroring on source port change encap rules
    https://git.kernel.org/netdev/net/c/7d1a3d08c8a6
  - [net,12/16] net/mlx5e: Fix error path of updating netdev queues
    https://git.kernel.org/netdev/net/c/5e7923acbd86
  - [net,13/16] {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table
    https://git.kernel.org/netdev/net/c/7c9f131f366a
  - [net,14/16] net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count
    https://git.kernel.org/netdev/net/c/75e8564e919f
  - [net,15/16] net/mlx5: Set term table as an unmanaged flow table
    https://git.kernel.org/netdev/net/c/6ff51ab8aa8f
  - [net,16/16] mlx5e: add add missing BH locking around napi_schdule()
    https://git.kernel.org/netdev/net/c/e63052a5dd3c

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 4388afeff251..9662cd39c7ff 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -743,10 +743,10 @@  int mlx5_mr_cache_init(struct mlx5_ib_dev *dev)
 		ent->xlt = (1 << ent->order) * sizeof(struct mlx5_mtt) /
 			   MLX5_IB_UMR_OCTOWORD;
 		ent->access_mode = MLX5_MKC_ACCESS_MODE_MTT;
-		if ((dev->mdev->profile->mask & MLX5_PROF_MASK_MR_CACHE) &&
+		if ((dev->mdev->profile.mask & MLX5_PROF_MASK_MR_CACHE) &&
 		    !dev->is_rep && mlx5_core_is_pf(dev->mdev) &&
 		    mlx5_ib_can_load_pas_with_umr(dev, 0))
-			ent->limit = dev->mdev->profile->mr_cache[i].limit;
+			ent->limit = dev->mdev->profile.mr_cache[i].limit;
 		else
 			ent->limit = 0;
 		spin_lock_irq(&ent->lock);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index c114365eb126..a1d67bd7fb43 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -503,7 +503,7 @@  static int handle_hca_cap_odp(struct mlx5_core_dev *dev, void *set_ctx)
 
 static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)
 {
-	struct mlx5_profile *prof = dev->profile;
+	struct mlx5_profile *prof = &dev->profile;
 	void *set_hca_cap;
 	int err;
 
@@ -524,11 +524,11 @@  static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)
 		 to_fw_pkey_sz(dev, 128));
 
 	/* Check log_max_qp from HCA caps to set in current profile */
-	if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < profile[prof_sel].log_max_qp) {
+	if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < prof->log_max_qp) {
 		mlx5_core_warn(dev, "log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n",
-			       profile[prof_sel].log_max_qp,
+			       prof->log_max_qp,
 			       MLX5_CAP_GEN_MAX(dev, log_max_qp));
-		profile[prof_sel].log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp);
+		prof->log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp);
 	}
 	if (prof->mask & MLX5_PROF_MASK_QP_SIZE)
 		MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp,
@@ -1381,8 +1381,7 @@  int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
 	struct mlx5_priv *priv = &dev->priv;
 	int err;
 
-	dev->profile = &profile[profile_idx];
-
+	memcpy(&dev->profile, &profile[profile_idx], sizeof(dev->profile));
 	INIT_LIST_HEAD(&priv->ctx_list);
 	spin_lock_init(&priv->ctx_lock);
 	mutex_init(&dev->intf_state_mutex);
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index f8e8d7e90616..020a8f7fdbdd 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -703,6 +703,27 @@  struct mlx5_hv_vhca;
 #define MLX5_LOG_SW_ICM_BLOCK_SIZE(dev) (MLX5_CAP_DEV_MEM(dev, log_sw_icm_alloc_granularity))
 #define MLX5_SW_ICM_BLOCK_SIZE(dev) (1 << MLX5_LOG_SW_ICM_BLOCK_SIZE(dev))
 
+enum {
+	MLX5_PROF_MASK_QP_SIZE		= (u64)1 << 0,
+	MLX5_PROF_MASK_MR_CACHE		= (u64)1 << 1,
+};
+
+enum {
+	MR_CACHE_LAST_STD_ENTRY = 20,
+	MLX5_IMR_MTT_CACHE_ENTRY,
+	MLX5_IMR_KSM_CACHE_ENTRY,
+	MAX_MR_CACHE_ENTRIES
+};
+
+struct mlx5_profile {
+	u64	mask;
+	u8	log_max_qp;
+	struct {
+		int	size;
+		int	limit;
+	} mr_cache[MAX_MR_CACHE_ENTRIES];
+};
+
 struct mlx5_core_dev {
 	struct device *device;
 	enum mlx5_coredev_type coredev_type;
@@ -731,7 +752,7 @@  struct mlx5_core_dev {
 	struct mutex		intf_state_mutex;
 	unsigned long		intf_state;
 	struct mlx5_priv	priv;
-	struct mlx5_profile	*profile;
+	struct mlx5_profile	profile;
 	u32			issi;
 	struct mlx5e_resources  mlx5e_res;
 	struct mlx5_dm          *dm;
@@ -1083,18 +1104,6 @@  static inline u8 mlx5_mkey_variant(u32 mkey)
 	return mkey & 0xff;
 }
 
-enum {
-	MLX5_PROF_MASK_QP_SIZE		= (u64)1 << 0,
-	MLX5_PROF_MASK_MR_CACHE		= (u64)1 << 1,
-};
-
-enum {
-	MR_CACHE_LAST_STD_ENTRY = 20,
-	MLX5_IMR_MTT_CACHE_ENTRY,
-	MLX5_IMR_KSM_CACHE_ENTRY,
-	MAX_MR_CACHE_ENTRIES
-};
-
 /* Async-atomic event notifier used by mlx5 core to forward FW
  * evetns recived from event queue to mlx5 consumers.
  * Optimise event queue dipatching.
@@ -1148,15 +1157,6 @@  int mlx5_rdma_rn_get_params(struct mlx5_core_dev *mdev,
 			    struct ib_device *device,
 			    struct rdma_netdev_alloc_params *params);
 
-struct mlx5_profile {
-	u64	mask;
-	u8	log_max_qp;
-	struct {
-		int	size;
-		int	limit;
-	} mr_cache[MAX_MR_CACHE_ENTRIES];
-};
-
 enum {
 	MLX5_PCI_DEV_IS_VF		= 1 << 0,
 };