From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E89B4A00C2; Wed, 4 Jan 2023 06:19:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4B7B40A82; Wed, 4 Jan 2023 06:19:48 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2047.outbound.protection.outlook.com [40.107.95.47]) by mails.dpdk.org (Postfix) with ESMTP id 76AC840697 for ; Wed, 4 Jan 2023 06:19:46 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b3iMTDXqLliZQPz0XzMYzZEyR++Ld1wr3Oh6naCWe2Uj20wmsRFoYXcs0ZnzPxOEteTXw77jhBElcMQ10JLbJm1fzRP8E+J99QezkMzo6PUj8qZ+hMtXXQaYYl2Je1qUQo+wTP4ggYh1knnQSFdNY+CCfZ1iIM0t1D4q0uKtS8kt8vpgBwc4VEVXhsRr1SmyhoVYsnViaK9BUJPIjWMZ1ePv1gYXYdDDiMVDYnQnpFnVtsHxJb3YiLEelBvM5Kav5hXQ0TtRztbE3AQR2jT9/QsBrk84cwPtk0RMq45cjra2v5V+4ldQMouiz2oL8AwDXNCVGNTPlAAbfTGDZA97+Q== 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=iuQxjcYj1s/0G6vE56YR5wYPnRvYXOEXelXgSPcAyKo=; b=P2N+U9aFe+1XXJ8JBJrfoWJuqJMcxspdYRNk58Vtx/p31VTw+JS7YIVSs/PUaAPXzJNJ+9oxPU2PWyLbHfCwGCWnHyf7ZPziq9wz84SaQ/2gmNn1kwt/x7O1pXutkRZPjp/7NtmJaFMSR1GkxHddo4RCIqRMhQnAZH2J/w4OH2G5dXnrMWRQG6ReBJH8++CE05VsnpFrYfYAEpwJuBwK4fIbUivfNg2PV8lUF4NIo1Gx0eb12kObSpJs8W4rRpYlYH3djT1RbrkRSuvWEuSUNfRHMzYl/mySAhWOwKcvPgs6S5PP8eGvxrjY0yo17oVex9u2zbRPJ2DJL/A5yCSvZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iuQxjcYj1s/0G6vE56YR5wYPnRvYXOEXelXgSPcAyKo=; b=1+HnRf6ST2xSjjs2pyZMhNbuaQBbj1RzqdfrTDA0BkaMefm7nKYTdJtEN03BVy99KYlOXJyKwf/Y5RYEVg6jaDjIEsljBah59qg8a2eMtB1WV6vR9r/Lb+yIifOMSFgy6uH8gu6j6KTwv28NlUbTGHx9IAc7XgsBOd2zis172Eo= Received: from CY5PR22CA0001.namprd22.prod.outlook.com (2603:10b6:930:16::15) by SA0PR12MB4560.namprd12.prod.outlook.com (2603:10b6:806:97::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Wed, 4 Jan 2023 05:19:44 +0000 Received: from CY4PEPF0000C979.namprd02.prod.outlook.com (2603:10b6:930:16:cafe::43) by CY5PR22CA0001.outlook.office365.com (2603:10b6:930:16::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.14 via Frontend Transport; Wed, 4 Jan 2023 05:19:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000C979.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5944.10 via Frontend Transport; Wed, 4 Jan 2023 05:19:43 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 23:19:43 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 3 Jan 2023 21:19:42 -0800 Received: from xhdipdslab49.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 3 Jan 2023 23:19:40 -0600 From: Nipun Gupta To: , , , CC: , Nipun Gupta Subject: [PATCH v2] vfio: do not coalesce DMA mappings Date: Wed, 4 Jan 2023 10:49:36 +0530 Message-ID: <20230104051936.2456411-1-nipun.gupta@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221230095853.1323616-1-nipun.gupta@amd.com> References: <20221230095853.1323616-1-nipun.gupta@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C979:EE_|SA0PR12MB4560:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f7e3ab3-526c-469b-8141-08daee134a0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dUPTFD9qMcTYidv+zPhnkXAwYhi4rMMByn1FigGOrhXA6VRNxEkKI5jNgq/5ezQK0k40FPsxiQdoAc0ffKyj33AGC3iSxiIoWDHPDF/1WLCWG3DXRKCAupqJPROyQciGGzpKFRKD/r7qFZ18DvS1kpH3Y0W5IzfELKUfdlHKIMx63MkUHUWTFVr7v54oZhTRO7ugQ26aV05J6UM1tcnhgNyoT7WaVwshEfLaR9ot3ZXgfHRJYt6Tm/Fj3AVfbuZ7rMHM9YTOe2pHgdmFKCHoiSOb9o4GHxwJqpysouoBWIUtlNz8S22ZzvyFOec0+KakpCJspIuVzvl4G/KAZ5182ItFl7/0nPDkXn6mTSZzoval7DUt/AX6JqIEg5rukWpJFxcoqS+sr7kGtbl4LTgyuT+DRji8uDF9+YzD0iSlKGSeA4eLX8mWqJDhiqzFbEeDKEQFLftJl1NM/kIp21gH5PcxpnImTW2bc1nsl9KtPB0skCqgBZRBD+Q+zNNiwNoHT+bnvUGaCROU+D7BYUX4McWDgo6cFQ91ldIlBSLK7kiOIt7fp/uZ6TnOTFTcS61rlYPelN/jd7acCiw20mVtYuaDKLIzp52bl1SbUwQ2swoe1sCHRfnpF+qg2SYdZZBbIeO8PYn0ptxqgvFqH5a78otqSS3NDkNRGjiUlq//ff/ytXNZpwb9HtW/mAaHTNFZAVkRb2Wu7gKVlcHnaGe1QQoIXFeIdQ0g4FY60iI7j0k= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199015)(46966006)(40470700004)(36840700001)(83380400001)(47076005)(2616005)(82310400005)(186003)(426003)(26005)(336012)(6666004)(40480700001)(40460700003)(86362001)(36860700001)(36756003)(81166007)(356005)(1076003)(82740400003)(41300700001)(4326008)(8676002)(5660300002)(2906002)(44832011)(8936002)(316002)(478600001)(70206006)(70586007)(6636002)(54906003)(110136005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2023 05:19:43.9572 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f7e3ab3-526c-469b-8141-08daee134a0f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000C979.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4560 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org At the cleanup time when dma unmap is done, linux kernel does not allow unmap of individual segments which were coalesced together while creating the DMA map for type1 IOMMU mappings. So, this change updates the mapping of the memory segments(hugepages) on a per-page basis. Signed-off-by: Nipun Gupta Signed-off-by: Nikhil Agarwal --- Changes in v2: - Fix checkpatch errors by updated mailmap .mailmap | 4 ++-- lib/eal/linux/eal_vfio.c | 29 ----------------------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/.mailmap b/.mailmap index 75884b6fe2..a234c9b3de 100644 --- a/.mailmap +++ b/.mailmap @@ -954,7 +954,7 @@ Nicolas Chautru Nicolas Dichtel Nicolas Harnois Nicolás Pernas Maradei -Nikhil Agarwal +Nikhil Agarwal Nikhil Jagtap Nikhil Rao Nikhil Vasoya @@ -962,7 +962,7 @@ Nikita Kozlov Niklas Söderlund Nikolay Nikolaev Ning Li -Nipun Gupta +Nipun Gupta Nir Efrati Nirmoy Das Nithin Dabilpuram diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c index 549b86ae1d..56edccb0db 100644 --- a/lib/eal/linux/eal_vfio.c +++ b/lib/eal/linux/eal_vfio.c @@ -1369,19 +1369,6 @@ rte_vfio_get_group_num(const char *sysfs_base, return 1; } -static int -type1_map_contig(const struct rte_memseg_list *msl, const struct rte_memseg *ms, - size_t len, void *arg) -{ - int *vfio_container_fd = arg; - - if (msl->external) - return 0; - - return vfio_type1_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova, - len, 1); -} - static int type1_map(const struct rte_memseg_list *msl, const struct rte_memseg *ms, void *arg) @@ -1396,10 +1383,6 @@ type1_map(const struct rte_memseg_list *msl, const struct rte_memseg *ms, if (ms->iova == RTE_BAD_IOVA) return 0; - /* if IOVA mode is VA, we've already mapped the internal segments */ - if (!msl->external && rte_eal_iova_mode() == RTE_IOVA_VA) - return 0; - return vfio_type1_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova, ms->len, 1); } @@ -1464,18 +1447,6 @@ vfio_type1_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, static int vfio_type1_dma_map(int vfio_container_fd) { - if (rte_eal_iova_mode() == RTE_IOVA_VA) { - /* with IOVA as VA mode, we can get away with mapping contiguous - * chunks rather than going page-by-page. - */ - int ret = rte_memseg_contig_walk(type1_map_contig, - &vfio_container_fd); - if (ret) - return ret; - /* we have to continue the walk because we've skipped the - * external segments during the config walk. - */ - } return rte_memseg_walk(type1_map, &vfio_container_fd); } -- 2.25.1