Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2733264pxj; Mon, 31 May 2021 09:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5EolCcay7xqSuoUhn1suydoM2qXssFgqqTpos6nTzWUiWc3bX0phOviWNBxcza7H8Qb8l X-Received: by 2002:a05:6402:883:: with SMTP id e3mr26294095edy.1.1622478096035; Mon, 31 May 2021 09:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478096; cv=none; d=google.com; s=arc-20160816; b=nXEU3qS5h+qh49OdZetVb7uDVWkUcpuEAiK49kDMWuZz5J/YE44KGOFi3XzFmydUL8 nqImJh0WIYRLVcZTD5DUaRHWABTKLpkmot7Gx9u4hlIOcJ5ErGCWXO7KMMWt0xZj0oRp RLhRjHOgbc9gOJtK8zY1UZid5wqHhkVDAXWaEccXaseKbNCjJFkICZfaEBVC7p6vrSyr KK19G5sawK7SibfKaRu2yamgL/vE20vkNLmQrQ0vULF1ACSBqruwOUrjmPNMJzGK4EO4 AO5Fx7jqOAhvk7Ff+1564FQtojt6rglM2qiUGR9BaDDFVg0bbzAfUsE/Ec3vKKVISjKZ AOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wkE3Xs1AbOWzxvW4yHgpnXnTeu1zoKoaFLNxtbk7zyI=; b=iWEVIVkrC0fGDhRE5wUmVPa9JH+JhFk9CEzToNVGh0J/KiFjXEWIg/R4Z39CeVvfWK MGpo1QZ7mPAKfwnjllVrx3TTavepfKjYhiNH4EQP/iAYkl7qph2ufxHQsk3XGIvaGDjE jfWLc+R71BYUOgWGDvjDtrUYohf1VF1RJDhExeoZbw+sy0PJ2iYElJXbQaK3hAXxK2a5 C5OHT7xaelTr3LUEKlv4ikGDBw2QDrHw12wQtT4AwS54UJFIxYHjEKDe+1GSD+3/x6Ig qlvpHUEdCp+J7WMpg54t/7fbeYV05bbFvUV8Hzf+NAyggIhvzOE+b8THMm1c3RVHOqvl a1Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="o/6KH25S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm25si189956edb.202.2021.05.31.09.21.13; Mon, 31 May 2021 09:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="o/6KH25S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234082AbhEaQVw (ORCPT + 99 others); Mon, 31 May 2021 12:21:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:37854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233313AbhEaOn2 (ORCPT ); Mon, 31 May 2021 10:43:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 10C606191B; Mon, 31 May 2021 13:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469255; bh=uMF7+gPy7twIoaTGLUFuRpN4SVRDwXmZORFPJj9IrSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/6KH25SO8tV4LVzQc0KhG9yE+b8J/nA0l1pqYAz42czh+TxXPNxPvY/H4BGWh1TT LkUHRP0RviBOzHKI3Za+mFHtnhmNRUSk4gBeNf0AyhAv+//Ikinwkh9pocOpMTQDMo zMWRkp48fQGEDOZbLkbWJW+QqLc5C1Xi8zTuJR1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Mark Bloch , Saeed Mahameed Subject: [PATCH 5.12 127/296] {net, RDMA}/mlx5: Fix override of log_max_qp by other device Date: Mon, 31 May 2021 15:13:02 +0200 Message-Id: <20210531130708.168948818@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maor Gottlieb commit 3410fbcd47dc6479af4309febf760ccaa5efb472 upstream. 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 Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx5/mr.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/main.c | 11 ++---- include/linux/mlx5/driver.h | 44 ++++++++++++------------- 3 files changed, 29 insertions(+), 30 deletions(-) --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -764,10 +764,10 @@ int mlx5_mr_cache_init(struct mlx5_ib_de 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); --- 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 mlx 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_co 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, @@ -1335,8 +1335,7 @@ int mlx5_mdev_init(struct mlx5_core_dev 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); --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -698,6 +698,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; @@ -726,7 +747,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; @@ -1073,18 +1094,6 @@ static inline u8 mlx5_mkey_variant(u32 m 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. @@ -1138,15 +1147,6 @@ int mlx5_rdma_rn_get_params(struct mlx5_ 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, };