From patchwork Wed Jul 17 10:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashish Mhetre X-Patchwork-Id: 13735306 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97447C3DA42 for ; Wed, 17 Jul 2024 10:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=vDjPZCWRIbSgtP5xppt2KGALTvzFItgIlDVqzqfEXgo=; b=f20xGspXUPDcogved+KStVeC2S R1EeJLF7jDABV8FBZDVJq/An5M7ERXWF4tGVglQdgG6bHr1pUWvLYzTUX7aXeaZv6lF7h9c8D6Wvt uHuvdY6TeY97/mIEaym+DUIl8UTeYKj5GqHGHtnn5KV8XzG8hzVLaYsU88TdGbryt+gK0sM/v1sgi dKLgo5gT/GqxusShoF3kEK79KmkFtAsB+yA8K93dHpJodkPZ0eyMOVZDWPhvHP2b4Tezduk2+pHXO RyTnjNOI/5SjQUI5j5+HeOdiHU2RcKIw2KI/pykSD2nd6YQlyTcMHsy6knJl/ncuy3yQg4Zs0r3kC xhv/HcnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sU1Z2-0000000DQmr-1V9T; Wed, 17 Jul 2024 10:07:12 +0000 Received: from mail-dm6nam10on20628.outbound.protection.outlook.com ([2a01:111:f400:7e88::628] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sU1Yh-0000000DQgs-300v for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2024 10:06:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FKUU5xB5XPfq19hiwD/YTNDscU96SpnWcYsE5++n2TLEdEtETOkxzPnOngIFc2Eshvm6w8hJ+c3/H//WyDwLbxo2DjxvMzYJVXwYTNuK89/YxR8bPKL44z2d2fyvxAF9erCpU+feeY6qXd9VJ2unwJVl5q+1wzmj8bqG/IU7WjN7SRfKixfpl2218Ku0wQTsKAGjACGipJqRDrylABPIm46IXJAVlxVYTwTJDsvWsGFJ574NfuSRX91s9Os0KyGR4wyPhwqzdDckPFZwaScWW5+nRVSmAgOSc2U0IfVekEfbjTaBXgl6wf4hS2B0C21Qc/wgxTjxi3B9hvHyk7Mp1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=vDjPZCWRIbSgtP5xppt2KGALTvzFItgIlDVqzqfEXgo=; b=SkjFJOljUmmx4ffU1sgRyGbw1VeKgIMZfW74s93vAqMPg0MXfok83fAj2OCF/N6subWrqAeAPo9gSTJJhf0u9iwO/gqLYk7smyyjQOkhlrHcb4a9UIoQ+6rZdA2r4hEPLMhO8HtuPjUkBdKb0flw1wSkJLMouctVOVi2R8BxT5M1wArlVOGUAhMG73NmDo9mW19Swfe0rz3aekITYM9o05QvRv/0evhmQN7treNIOt6tegzXrZgfywE1TbYRAqJr6hcM6s/bjw9bGyFWzdASasY7dLVm8fjdoAhad+GrA5utAaf+u3o9LnXe+k/B0jXa5IgJgHhU7s7v+VS/UEnrvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vDjPZCWRIbSgtP5xppt2KGALTvzFItgIlDVqzqfEXgo=; b=uS4/E/b9AiO80l8gEZfbjTF39s9InZFpKyFxlYSt+WjQIDF3BCLxjcuPk5qcV5RtDts4IzLTPwRPEblAowA8X0iYzsxWQsu5slf5WycmyT6/GEP4jB1tQPqa/eO0m6SIKGdlrS7hVv0i9Q0jZXPOgNF71GDiG3GafhqCpSaRYd+lJFv4k1dpf9WcmSzNspq7EUnTaAO5cu5VFXRewQbm7bmSXysZId07bzYUO+yiPId2vIiAksyxmzNMtpOei81xI6MvFyh+kTelYpMn8Ik3fyA6RcQWPGMhI/1sHBScJEbmQ7MCJL308Up5zmW4Qjj+fw7NDXMSDahkpGXXIdTosA== Received: from CH0PR03CA0345.namprd03.prod.outlook.com (2603:10b6:610:11a::29) by MN0PR12MB6032.namprd12.prod.outlook.com (2603:10b6:208:3cc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.17; Wed, 17 Jul 2024 10:06:46 +0000 Received: from CH1PEPF0000AD7A.namprd04.prod.outlook.com (2603:10b6:610:11a:cafe::aa) by CH0PR03CA0345.outlook.office365.com (2603:10b6:610:11a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14 via Frontend Transport; Wed, 17 Jul 2024 10:06:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH1PEPF0000AD7A.mail.protection.outlook.com (10.167.244.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.11 via Frontend Transport; Wed, 17 Jul 2024 10:06:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 17 Jul 2024 03:06:32 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 17 Jul 2024 03:06:32 -0700 Received: from build-amhetre-20240716T042216611.internal (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 17 Jul 2024 03:06:32 -0700 From: Ashish Mhetre To: , , CC: , , , , Ashish Mhetre Subject: [PATCH 1/2] iommu: Optimize IOMMU UnMap Date: Wed, 17 Jul 2024 10:06:18 +0000 Message-ID: <20240717100619.108250-1-amhetre@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7A:EE_|MN0PR12MB6032:EE_ X-MS-Office365-Filtering-Correlation-Id: 51a91b58-b092-4075-e9bf-08dca6482a98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: 4xWgCqYatPEJlQfIMlCK4VM4MldUUECwhXeDK1yPaxeARtslXGqYtovG62vanu/kLcL/tI5MRv4l1r1MwEZnwTC9hueZFkoXpjkmNf3SmUCHhi8tXvL7ojkRQHue3gCnWcu36pguLeCjtPyV6zUA0gfjpzkpa0cTzFNSkH48cYk/ER3EPFA3/FY4Om1Yk8GqDCE0VzOke1BOYs5FlmsXyNSWeb9woS0KSpM8+OIlxl7ckZzPYRP0rJ41+VGXNCQp5M+G+h0bdiyTZGAFPhtI9wbzwaqOAnZAY5AAI4p0xOQvG2xog3kjhTrCqvY/di+RbJlJokZaiZi+4rESfTYxijohH6h7hVi9keYwPsjYnvNMz90dOOqme22pdPAZVhlNIT6lhhaSjUlW4ijRUMJ5Pt8tRicaCtkuoABbSKETUYEoQ/+QEVnQ9HfQEHUlHQxu7Bl7a6BzFij9jIiwGLsFugXjT0G3nAbFI9xVZUQ+cyiHnFTquSb0JT86cZsDSmZSJhCAUWbsGPaFaaLoMIu9kZUrDsW4TGUDmwUwSAnCbH/WvFZm2sRpXE5RbWX4s9W/IJkz0hrJ6O1VpAStYoXSlHiIShiKliwvx2kO9LweoYjMwP9e9ISm0DUdk3q/w1pXRgO7QBWDSdiDxQAfKYjtTd7hp2dKsdKlzjPEmE/+QiTDZXBYGrvX9ln4HJvACXt5YMGkxKcVIIDqpykdPD8hSg8uMIp2QjV1UvG207K2k4+6UEbggTveeN2CIzER4BX/Yx92RR3tLwrfRsUrBQ27AvxCwDLVRTHlOTxC1atzBbQm2mfpVA0fAqPK0BNOKkL3rmoLQlv9VKAdl1iWzIsBwMGAosgWgug1RJKgOBMiZIxRTOFL7MQe32BGCxH1AtC/Ng5DqyAExKvA9h+y1fnzqmUZDUMjJ+AKcS+I7KOZHXAiU+Fo0fx4TZbZdoPA+EiVQK9aNScqjWIq+HAPMqIk8tQ19gZpkrsypDwpCJstYGvtifNE/JJ0LTniTG4D/+53IPSfKVQVzN0sJW6ptb5sVac4H7FWsT39Cm7kNwVAvSSd7FNNvnhEbJSp6aQimFNuG8YXxTs7GCGYH6yJygWMJ+ExnppVZwlEEg+5Nrl1TFDcYzJh762VJTCUIygjJozYEm2EKSOkjFbblik4cr5MFscqXrDWpqUb/SgJh0uAQcu6IbrZx85xbDXt6KE0Kh9lYJiNCEoM5tVrx0kijTyO+FFJ55BltbvmIhK8ES6g8z33w6Pjfef8KGD9a6xw1ayRdyAAP8oFQnGMz/m5ETOBiGJVaB9w0pgh84eiecUhfdqKjTPYKrba8/RiUO2Syg+3xb2uJi9HVCr+Oz7MN4ZdhnP+zpqKP9RibnqHN3jVwEp7C2NA1ymHjujT28TZBRrQGPT50XSHHaatejsCY/YPq66OszPiAN7UcNAnu7gwwWRtVQaaf4ppbKXtIxlsyu/G X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 10:06:46.0725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51a91b58-b092-4075-e9bf-08dca6482a98 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6032 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_030651_792472_64D3AAA3 X-CRM114-Status: GOOD ( 14.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The current __arm_lpae_unmap() function calls dma_sync() on individual PTEs after clearing them. Overall unmap performance can be improved by around 25% for large buffer sizes by combining the syncs for adjacent leaf entries. This patch optimizes the unmap time by clearing all the leaf entries and issuing a single dma_sync() for them. Below is detailed analysis of average unmap latency(in us) with and without this optimization obtained by running dma_map_benchmark for different buffer sizes. UnMap Latency(us) Size Without With % gain with optimiztion optimization optimization 4KB 3 3 0 8KB 4 3.8 5 16KB 6.1 5.4 11.48 32KB 10.2 8.5 16.67 64KB 18.5 14.9 19.46 128KB 35 27.5 21.43 256KB 67.5 52.2 22.67 512KB 127.9 97.2 24.00 1MB 248.6 187.4 24.62 2MB 65.5 65.5 0 4MB 119.2 119 0.17 Signed-off-by: Ashish Mhetre --- drivers/iommu/io-pgtable-arm.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index f5d9fd1f45bf..1787615eec24 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -274,13 +274,15 @@ static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries, sizeof(*ptep) * num_entries, DMA_TO_DEVICE); } -static void __arm_lpae_clear_pte(arm_lpae_iopte *ptep, struct io_pgtable_cfg *cfg) +static void __arm_lpae_clear_pte(arm_lpae_iopte *ptep, struct io_pgtable_cfg *cfg, int num_entries) { + int i; - *ptep = 0; + for (i = 0; i < num_entries; i++) + ptep[i] = 0; if (!cfg->coherent_walk) - __arm_lpae_sync_pte(ptep, 1, cfg); + __arm_lpae_sync_pte(ptep, num_entries, cfg); } static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, @@ -635,9 +637,10 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, unsigned long iova, size_t size, size_t pgcount, int lvl, arm_lpae_iopte *ptep) { + bool gather_queued; arm_lpae_iopte pte; struct io_pgtable *iop = &data->iop; - int i = 0, num_entries, max_entries, unmap_idx_start; + int i = 0, j = 0, num_entries, max_entries, unmap_idx_start; /* Something went horribly wrong and we ran out of page table */ if (WARN_ON(lvl == ARM_LPAE_MAX_LEVELS)) @@ -652,28 +655,33 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, /* If the size matches this level, we're in the right place */ if (size == ARM_LPAE_BLOCK_SIZE(lvl, data)) { max_entries = ARM_LPAE_PTES_PER_TABLE(data) - unmap_idx_start; + gather_queued = iommu_iotlb_gather_queued(gather); num_entries = min_t(int, pgcount, max_entries); - while (i < num_entries) { - pte = READ_ONCE(*ptep); + /* Find and handle non-leaf entries */ + for (i = 0; i < num_entries; i++) { + pte = READ_ONCE(ptep[i]); if (WARN_ON(!pte)) break; - __arm_lpae_clear_pte(ptep, &iop->cfg); - if (!iopte_leaf(pte, lvl, iop->fmt)) { + __arm_lpae_clear_pte(ptep, &iop->cfg, 1); + /* Also flush any partial walks */ io_pgtable_tlb_flush_walk(iop, iova + i * size, size, ARM_LPAE_GRANULE(data)); __arm_lpae_free_pgtable(data, lvl + 1, iopte_deref(pte, data)); - } else if (!iommu_iotlb_gather_queued(gather)) { - io_pgtable_tlb_add_page(iop, gather, iova + i * size, size); } - - ptep++; - i++; } + /* Clear the remaining entries */ + if (i) + __arm_lpae_clear_pte(ptep, &iop->cfg, i); + + if (!gather_queued) + for (j = 0; j < i; j++) + io_pgtable_tlb_add_page(iop, gather, iova + j * size, size); + return i * size; } else if (iopte_leaf(pte, lvl, iop->fmt)) { /* From patchwork Wed Jul 17 10:06:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashish Mhetre X-Patchwork-Id: 13735307 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8A4FC3DA4B for ; Wed, 17 Jul 2024 10:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Z/JYYuNywcOlvbc7IRcLncHn6vGzXZYzbS9x8PuOD4Y=; b=rRLo0yLSdwHk+kRsdhOZSykV93 5iI83Ym5IBFio+lKYxJAW/9bL2pGHr9MVECdyxwy8ow4XSp8Jv6YayDUyxeWcv9gmmF2SzYhwP9Ng 3V1r3MO1nkxumgN6QYy2UWkFRW3Q+BKmmI03k7Ws4Z9N/13oLntgx1xQPqzY3A5z95cGzgzwpCZBk gHsvQs3KtEFI9maGdNKkDBUzicRmg0UQbvcUAjtP/AuZfS80LrlS2WYJvYWiMeCmvdc19ibACC5Sj YfKDuVZM3CWkQRPyFY8yRyBsdOdfw8+pjFgIp4BHc4af0/QFwhLL4Uhsv2jn27W+dA/AP2V4gMMoy Hy3v4MLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sU1ZL-0000000DQv4-1BoA; Wed, 17 Jul 2024 10:07:31 +0000 Received: from mail-dm6nam10on2060c.outbound.protection.outlook.com ([2a01:111:f400:7e88::60c] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sU1Ym-0000000DQin-43Mz for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2024 10:06:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nKLvfcyfjEnn+VPuG8QX6ybwAxW2uQ+fBeQRDlkQE8NJo/YnUMxwWByEO7CYmmPAgdV5ZXWzvsbO56Qxwc8xiLKZnRr/RD9BRfnEOIDI+pJsQKNExevuvRPAh1XKPSQm4WbfbXNuBnZaar3vFukcUXVY+ydFZ6/xQnjar8E8jJy6tRmhdM4PyUJdB3vlosukB8u/okd88gLhOiyXZccuqzZhF5R0z/61M0bAsGH5M6K58p2+4hQ/k7nnjXiG35Ukdoy1ZJJcmgtjJKrdxwtqmjcbsZ4kZnC+HfgIxDrH9oZT17WMD/Z2w2Sxsy0xHUupAF85Nc3XrmuSrZUf55Mzlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Z/JYYuNywcOlvbc7IRcLncHn6vGzXZYzbS9x8PuOD4Y=; b=UfZyc5uWsNHyjvJI7CkPBpZaHuoiNYAkVjPbxrDxZjxyfU/ij/ppxIs13WVWQ39JjuaYgzxavN752bK2NKWj9VlSGIAE68cDWU//qQbbdgS9U9UapCOj+a1cgiGmpn+hvoYCa0aB2Ndj3rVmhhIXXjfs5qbOOF/ReTQPTZ7JrSRzDMdLEcRwxuSMxbAXbEJwH6oUq5l42MtjCyaE4uZILc3IA7tTaFcrj6halypxuq+RcRZf0A0lUyFT0KS864iOobtBLh82De1uTYsnTWSyouwgCChutVKDpJqdzM7heAMpl9Bf1BYG3pj7LbrzdXM0cwAKU4RiyPLtBux/8uAJzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z/JYYuNywcOlvbc7IRcLncHn6vGzXZYzbS9x8PuOD4Y=; b=s0/Eq+qoOnVD6Z83hjENNxUIa7rl1OVAlNDNDbEXD88kzRn0F1L6a37hsJxoXExgn10JNFkhU5LM3HI64vuXEIGLnIMdqAQ+1DEsZRg+leOpSGKrnRPOAlMhE0qDz8R7/GW/+JCm+CDApHbhVM8AWV/iv/4Jbuf411VY1u4q8eciXaI7PsdyitG5y9Wnu3zGWWICSItBqsosCxudkCYsJ9vrlRqMiJLq4d7PghmZxo0jbJwLQAsP0YJYrvHc3+z4pLTTwCxB303rr5tEPJfRFQYPFCSQo0JfYyKyb2Crl/h4h/uwFbRgcNJjb2YDDtKuM/Z9qt+ESA1alZW/wgAfZQ== Received: from CH5P222CA0024.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::9) by PH7PR12MB6417.namprd12.prod.outlook.com (2603:10b6:510:1ff::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.27; Wed, 17 Jul 2024 10:06:49 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:1ee:cafe::22) by CH5P222CA0024.outlook.office365.com (2603:10b6:610:1ee::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16 via Frontend Transport; Wed, 17 Jul 2024 10:06:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.11 via Frontend Transport; Wed, 17 Jul 2024 10:06:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 17 Jul 2024 03:06:35 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 17 Jul 2024 03:06:35 -0700 Received: from build-amhetre-20240716T042216611.internal (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 17 Jul 2024 03:06:35 -0700 From: Ashish Mhetre To: , , CC: , , , , Ashish Mhetre Subject: [PATCH 2/2] include: linux: Update gather only if it's not NULL Date: Wed, 17 Jul 2024 10:06:19 +0000 Message-ID: <20240717100619.108250-2-amhetre@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240717100619.108250-1-amhetre@nvidia.com> References: <20240717100619.108250-1-amhetre@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD74:EE_|PH7PR12MB6417:EE_ X-MS-Office365-Filtering-Correlation-Id: 42bb99e1-c5c1-4af5-ebf9-08dca6482c9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: XeKCDvi1VR6E4atH86uFFmutFuTOUW13owC1m5J85N2P29IK9j/hZrM00VDi886IiaCt/yyBj/1oNmvsxQY0Lsun/Z0VZNPpobjYRVlV64CXJ33BrtNidyz2CNsGxehmDIlgA8YMODyEIBQjzgmrITNGFUzcVGoo9JikDhPOrse99drvtB6ZHzac4qRFtH6rHGTJFilCraeKg14Z9sIKX3HmBncllt1/KfaSAISzyg3BpSLV9Jj1jvujUclpsfibI3Hk+wq9drNXGLqWO7ypG8kRoNtbVscQ5YnDG6tujV04vEZ3N9lv08BlsQCYuzVLzdbSQGCLA3SsImt6RqiXoYyTiLNSZeXaUzkkiiAC3eH8ns3geNmCs7OW3dPjz8y2by3Eo8lkiVIQI75HseSWMFDZfOOMey3FD0CHuKLhsr/PKYGQcQ/bofDk/DlvgwXdJ5dIM7eRZieoU091pRagFDPu3d6F0KDcRk3DDhGlLi6cCZPAebn1fOo456W2FgojzeQAC9yUjg/jeXNJY5ZssTZGdKWA9GxAQidK+VQrBPsiR6qORTf8Ic9QWhFUoBgDqFRTinuzjekJ9dfD/luhxibXBQyR2qSshEAmvW38DlIiCnYcL7ReU9mzFu3xHa9GU8tJZ1f0Z/dS8rds7xWhfZGXz1+mTBTG+HJ6hZvRkA9EmccXYycHEuw1DDkbLV1MZAFKu3JJpxKzCyYXPngZmK66eF+JEypO/kJKVFoboIa0Gn5gXH+Ywc47n4rjk91sTQdkwX9y+p8PIZvI+QRiFn7XAVUuv3ZpZ0/wvTmW7QScGd7q1WX8RoY0PVGziW/JLpBYvcfDnzpG8MgXqkgnQiJGQhrjfnu7Cj31byuxgvB4ESjd3cadGAGvB5BCTAiSmW30inSm8Xq/LhrWYfz+BkV4DxPl3l3gHhZ1u8iDFWLknOySSfXrWxrb83r9uFAiC7w5YSdCgKnf1DC9Mg4DKVRF/KTTomBKawlUaFiUazEhwrZMOT7Z33G25RBURQyYacWD45Q91nUgyP4HtOiL2h5+BrLP29xPjNmk4Zasq9vwz5QBzfo92kdZoc40pcGo+ZPsLB1vwmy+4G7j3SIE3sLLgnberT4NPIFbqbKh00dNoixVXT3I+wOuHSUzvez9mrNXlOsaweMJ+ZwFZOkZY+t935V2HFYu5ONa9yQsrqgi3qBWuo1sKWzukhdU/9pFWGiCy+JnHHCol0c0BiaYQCK0oIcnkUKxQPGY2MnXwPAsk8ygsD8CkONU9wE3x7Eoo9n2zKkrsGFoBeC+kf4VFVafLbdblbNBGB7MAOqCVZ3EG7FB5ZhQ7I8Qmw5tDO/Ahdoo5o/EMOTs32wM/yB2TIYDCHRnAHd1IkFP7eRfRtJn1sw5rSFOVjLTWs68aDx1Qpl+gevAv0Dx1i+XEAtbVHmlrwM+/WWnaoz8ZoZnPmfCku7/9OsUknCgTaeeWu9n X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 10:06:49.4230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42bb99e1-c5c1-4af5-ebf9-08dca6482c9c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6417 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_030657_037691_1BEB6264 X-CRM114-Status: GOOD ( 11.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Gather can be NULL when unmap is called for freeing old table while mapping. If it's NULL then there is no need to add page for syncing the TLB. Signed-off-by: Ashish Mhetre --- include/linux/iommu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 4d47f2c33311..2a28c1ef8517 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -928,6 +928,9 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, struct iommu_iotlb_gather *gather, unsigned long iova, size_t size) { + if (!gather) + return; + /* * If the new page is disjoint from the current range or is mapped at * a different granularity, then sync the TLB so that the gather