Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp520629lqr; Wed, 5 Jun 2024 12:40:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+X8cbsYMtSAZxJyLoTuObdLR0Z7L1EnYzibQd0eP6Zl4caNxSLJ2HRJsagmhWQQE1NuHEVqeEpD8Kte4LteSRLCEuTXhJ0cat4V9/KA== X-Google-Smtp-Source: AGHT+IEuBo6xWlV2lvvBy6rOVvI14QgxGu+BFRaQGpQbHOQ1I9fu4Rau9+wYFP1sSV1sJzxqTGF9 X-Received: by 2002:a05:6a20:12d0:b0:1b2:c6c7:f60f with SMTP id adf61e73a8af0-1b2c6c7f7d6mr244739637.25.1717616438729; Wed, 05 Jun 2024 12:40:38 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242d5e91esi10849903b3a.370.2024.06.05.12.40.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 12:40:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203106-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=pi3w3toA; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-203106-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203106-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 834BDB20EDC for ; Wed, 5 Jun 2024 19:32:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B776A1552EA; Wed, 5 Jun 2024 19:30:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b="pi3w3toA" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2108.outbound.protection.outlook.com [40.107.93.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073A71514E6; Wed, 5 Jun 2024 19:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.108 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615824; cv=fail; b=M/TWBoi9zF1RanrqdGiiNOyKX5N4qQTZ96y9UTWJtrsxGCk2ESBm34DXDcE/d6hU+AM5SQr19iVfSxyzogngYF8zuI5+qrzEq0ohAeUMz9rJ1M5Vxzdyx2wCxMHFDG/1gMXwkDzPG03BEqV8EBjNoQxvhLmn1LEVhf9h6zxzRhM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717615824; c=relaxed/simple; bh=4a3k6y2crYCilo4927vRW7ZxB2urJxhgN01xNP/IdWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iumhYRwVMNnfaoGLwOMV5rt/QJJOANnneUOJeZWxbWp2OMAPBXmI7NTvzaBdxCc6/l0ix8hTzj+GjaVCCQB7ugekmE0JVH9SLUltwbciA0jbWwdiea30qc1c5+bjMHVvz11eMvh3w1OdVgDiHD2mztCXkq697Qs08fP23J5qvxQ= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com; spf=pass smtp.mailfrom=eideticom.com; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b=pi3w3toA; arc=fail smtp.client-ip=40.107.93.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eideticom.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+40/1HbSdhQLVXDWUzYOMVHsxynjBpASwATfSvqcJNiuP0Z6WfCGly+JSeHVin582JlnnFp3OaMma0NQ0Dy74ezuKaD4TKHycGkCCIGB4heWar/1c3OpCfDjwty6EvVUb6wnSuYXd869t/R3KI9A4/RB1FnoBrSoEVaAiqjB092ZjtXyzJQsP2p+iPeOediGJvjPk/uJ1n5Ys9erj1fzvURzxALPrjVYFtxeI7TFSEecNRk3ojKZAhrhHjs8TC11AOXFTsn6W0f6+Pg3LKg8AYa8h5YU7QhvH3qByhkjeJnWQUUdjwT5tk3c8IzzHMkVu7BM/3fbQUrF6yHEq/16A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LLEvtGJwZjuGUInJS9PLacP482Vjf2UziijYhxnFPGQ=; b=KbE1hACcQLe4EUN0tP6JkzcySKJbFj7YBjLOqyTko0KC16n8/OAAbAQE+WhYy0Ub8DoJPc3ezdSmJlKRyykVQV1+Hk96alaL3klMfACcOmGn4m8J5Njgrl51r3E3zJvIo6uRP+OyDXaOs09I8IZGI8AizuSIl2jribPApnXV+ofj7UtW5m0z7nFVdnyCTuu+G9xOcVJmRM3mjZ3vdy0oma9swvajuar8WuBYOak5LdGz3db/Um6vfhI1/1ZxbC3PtSkaBBuuTx6eMdITGfjY6xJCKYS2wFxf2utzqzj6UdinVL80flKsKA+9RuZaaj7lQ4qEKXS2dtU6u8Z4m2REgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LLEvtGJwZjuGUInJS9PLacP482Vjf2UziijYhxnFPGQ=; b=pi3w3toAAxyC8KcTlZpOoHpX26inCpEg2vGib9/5uqGydOm66qHIAyhFAsIfNB/SFjjpSIYLa8uIYKfQyZTSVfEL15sTqx5adK67u5FJ1inD9wLK0QXwU/lnsLtJkXcdxMqMsg8lzpbkoq61cLd1z2u0ac0UGoG+2OiwiAcHa6A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) by PH8PR19MB7093.namprd19.prod.outlook.com (2603:10b6:510:223::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Wed, 5 Jun 2024 19:30:11 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.033; Wed, 5 Jun 2024 19:30:11 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Bjorn Helgaas , Logan Gunthorpe , Greg Kroah-Hartman , Tejun Heo , "Rafael J. Wysocki" , Andrew Morton , Mike Marciniszyn , Michael Guralnik , Martin Oliveira , Dan Williams , Ard Biesheuvel , Valentine Sinitsyn , Lukas Wunner Subject: [PATCH 6/6] RDMA/umem: add support for P2P RDMA Date: Wed, 5 Jun 2024 13:29:34 -0600 Message-Id: <20240605192934.742369-7-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605192934.742369-1-martin.oliveira@eideticom.com> References: <20240605192934.742369-1-martin.oliveira@eideticom.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MW4P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::12) To MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR19MB4250:EE_|PH8PR19MB7093:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b3302fa-a446-48fc-9457-08dc8595e9df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WoUhsWdI3dWrJg9T87g52xJSlUVURxPCcyyDhKPF1hhfWr8myBzRA5TxcToF?= =?us-ascii?Q?IkXO4CEq6z2AA4gT9+5X9m6YciHwQOu3jc5sWUEB4eiIsZe07mUT+HVQ5o15?= =?us-ascii?Q?aaaKxJoB4tF0kowb1vTLXnwcxYqcUxmD3BYZ37Bg0bGGov2L3j0vTzImBJ6g?= =?us-ascii?Q?YkgXG0pNBxgmGH6CO4+kQu08NPwKnwHZRq+j3pAyp5C3zrouhUsDh0pvbu2A?= =?us-ascii?Q?H0O+18T56VaW0qkBx/TatrXj+u/hilDyw/eRpDQ3ad5xCk6NUT5eYpBf3666?= =?us-ascii?Q?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ypYcNG8TjyZT0Y5XQG02Q?= =?us-ascii?Q?9eooXHIXSxr6Q2GlExqQ2oM9ykvIaxZbnyYTZjRTScDMg5qEbl4KJcB51eHV?= =?us-ascii?Q?WsCCmFK7Xk4XfTyz5u4LbIhNf5y2CqgWu/wflhHlnaghOtUU+UarVg1pd83Q?= =?us-ascii?Q?x6zS6TdlBbf5FHsLhAjzDP+ZQzsq4eSItZRKn/9sfa4gy3qaJJIA0C5XTEOR?= =?us-ascii?Q?Y2ZqvCA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR19MB4250.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VwS2HTB3sluArf9tP/AMjIZe8Jxn2fndAsKHv7BqtII0aix5KJf3NgL/xP2v?= =?us-ascii?Q?A1sdQit89Ye4uDZvLWJyjZoT2QfmEaOfR8JzZlGebpJQBRIZSftYhVIIi3WT?= =?us-ascii?Q?aCi943r+SNxpYbtU/VO7YPotIjvbHRJH0s7DVuCm8WYTgyZ9ndXdM2GYBrfr?= =?us-ascii?Q?Ax0O1nOzYZGVJAhdpjNaifPV7Xw0IqopVxEkuUaiJRfP0xBcpJFF9o96NaZT?= =?us-ascii?Q?uPdR8t1+MJQVlSWdYgXBsBOqvnLSvoAw52vNAQRdbpApMWk8mLuX2wywCPjR?= =?us-ascii?Q?/5ufTKaN/VX3YycqXojbhTqsURnjUSn//tv6nLQDNYJCKEBhGFp9sSLt8OZM?= =?us-ascii?Q?KIyfeYZWkh6YbP0y0b2wU1NNlzNokfF/R92hS26Wa+xlcCQIx9Mhjl4OZQT/?= =?us-ascii?Q?9KMjx0trlXUUeCG5xtK5dYG+ExUThszBq1YjlExblOShk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S2mWR+mzXWJ9GylmJYtC7D6yvUdxjbb5nGCQkdvN?= =?us-ascii?Q?FsYnj/Id3EPXveofN5QxVBFAqqnThdO/jUDFwPBwVPMa1rhCjO7mTT3enudT?= =?us-ascii?Q?nnLYqYWh+f1hTI77Kl+AzPLdxL8+2l/2MPdRqoNueQqr57WGtJha6BOPf/lT?= =?us-ascii?Q?+RY2K/HMZZ+0YYHwvi1a5JRShA0jenFOsuwwtDvSGIygwRBVYexdcfAgjXsw?= =?us-ascii?Q?zoz8yofD6Lj0FPrXa+Rg0DEM4g6/J1V5kHWWXgnaXVjtAaizXTXCFTpxlAIJ?= =?us-ascii?Q?+g=3D=3D?= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b3302fa-a446-48fc-9457-08dc8595e9df X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 19:30:10.1101 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pW4vfJjQZhLVzHXkMV3OJtREdxV0qWStmNY5Mhj3g+/P+PsH5Ok55ex2XALbpfaYTEzPgsqjRzbj003OD5RBNLbpgz9x5kbuzKMr1z6RIeE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB7093 If the device supports P2PDMA, add the FOLL_PCI_P2PDMA flag This allows ibv_reg_mr() and friends to use P2PDMA memory that has been mmaped into userspace for MRs in IB and RDMA transactions. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira --- drivers/infiniband/core/umem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 07c571c7b699..b59bb6e1475e 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -208,6 +208,9 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, if (umem->writable) gup_flags |= FOLL_WRITE; + if (ib_dma_pci_p2p_dma_supported(device)) + gup_flags |= FOLL_PCI_P2PDMA; + while (npages) { cond_resched(); pinned = pin_user_pages_fast(cur_base, -- 2.34.1