Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2901275pxv; Sun, 18 Jul 2021 05:02:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyka4lwO4VqJ8gwch1GhZGjSPYrPpj4blwce/qVWgcN5ydXDQgimku8OT2RJtn9G6DfWgJT X-Received: by 2002:a5d:8c9a:: with SMTP id g26mr14859102ion.121.1626609770035; Sun, 18 Jul 2021 05:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626609770; cv=none; d=google.com; s=arc-20160816; b=W6Xe5qE76FNkPnGwoNt78mSYmdu+keQF/vj3M7WT9MncVTLLg1YHs5BLcQAv/3UXQC WQF6irLJEsjVIhB9ygkqEM8PguSAtEJpe8WztLWMh7cwwYkPvqCUq72Sdsk0sJP8fQE/ ToK+XbjYpK7NvLH5fyBh8DCTfnlyff4iSVbMF5HVaptFAylrGXd4THh1vvZYbWd5NtJ6 r9sH2tPDZ92X7oRLnn40qa6b2GCl64Nk8nZ9mj+bXIK4BjcqFU/GnyYG2nZeNiGoITOH IFwJoHg/4pzfee+hDz8MGOaTtg80fkNV3hf0GOLCvZXABCpE0CBwpgEgyHikqW/9BADN 5c3g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+YD+RQywZUKfoh9qEUezW4Htc5v3KCzsYmgBbnkUzM4=; b=MMbVkB69SiYtbZwRSQr4S77rlV3Jd2jqrMdLQpqvP+dgeyA4mo3oj6bfDLR4dyKeNv T1jp7Xz40GNO5cQ9jQTqh43G7Vl+G9gETLOpDormq7GfXhrxUmvSCOOeeNYITZJogT/2 IsVyDcduFSpENmtojR5CRV2ulwAhopXw7rhnVWFLznHyCZqVui8W1V8n3p3qrQvlptoB fZD8DWX7VxihpHZDoHEWk881ZwYdD68PIx70OEmOnTM4OVbXM5/wK/tCz5jjW1Eji5/3 CR2NcKKRi5cmpv+pFbxNdzJS5Pn7iJF7f3wKYIBIfMu7kFI/4/GBeALXuZNQmSOTEtIk 3ueg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GVxrMkCQ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si16110096jaf.84.2021.07.18.05.02.38; Sun, 18 Jul 2021 05:02:50 -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=@kernel.org header.s=k20201202 header.b=GVxrMkCQ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233577AbhGRMEU (ORCPT + 99 others); Sun, 18 Jul 2021 08:04:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:43912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233225AbhGRMEQ (ORCPT ); Sun, 18 Jul 2021 08:04:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 238846108B; Sun, 18 Jul 2021 12:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626609677; bh=uzq54RD5rZlPgk1E6YmXI5XtGyehCEp6l22OvYxcfvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVxrMkCQYE+pAomwkbx63lnQMvryKVV5dnEGWkl81UYrEgqmqF//S9YKv5qwjgCAw WLh6PNMpBOI9qMBq/QpxCLnjzZNdJE0H5h8xpL0MyY+x74P9i6ngquMcKKqE/yRntk YNifI/qGlAYzw1ROZilcnAXkjXQGqA0AzEB7WeJReqe2qTEoEQbPX0ydTWNvtLfQXv OIf4GTCkp3sMLliXTt64JxqUvEE/gcCsCRw6JB2E+TesqxqKF7dczpCMFCf/THjoAD AHcnkMEI/0njNW6ufeEIvl6z4TjG8lJcdxBegyUJQUl7VWEwP2f3oT2K4wDgKtrrYE ziOThhJRMsloQ== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Leon Romanovsky , Adit Ranadive , Ariel Elior , Bernard Metzler , Christian Benvenuti , Dennis Dalessandro , Gal Pressman , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Michal Kalderon , Mike Marciniszyn , Mustafa Ismail , Naresh Kumar PBS , Nelson Escobar , Potnuri Bharat Teja , Selvin Xavier , Shiraz Saleem , Steve Wise , VMware PV-Drivers , Weihang Li , Wenpeng Liang , Yishai Hadas , Zhu Yanjun Subject: [PATCH rdma-next 5/9] RDMA/mlx5: Delete device resource mutex that didn't protect anything Date: Sun, 18 Jul 2021 15:00:55 +0300 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky The dev->devr.mutex was intended to protect GSI QP pointer change in the struct mlx5_ib_port_resources when it is accessed from the pkey_change_work. However that pointer isn't changed during the runtime and once IB/core adds MAD, it stays stable. Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/gsi.c | 34 ++++++++-------------------- drivers/infiniband/hw/mlx5/main.c | 9 ++++++-- drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 -- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/gsi.c b/drivers/infiniband/hw/mlx5/gsi.c index 7fcad9135276..e549d6fa4a41 100644 --- a/drivers/infiniband/hw/mlx5/gsi.c +++ b/drivers/infiniband/hw/mlx5/gsi.c @@ -116,8 +116,6 @@ int mlx5_ib_create_gsi(struct ib_pd *pd, struct mlx5_ib_qp *mqp, goto err_free_tx; } - mutex_lock(&dev->devr.mutex); - if (dev->devr.ports[port_num - 1].gsi) { mlx5_ib_warn(dev, "GSI QP already exists on port %d\n", port_num); @@ -167,15 +165,11 @@ int mlx5_ib_create_gsi(struct ib_pd *pd, struct mlx5_ib_qp *mqp, INIT_LIST_HEAD(&gsi->rx_qp->sig_mrs); dev->devr.ports[attr->port_num - 1].gsi = gsi; - - mutex_unlock(&dev->devr.mutex); - return 0; err_destroy_cq: ib_free_cq(gsi->cq); err_free_wrs: - mutex_unlock(&dev->devr.mutex); kfree(gsi->outstanding_wrs); err_free_tx: kfree(gsi->tx_qps); @@ -190,16 +184,13 @@ int mlx5_ib_destroy_gsi(struct mlx5_ib_qp *mqp) int qp_index; int ret; - mutex_lock(&dev->devr.mutex); ret = mlx5_ib_destroy_qp(gsi->rx_qp, NULL); if (ret) { mlx5_ib_warn(dev, "unable to destroy hardware GSI QP. error %d\n", ret); - mutex_unlock(&dev->devr.mutex); return ret; } dev->devr.ports[port_num - 1].gsi = NULL; - mutex_unlock(&dev->devr.mutex); gsi->rx_qp = NULL; for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) { @@ -339,23 +330,13 @@ static void setup_qp(struct mlx5_ib_gsi_qp *gsi, u16 qp_index) WARN_ON_ONCE(qp); } -static void setup_qps(struct mlx5_ib_gsi_qp *gsi) -{ - struct mlx5_ib_dev *dev = to_mdev(gsi->rx_qp->device); - u16 qp_index; - - mutex_lock(&dev->devr.mutex); - for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) - setup_qp(gsi, qp_index); - mutex_unlock(&dev->devr.mutex); -} - int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr, int attr_mask) { struct mlx5_ib_dev *dev = to_mdev(qp->device); struct mlx5_ib_qp *mqp = to_mqp(qp); struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; + u16 qp_index; int ret; mlx5_ib_dbg(dev, "modifying GSI QP to state %d\n", attr->qp_state); @@ -366,8 +347,11 @@ int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr, return ret; } - if (to_mqp(gsi->rx_qp)->state == IB_QPS_RTS) - setup_qps(gsi); + if (to_mqp(gsi->rx_qp)->state != IB_QPS_RTS) + return 0; + + for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) + setup_qp(gsi, qp_index); return 0; } @@ -511,8 +495,8 @@ int mlx5_ib_gsi_post_recv(struct ib_qp *qp, const struct ib_recv_wr *wr, void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi) { - if (!gsi) - return; + u16 qp_index; - setup_qps(gsi); + for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) + setup_qp(gsi, qp_index); } diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 75d5de14f80b..cac05bbe14c2 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -2501,6 +2501,13 @@ static void pkey_change_handler(struct work_struct *work) container_of(work, struct mlx5_ib_port_resources, pkey_change_work); + if (!ports->gsi) + /* + * We got this event before device was fully configured + * and MAD registration code wasn't called/finished yet. + */ + return; + mlx5_ib_gsi_pkey_change(ports->gsi); } @@ -2795,8 +2802,6 @@ static int mlx5_ib_dev_res_init(struct mlx5_ib_dev *dev) if (!MLX5_CAP_GEN(dev->mdev, xrc)) return -EOPNOTSUPP; - mutex_init(&devr->mutex); - devr->p0 = rdma_zalloc_drv_obj(ibdev, ib_pd); if (!devr->p0) return -ENOMEM; diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index dbbcb53d2ca2..f2c8a6375b16 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -813,8 +813,6 @@ struct mlx5_ib_resources { struct ib_srq *s0; struct ib_srq *s1; struct mlx5_ib_port_resources ports[2]; - /* Protects changes to the port resources */ - struct mutex mutex; }; struct mlx5_ib_counters { -- 2.31.1