From patchwork Sat Oct 22 07:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1100549wrr; Sat, 22 Oct 2022 01:17:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zLk+rFCpZLWg2knEKTFGCo7sEEJyJ/TbM/gKhjZ+R+3QjGJVEMd1v947JsdgObMsi1qcD X-Received: by 2002:a17:902:8c81:b0:178:1701:cd with SMTP id t1-20020a1709028c8100b00178170100cdmr23788805plo.138.1666426656602; Sat, 22 Oct 2022 01:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426656; cv=none; d=google.com; s=arc-20160816; b=Ihf7MiaKrMCwmlwWNQSYrZLJq0l60+wSdXnE6tpppyUZBHd8oWNJxOMiZBQOvSqJlb bUXCW/1rW6PiaCISw5dGEDT+CY6tclVSAl/XbV0qauLCjX1Wmu/7A7unKdNGQYWHXXn6 WHeU89MjGoH5ID4/OvH1KHIv/Vfk2S4nl7g3seB72kz+rh0TqGjzFd2TRda0QCyR8MjZ aIXSD+paqBSPCqZnlBNhsrN1wnM9/IYmzFdRPTOR6KP7mPNFZ1kLnYJWpj5fYvtx6b5R xjbH+JYqGnYFnMya2098pNtS9imHXoMtS4jTzjIpuj+fJ6RG1L1aBWgeb/XmRaPxPXAK Zqbw== 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=ceNx+7hbdoFzUZsJAvZg0uBkWElofMkGD9IHgYrAti7lvTIct8HpxVdX9c1TPxAyQI DudN5I4qdHXmN/seUnzE3GOaPHBo4abKGuCKAtxQ+7OM4mhdy6UH+4YPWRiq81RGllGq 3ndG4oFR4+tvbqwwK0CVxVMLyGd3Fkt6kxyDjjUscMYXjqoqSI4Mgf4tDb4DmYOmB7WP 2nuNPi0CervQv9G9PCs33WfSfp0em/An9jmoPgrH9VIAg//Xaqznkczu+ghm+6lvdUXk KBml9MDwWVIhGvu/lcAYwUY0wMFdeKl2I2JrPCKv43mgNh5r0OxjW/aAwpsfGQko7qjp 8bbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kRj5ZjjK; 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 b22-20020a63d316000000b004636ce58db2si27728865pgg.776.2022.10.22.01.17.22; Sat, 22 Oct 2022 01:17:36 -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=kRj5ZjjK; 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 S233343AbiJVIM0 (ORCPT + 99 others); Sat, 22 Oct 2022 04:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232833AbiJVIKK (ORCPT ); Sat, 22 Oct 2022 04:10:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D771834C; Sat, 22 Oct 2022 00:54:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id E17CEB82E0B; Sat, 22 Oct 2022 07:54:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5956AC433D6; Sat, 22 Oct 2022 07:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425261; bh=W/qDAiByOmW1Y7CEAQjz9gU5fPmSyXrCb/xo6AYIas8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRj5ZjjKrKElQ0Iryj0dz8aGZRzoKS7ajvembMVZJcbxIaSUVIqHS1POxc/L6JEdf 8Ztw4k5hhiz23powDVufy1O1VlS48PAIhql7rfLSEO8HpRS/1hxby8MbO422s6byPr AeIkCn40dZyN4Quc9n4imso4fOXV0DSEEoHHMEXo= 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 5.19 443/717] IB: Set IOVA/LENGTH on IB_MR in core/uverbs layers Date: Sat, 22 Oct 2022 09:25:22 +0200 Message-Id: <20221022072517.901595870@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747374997720265973?= X-GMAIL-MSGID: =?utf-8?q?1747374997720265973?= 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;