From patchwork Wed Oct 19 08:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp216201wrs; Wed, 19 Oct 2022 02:17:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xQeBTIUOLqFQMpRAdO8lVRDyJRdPArtZu7n8g02/nnsqO/58ESO5UplOlpSWYcZaeRv7i X-Received: by 2002:a17:907:3e9c:b0:78d:ce8b:8548 with SMTP id hs28-20020a1709073e9c00b0078dce8b8548mr6011956ejc.427.1666171068461; Wed, 19 Oct 2022 02:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666171068; cv=none; d=google.com; s=arc-20160816; b=L/2dlJuLw6bgp7Jvmw14y6LYkMqNc8DCCpeHxeXnDOgLDx2QQR5hw8MQeBcUolVC5c ON2i6+qy2CrsagcG1D9uUpYISgl80VtPVAmn48kX8ReVNRLmJnMs92+hzFDhRiD9Ws6K xsCMzgjxVJ3e4V1p7EN5f7yhmh1c1hxGLYXDL10+FS3ehRlkOxyY53QxMg8lbZ3VnWPU oP4uMcCGNaPWUZZvb7BcNxS+f2SXuernEkcDm+GV2CXheBPNLSKAu5dXuDCcUth3qpBS haElU4Be6fp4bRi7gYMiI3iSioHQVuD1kOrgSuuzAbiEx39kS3qhynkO10cBpvXGZmnt 1Y4g== 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=140KZRh9LACpHILqQQ4t5cICFNwZBFF4XqeBjeTeCTE=; b=FHCQHQI1hsXms2E6mAPb9d6C5tMFfLDJChTPP24vX+3OiRePks3OUjyqF+RXTcYnA/ +oIg+44n5UplKBar129qJ0g317E0S9K+LOr7NT21/jOUUS8OUmHsse5TUScAC9E3ThFL TtgoYwVzA9fLjFGI5RgZOKMf4XwywDSW0pPjCOIOaFXq3K8+P4ebh5q10CuatztLokDI 9kSUjHxgUrr2qzYQ3lSQSv+WmQlwKfcsduGmq6Xl3WDDvKYO8HP2GSsxfLorWYZjB//5 HIY1QuSnrKB9YnL2RbxNNM2/qGqYj1cMsZfGOxFFl266iTslpEXDpUFdifay6kGPqPa/ mMQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MZsX8dO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a170906a10600b00782e9b7305dsi11383070ejy.266.2022.10.19.02.17.23; Wed, 19 Oct 2022 02:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MZsX8dO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233166AbiJSJQU (ORCPT + 99 others); Wed, 19 Oct 2022 05:16:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232830AbiJSJNc (ORCPT ); Wed, 19 Oct 2022 05:13:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC80C90F0; Wed, 19 Oct 2022 02:03:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5934461825; Wed, 19 Oct 2022 09:02:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68E9EC433C1; Wed, 19 Oct 2022 09:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170169; bh=W/qDAiByOmW1Y7CEAQjz9gU5fPmSyXrCb/xo6AYIas8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MZsX8dO5AlCV60L6+yi9NXCrKorQ0FY7nuiMGCWVLTgm3jlBS1t3ulV9IMK6Sh+FE tKR4iWY9vFt9FHRbe01nWddw2pd8vGcHmYwxCVof/InQk0K/jjUYKlKOR4dxc/NVPJ NkNZ0yyDBsgO2CBCtnMbk44YkGjXntLx6H9tKgB0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daisuke Matsuda , Leon Romanovsky , Sasha Levin Subject: [PATCH 6.0 552/862] IB: Set IOVA/LENGTH on IB_MR in core/uverbs layers Date: Wed, 19 Oct 2022 10:30:39 +0200 Message-Id: <20221019083314.369588800@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106994695046939?= X-GMAIL-MSGID: =?utf-8?q?1747106994695046939?= From: Daisuke Matsuda [ Upstream commit 241f9a27e0fc0eaf23e3d52c8450f10648cd11f1 ] Set 'iova' and 'length' on ib_mr in ib_uverbs and ib_core layers to let all drivers have the members filled. Also, this commit removes redundancy in the respective drivers. Previously, commit 04c0a5fcfcf65 ("IB/uverbs: Set IOVA on IB MR in uverbs layer") changed to set 'iova', but seems to have missed 'length' and the ib_core layer at that time. Fixes: 04c0a5fcfcf65 ("IB/uverbs: Set IOVA on IB MR in uverbs layer") Signed-off-by: Daisuke Matsuda Link: https://lore.kernel.org/r/20220921080844.1616883-1-matsuda-daisuke@fujitsu.com Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/core/uverbs_cmd.c | 5 ++++- drivers/infiniband/core/verbs.c | 2 ++ drivers/infiniband/hw/hns/hns_roce_mr.c | 1 - drivers/infiniband/hw/mlx4/mr.c | 1 - 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 046376bd68e2..4796f6a8828c 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -739,6 +739,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) mr->uobject = uobj; atomic_inc(&pd->usecnt); mr->iova = cmd.hca_va; + mr->length = cmd.length; rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR); rdma_restrack_set_name(&mr->res, NULL); @@ -861,8 +862,10 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) mr->pd = new_pd; atomic_inc(&new_pd->usecnt); } - if (cmd.flags & IB_MR_REREG_TRANS) + if (cmd.flags & IB_MR_REREG_TRANS) { mr->iova = cmd.hca_va; + mr->length = cmd.length; + } } memset(&resp, 0, sizeof(resp)); diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index e54b3f1b730e..f8964c8cf0ad 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -2149,6 +2149,8 @@ struct ib_mr *ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, mr->pd = pd; mr->dm = NULL; atomic_inc(&pd->usecnt); + mr->iova = virt_addr; + mr->length = length; rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR); rdma_restrack_parent_name(&mr->res, &pd->res); diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 867972c2a894..dedfa56f5773 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -249,7 +249,6 @@ struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, goto err_alloc_pbl; mr->ibmr.rkey = mr->ibmr.lkey = mr->key; - mr->ibmr.length = length; return &mr->ibmr; diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c index 04a67b481608..a40bf58bcdd3 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c @@ -439,7 +439,6 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, goto err_mr; mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; - mr->ibmr.length = length; mr->ibmr.page_size = 1U << shift; return &mr->ibmr;