From patchwork Fri Nov 11 04:30:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13039656 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FE5CC433FE for ; Fri, 11 Nov 2022 04:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232287AbiKKEa7 (ORCPT ); Thu, 10 Nov 2022 23:30:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiKKEaz (ORCPT ); Thu, 10 Nov 2022 23:30:55 -0500 Received: from mail1.bemta37.messagelabs.com (mail1.bemta37.messagelabs.com [85.158.142.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6530442F68; Thu, 10 Nov 2022 20:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1668141050; i=@fujitsu.com; bh=fjsTTPP+5pcUTVlho3XxaWSxwAHN8a8nnOjRBSnAiBM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gVmFTUKy24yRO3ZNKouAZibyZxVDhdtkqL6D35FwlMFii/Qs06kTOwAEK7mNxJYRM pD2vhvfE7DIcxULPBpl4h46r5F9nUV76WucSTtBwbdnhzvPvjRSTgzl5O4daFwmxsW GD5JR1zVqO83HEq710tHHfjpMkfOcG9o+jOofoNp1wAcEnZijXYUuDeSgkuSogzBPi fXPSE65L3iV0wzQYsUornXqElaf9eEa4AxTev1AOloXPfmLlyGgTB1dc9Stx1fcW+P p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Wc7/nU0vr5tJbapRB/L6aT/LZ3p3gXtq43 eXPm+RPx+RG3y5c3l5s7lU9PO/nhcbfngo/sCSEN3FUP8/oNDeyVWIozEg21mIuKEwG4nn/je AMAAA== X-Env-Sender: lizhijian@fujitsu.com X-Msg-Ref: server-17.tower-728.messagelabs.com!1668141049!608144!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30575 invoked from network); 11 Nov 2022 04:30:49 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-17.tower-728.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Nov 2022 04:30:49 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id 6D3681AE; Fri, 11 Nov 2022 04:30:49 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id 623541AD; Fri, 11 Nov 2022 04:30:49 +0000 (GMT) Received: from bc0da1a9c27e.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 11 Nov 2022 04:30:46 +0000 From: Li Zhijian To: Zhu Yanjun , Jason Gunthorpe , "Leon Romanovsky" , CC: , Li Zhijian Subject: [for-next PATCH 1/5] RDMA/rxe: Remove rxe_phys_buf.size Date: Fri, 11 Nov 2022 04:30:26 +0000 Message-ID: <1668141030-2-2-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> References: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Every rxe_phys_buf used by either IB_MR_TYPE_MEM_REG or IB_MR_TYPE_USER has the same size, which should be same with ibmr->page_size. So we can use ibmr->page_size correspondingly. Signed-off-by: Li Zhijian --- drivers/infiniband/sw/rxe/rxe_mr.c | 11 ++++------- drivers/infiniband/sw/rxe/rxe_verbs.c | 1 - drivers/infiniband/sw/rxe/rxe_verbs.h | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index d4f10c2d1aa7..f6366a635b92 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -145,6 +145,7 @@ int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, mr->page_shift = PAGE_SHIFT; mr->page_mask = PAGE_SIZE - 1; + mr->ibmr.page_size = PAGE_SIZE; num_buf = 0; map = mr->map; @@ -167,7 +168,6 @@ int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, } buf->addr = (uintptr_t)vaddr; - buf->size = PAGE_SIZE; num_buf++; buf++; @@ -219,7 +219,7 @@ static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out, size_t offset = iova - mr->ibmr.iova + mr->offset; int map_index; int buf_index; - u64 length; + u64 length = mr->ibmr.page_size; if (likely(mr->page_shift)) { *offset_out = offset & mr->page_mask; @@ -230,8 +230,6 @@ static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out, map_index = 0; buf_index = 0; - length = mr->map[map_index]->buf[buf_index].size; - while (offset >= length) { offset -= length; buf_index++; @@ -240,7 +238,6 @@ static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out, map_index++; buf_index = 0; } - length = mr->map[map_index]->buf[buf_index].size; } *m_out = map_index; @@ -274,7 +271,7 @@ void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) lookup_iova(mr, iova, &m, &n, &offset); - if (offset + length > mr->map[m]->buf[n].size) { + if (offset + length > mr->ibmr.page_size) { pr_warn("crosses page boundary\n"); addr = NULL; goto out; @@ -336,7 +333,7 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, src = (dir == RXE_TO_MR_OBJ) ? addr : va; dest = (dir == RXE_TO_MR_OBJ) ? va : addr; - bytes = buf->size - offset; + bytes = mr->ibmr.page_size - offset; if (bytes > length) bytes = length; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 88825edc7dce..5da394c675bf 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -991,7 +991,6 @@ static int rxe_set_page(struct ib_mr *ibmr, u64 addr) buf = &map->buf[mr->nbuf % RXE_BUF_PER_MAP]; buf->addr = addr; - buf->size = ibmr->page_size; mr->nbuf++; return 0; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index 22a299b0a9f0..acab785ba7e2 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -281,7 +281,6 @@ enum rxe_mr_lookup_type { struct rxe_phys_buf { u64 addr; - u64 size; }; struct rxe_map { From patchwork Fri Nov 11 04:30:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13039657 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD4FDC4332F for ; Fri, 11 Nov 2022 04:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232183AbiKKEbA (ORCPT ); Thu, 10 Nov 2022 23:31:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232343AbiKKEa7 (ORCPT ); Thu, 10 Nov 2022 23:30:59 -0500 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC82F68AE6; Thu, 10 Nov 2022 20:30:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1668141053; i=@fujitsu.com; bh=t3W7ccYeAWOB7TN9rQwLcUW5c4OzST5kRuF91e5+TEI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=w+eLUlGxhp3aQOon3jqrxU1B0Pvb0BSHUPchD8TxSSUUF0t6GUk6cyBM47nhJkanb SFoBFZIA8AZrwRWNUtzLBZygLjyzTkiN32FpF84hzFUXZd/uB9IFbPJ7Yg3N0AiIhN +ul9fkq7sBLYigtcBT3FZbK5BxI7VFBcQ2CIxPBFZ8KNsmA9umBOab6jg1bUqZaz8J ALf8R4vGeUAjL4AzoC+q2baJ6nDkWqoNu9CNCh6i8RWw5MqoeWCnEptrCC2XVxz/C1 HhA6bqXFF57/z66htCiJ/FFeb0ED5vhVG4Xc5/Yjf5xitZ9l0EaJlM6KmGvP5TD1CN wVZqSPxcX0kWQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRWlGSWpSXmKPEx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g-Ref: server-20.tower-548.messagelabs.com!1668141052!16817!1 X-Originating-IP: [62.60.8.146] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9145 invoked from network); 11 Nov 2022 04:30:52 -0000 Received: from unknown (HELO n03ukasimr02.n03.fujitsu.local) (62.60.8.146) by server-20.tower-548.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Nov 2022 04:30:52 -0000 Received: from n03ukasimr02.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTP id 56B2C1000D5; Fri, 11 Nov 2022 04:30:52 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTPS id 49A7A1000C1; Fri, 11 Nov 2022 04:30:52 +0000 (GMT) Received: from bc0da1a9c27e.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 11 Nov 2022 04:30:49 +0000 From: Li Zhijian To: Zhu Yanjun , Jason Gunthorpe , "Leon Romanovsky" , CC: , Li Zhijian Subject: [for-next PATCH 2/5] RDMA/rxe: use iova_to_vaddr to transform iova for rxe_mr_copy Date: Fri, 11 Nov 2022 04:30:27 +0000 Message-ID: <1668141030-2-3-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> References: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Make the code more friendly and readable by using iova_to_vaddr() This commit also remove the err1 label in rxe_mr_copy(). Signed-off-by: Li Zhijian --- drivers/infiniband/sw/rxe/rxe_mr.c | 46 +++++++++--------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index f6366a635b92..cf3ce8d293b3 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -289,13 +289,6 @@ void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, enum rxe_mr_copy_dir dir) { - int err; - int bytes; - u8 *va; - struct rxe_map **map; - struct rxe_phys_buf *buf; - int m; - int i; size_t offset; if (length == 0) @@ -315,49 +308,36 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, WARN_ON_ONCE(!mr->map); - err = mr_check_range(mr, iova, length); - if (err) { - err = -EFAULT; - goto err1; - } - - lookup_iova(mr, iova, &m, &i, &offset); - - map = mr->map + m; - buf = map[0]->buf + i; + if (mr_check_range(mr, iova, length)) + return -EFAULT; + offset = (iova - mr->ibmr.iova + mr->offset) & mr->page_mask; while (length > 0) { - u8 *src, *dest; - - va = (u8 *)(uintptr_t)buf->addr + offset; - src = (dir == RXE_TO_MR_OBJ) ? addr : va; - dest = (dir == RXE_TO_MR_OBJ) ? va : addr; + u8 *src, *dest, *va; + int bytes; bytes = mr->ibmr.page_size - offset; if (bytes > length) bytes = length; + va = iova_to_vaddr(mr, iova, bytes); + if (!va) + return -EFAULT; + + src = (dir == RXE_TO_MR_OBJ) ? addr : va; + dest = (dir == RXE_TO_MR_OBJ) ? va : addr; + memcpy(dest, src, bytes); length -= bytes; addr += bytes; + iova += bytes; offset = 0; - buf++; - i++; - - if (i == RXE_BUF_PER_MAP) { - i = 0; - map++; - buf = map[0]->buf; - } } return 0; - -err1: - return err; } /* copy data in or out of a wqe, i.e. sg list From patchwork Fri Nov 11 04:30:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13039658 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9DEEC4332F for ; Fri, 11 Nov 2022 04:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbiKKEbD (ORCPT ); Thu, 10 Nov 2022 23:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232511AbiKKEbA (ORCPT ); Thu, 10 Nov 2022 23:31:00 -0500 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339FB68AD9; Thu, 10 Nov 2022 20:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1668141056; i=@fujitsu.com; bh=YDhoYW+eXCKjvdTLBizlFrYt3TOUamkuYfdivtZaMMk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hVgtHvu6W1bvlIX3kfc2RL3uBP9LP032+foxXnX+egnZEj99xx+ylI7Dh5btleSmC 6wCjdm4bLdzk5bH5wcEAOecZNVXE1Tlh0Lt9B3942wrP0LPBhBjrUCgAeuBfEYgSpr 6e6FQa796VAW3anwijJyMc4lFmxvJsCKPG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czFqZk8zXYoubjPbW55kveCL4+Izk/OrLmtbpUqtSepKTtM0cPn BEFV4eIaDY3NgH8esI2ff9y/Vlt6eIPpDiutZu7S54uHeTEWRJXs0AufybbxccHPBtdDjnuHc HBoPt3CaNQn+cJtkULwkNXJjK3ux9NZofle1eSv/umREvq0/8dlZ/PNTJZbijERDLeai4kQAy sR8P3kDAAA= X-Env-Sender: lizhijian@fujitsu.com X-Msg-Ref: server-17.tower-571.messagelabs.com!1668141055!691429!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19201 invoked from network); 11 Nov 2022 04:30:55 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-17.tower-571.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Nov 2022 04:30:55 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 4711D1001A1; Fri, 11 Nov 2022 04:30:55 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTPS id 3A8BD10019F; Fri, 11 Nov 2022 04:30:55 +0000 (GMT) Received: from bc0da1a9c27e.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 11 Nov 2022 04:30:52 +0000 From: Li Zhijian To: Zhu Yanjun , Jason Gunthorpe , "Leon Romanovsky" , CC: , Li Zhijian Subject: [for-next PATCH 3/5] RDMA/rxe: iova_to_vaddr cleanup Date: Fri, 11 Nov 2022 04:30:28 +0000 Message-ID: <1668141030-2-4-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> References: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org No functional change, do cleanup for refactoring it easily later. Signed-off-by: Li Zhijian --- drivers/infiniband/sw/rxe/rxe_mr.c | 37 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index cf3ce8d293b3..a4e786b657b7 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -246,41 +246,38 @@ static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out, } } -void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) +static void *__iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) { size_t offset; int m, n; - void *addr; + lookup_iova(mr, iova, &m, &n, &offset); + + if (offset + length > mr->ibmr.page_size) { + pr_warn("crosses page boundary\n"); + return NULL; + } + + return (void *)(uintptr_t)mr->map[m]->buf[n].addr + offset; +} + +void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) +{ if (mr->state != RXE_MR_STATE_VALID) { pr_warn("mr not in valid state\n"); - addr = NULL; - goto out; + return NULL; } if (!mr->map) { - addr = (void *)(uintptr_t)iova; - goto out; + return (void *)(uintptr_t)iova; } if (mr_check_range(mr, iova, length)) { pr_warn("range violation\n"); - addr = NULL; - goto out; - } - - lookup_iova(mr, iova, &m, &n, &offset); - - if (offset + length > mr->ibmr.page_size) { - pr_warn("crosses page boundary\n"); - addr = NULL; - goto out; + return NULL; } - addr = (void *)(uintptr_t)mr->map[m]->buf[n].addr + offset; - -out: - return addr; + return __iova_to_vaddr(mr, iova, length); } /* copy data from a range (vaddr, vaddr+length-1) to or from From patchwork Fri Nov 11 04:30:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13039659 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1447C4332F for ; Fri, 11 Nov 2022 04:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232499AbiKKEbQ (ORCPT ); Thu, 10 Nov 2022 23:31:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232117AbiKKEbC (ORCPT ); Thu, 10 Nov 2022 23:31:02 -0500 Received: from mail1.bemta37.messagelabs.com (mail1.bemta37.messagelabs.com [85.158.142.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93FAE69DD2; Thu, 10 Nov 2022 20:31:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1668141059; i=@fujitsu.com; bh=6BOQYMvWVSi2uBbZfL1Bzz07XDsCbIwy+Optf2MNYVA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wl7LeVr8srVymoGxdKgmQAMbHmM6+bwnmfzzLVYbzLZOCNZ7eMkzmAcCUP17WBfK6 2bAF/IG9DkwxOCM2lA2u8J5PiHCSB8QvaoP6QhDwyruzjpIogmV+erJ+U5MhMzKKHc I2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1LjuXE09uSU22 cMxD4EBPqfFZU4x3dKo1Qwebna95aqA1fc87m1xT4Y3ldtWexab81YFHfE5L/reaWdoQbvZ3h FhZkv3JnC9WlOenTYv+Ts0KsL6mz3SxTbuSUzdk1bZh4Vocj4UYN13q/c9Q8m2Tv2zG1YmHUv 8uBDcdHa3Uzlp+cr9W+ZYZb2/sbx9r5FEjzTl4d/YUpYZxKnxFKckWioxVxUnAgAXtqlj3gDA AA= X-Env-Sender: lizhijian@fujitsu.com X-Msg-Ref: server-15.tower-728.messagelabs.com!1668141058!608057!1 X-Originating-IP: [62.60.8.179] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14018 invoked from network); 11 Nov 2022 04:30:58 -0000 Received: from unknown (HELO n03ukasimr04.n03.fujitsu.local) (62.60.8.179) by server-15.tower-728.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Nov 2022 04:30:58 -0000 Received: from n03ukasimr04.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTP id 41D42156; Fri, 11 Nov 2022 04:30:58 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTPS id 34D92153; Fri, 11 Nov 2022 04:30:58 +0000 (GMT) Received: from bc0da1a9c27e.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 11 Nov 2022 04:30:55 +0000 From: Li Zhijian To: Zhu Yanjun , Jason Gunthorpe , "Leon Romanovsky" , CC: , Li Zhijian Subject: [for-next PATCH 4/5] RDMA/rxe: refactor iova_to_vaddr Date: Fri, 11 Nov 2022 04:30:29 +0000 Message-ID: <1668141030-2-5-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> References: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org For IB_MR_TYPE_USER MR, iova_to_vaddr() will call kmap_local_page() to map page. Signed-off-by: Li Zhijian --- drivers/infiniband/sw/rxe/rxe_loc.h | 1 + drivers/infiniband/sw/rxe/rxe_mr.c | 38 +++++++++++++++------------ drivers/infiniband/sw/rxe/rxe_resp.c | 1 + drivers/infiniband/sw/rxe/rxe_verbs.h | 5 +++- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index c2a5c8814a48..22a8c44d39c8 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -73,6 +73,7 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma, void *addr, int length, enum rxe_mr_copy_dir dir); void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length); +void rxe_unmap_vaddr(struct rxe_mr *mr, void *vaddr); struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, enum rxe_mr_lookup_type type); int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index a4e786b657b7..d26a4a33119c 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -120,9 +120,7 @@ int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, struct ib_umem *umem; struct sg_page_iter sg_iter; int num_buf; - void *vaddr; int err; - int i; umem = ib_umem_get(&rxe->ib_dev, start, length, access); if (IS_ERR(umem)) { @@ -159,18 +157,9 @@ int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, num_buf = 0; } - vaddr = page_address(sg_page_iter_page(&sg_iter)); - if (!vaddr) { - pr_warn("%s: Unable to get virtual address\n", - __func__); - err = -ENOMEM; - goto err_cleanup_map; - } - - buf->addr = (uintptr_t)vaddr; + buf->page = sg_page_iter_page(&sg_iter); num_buf++; buf++; - } } @@ -182,10 +171,6 @@ int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova, return 0; -err_cleanup_map: - for (i = 0; i < mr->num_map; i++) - kfree(mr->map[i]); - kfree(mr->map); err_release_umem: ib_umem_release(umem); err_out: @@ -246,6 +231,12 @@ static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out, } } +void rxe_unmap_vaddr(struct rxe_mr *mr, void *vaddr) +{ + if (mr->ibmr.type == IB_MR_TYPE_USER) + kunmap_local(vaddr); +} + static void *__iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) { size_t offset; @@ -258,9 +249,21 @@ static void *__iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) return NULL; } - return (void *)(uintptr_t)mr->map[m]->buf[n].addr + offset; + if (mr->ibmr.type == IB_MR_TYPE_USER) { + char *paddr; + struct page *pg = mr->map[m]->buf[n].page; + + paddr = kmap_local_page(pg); + if (paddr == NULL) { + pr_warn("Failed to map page"); + return NULL; + } + return paddr + offset; + } else + return (void *)(uintptr_t)mr->map[m]->buf[n].addr + offset; } +/* must call rxe_unmap_vaddr to unmap vaddr */ void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) { if (mr->state != RXE_MR_STATE_VALID) { @@ -326,6 +329,7 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, dest = (dir == RXE_TO_MR_OBJ) ? va : addr; memcpy(dest, src, bytes); + rxe_unmap_vaddr(mr, va); length -= bytes; addr += bytes; diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 483043dc4e89..765cb9f8538a 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -636,6 +636,7 @@ static enum resp_states atomic_reply(struct rxe_qp *qp, *vaddr = value; spin_unlock_bh(&atomic_ops_lock); + rxe_unmap_vaddr(mr, vaddr); qp->resp.msn++; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h index acab785ba7e2..6080a4b32f09 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.h +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h @@ -280,7 +280,10 @@ enum rxe_mr_lookup_type { #define RXE_BUF_PER_MAP (PAGE_SIZE / sizeof(struct rxe_phys_buf)) struct rxe_phys_buf { - u64 addr; + union { + u64 addr; /* IB_MR_TYPE_MEM_REG */ + struct page *page; /* IB_MR_TYPE_USER */ + }; }; struct rxe_map { From patchwork Fri Nov 11 04:32:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13039668 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3051EC433FE for ; Fri, 11 Nov 2022 04:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbiKKEcv (ORCPT ); Thu, 10 Nov 2022 23:32:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiKKEcu (ORCPT ); Thu, 10 Nov 2022 23:32:50 -0500 Received: from mail3.bemta32.messagelabs.com (mail3.bemta32.messagelabs.com [195.245.230.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4254A68AEB; Thu, 10 Nov 2022 20:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1668141166; i=@fujitsu.com; bh=bqzxuxOj1uBZFGGeCXRO50kMdRTB6u9u4Z9D5YPVTeo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pKAmvP12BU+OFaZO4k/MPVM6nSXuLTaqQXcRgwJTYXRTBDSr4kpETIH/cCZsBL1zz hcfxtJ0wROMv89Neo3rYJUsExY16UDn/f+pCCYv8B5MHQ/amjVZCmWdSvdHMcQ6ris hRvbgcMEo+83hPuMvSHTLFNlAouDtXFR7xRNe4xEDbtwEecQMaFH+E3nvJMUKgI/jP G2G50sRs6Tcfw2h6YqgJI85ftvG48CL3yhgXoTjSfZUGAl2WLmFYLkVFkdmod7C221 JtdrJFVXFqu52E47CCgW80uLpmCGQGqHKu3uIuBAfp2W84XJcPmAFC1NbanGK0b7gI jR1u4AKX1Z8tw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRWlGSWpSXmKPExsViZ8ORpJt7ITf ZYNtufYuZM04wWkz5tZTZ4vKuOWwWzw71slicP9bP7sDqsXPWXXaPTas62Tw+b5Lz2Pr5NksA SxRrZl5SfkUCa0b/3x62gqtCFZ+mnmVrYPzC38XIxSEksJFR4t7/54wQzmImiSNPbzFBOAcYJ ZYsfsjSxcjJwSagIXGv5SYjiC0i0Mkosa01DcRmFnCT2PRmNnsXIweHsICPRNereJAwi4CqxJ rbG5lBbF4BR4mnT66xgdgSAgoSUx6+B4tzCjhJLL/zBSwuBFRzauYdFoh6QYmTM5+wQIyXkDj 44gUzyHgJASWJmd3xEGMqJGbNamOCsNUkrp7bxDyBUXAWku5ZSLoXMDKtYjQrTi0qSy3SNTTR SyrKTM8oyU3MzNFLrNJN1Est1S1PLS7RNdRLLC/WSy0u1iuuzE3OSdHLSy3ZxAgM/5RitlU7G H8t+6N3iFGSg0lJlHefTW6yEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQlevbNAOcGi1PTUirTMHG AswqQlOHiURHiFtwOleYsLEnOLM9MhUqcYFaXEea3OAyUEQBIZpXlwbbD4v8QoKyXMy8jAwCD EU5BalJtZgir/ilGcg1FJmDfuHNAUnsy8Erjpr4AWMwEttkvNAllckoiQkmpgsr8Wvq3NQuva ox2XQvbLadwUETj2s2yvXFzQ6S/yD23NOJuc7RlNDPd1em5yWqSSLnM29f2pGTV7n54yXe00b dddjWrVxSrhcw9yiv+qXWSUo7Te7vL2giqGss9+1yZce9BalbOvprjurbveKpGp/1g0/aIOmV oIWX09WXq+j997dh2/hJm3iv+j+APhJxnDDCU2FgQ03DS8WPyK7aONj8mVpEcSPWeYz39T+Ow /795nLY8MtuoPq35PvXN0QqXB1kNzKnZmznF12dJm5/ZT7ejZ23WT3rlMO1DooCHocrupSEh3 2p0Df10/RDcYn9HcP/P3Wv8rgr+ni+989+SzwRt2bpNrVqvfZU46YaP0S4mlOCPRUIu5qDgRA MVi5iN6AwAA X-Env-Sender: lizhijian@fujitsu.com X-Msg-Ref: server-26.tower-585.messagelabs.com!1668141165!713889!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31940 invoked from network); 11 Nov 2022 04:32:45 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-26.tower-585.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Nov 2022 04:32:45 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id 607E81AE; Fri, 11 Nov 2022 04:32:45 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id 5554C7B; Fri, 11 Nov 2022 04:32:45 +0000 (GMT) Received: from 401ba783c32b.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 11 Nov 2022 04:32:42 +0000 From: Li Zhijian To: Zhu Yanjun , Jason Gunthorpe , "Leon Romanovsky" , CC: , Li Zhijian Subject: [for-next PATCH 5/5] RDMA/rxe: Rename iova_to_vaddr to rxe_map_iova Date: Fri, 11 Nov 2022 04:32:15 +0000 Message-ID: <1668141135-2-1-git-send-email-lizhijian@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> References: <1668141030-2-1-git-send-email-lizhijian@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org be pair with rxe_unmap_vaddr Signed-off-by: Li Zhijian --- drivers/infiniband/sw/rxe/rxe_loc.h | 2 +- drivers/infiniband/sw/rxe/rxe_mr.c | 4 ++-- drivers/infiniband/sw/rxe/rxe_resp.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 22a8c44d39c8..496e29215e0f 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -72,7 +72,7 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, enum rxe_mr_copy_dir dir); int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma, void *addr, int length, enum rxe_mr_copy_dir dir); -void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length); +void *rxe_map_iova(struct rxe_mr *mr, u64 iova, int length); void rxe_unmap_vaddr(struct rxe_mr *mr, void *vaddr); struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, enum rxe_mr_lookup_type type); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index d26a4a33119c..e46ea2a7179c 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -264,7 +264,7 @@ static void *__iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) } /* must call rxe_unmap_vaddr to unmap vaddr */ -void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length) +void *rxe_map_iova(struct rxe_mr *mr, u64 iova, int length) { if (mr->state != RXE_MR_STATE_VALID) { pr_warn("mr not in valid state\n"); @@ -321,7 +321,7 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length, if (bytes > length) bytes = length; - va = iova_to_vaddr(mr, iova, bytes); + va = rxe_map_iova(mr, iova, bytes); if (!va) return -EFAULT; diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 765cb9f8538a..831d71e2054c 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -615,8 +615,8 @@ static enum resp_states atomic_reply(struct rxe_qp *qp, goto out; } - vaddr = iova_to_vaddr(mr, qp->resp.va + qp->resp.offset, - sizeof(u64)); + vaddr = rxe_map_iova(mr, qp->resp.va + qp->resp.offset, + sizeof(u64)); /* check vaddr is 8 bytes aligned. */ if (!vaddr || (uintptr_t)vaddr & 7) {