From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40BD2606A323 for ; Wed, 25 Nov 2026 18:21:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mpsiXlO/; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=HGsaveO4 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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:CC:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=7VscjMghDCeYXcEHLfTwJ3EFWx9w0392wl7vVUzTwmM=; b=mpsiXlO/CurzXuicng0WsJAC0e 6ryX6ljOna4R4NxPet4YCfE0d5hNBhOLsLYDoaNJht1F+uFKWT3BkWRs23bbvYXQVaw6+AXA7w9au IzXwnuIkY3kLAiK0+oppJlK3p+Xasv79E7V31JBLZM3EOD5Le7MMv0TgJuVYbGAkMrJ4aGJ4c8vxl GUbfg2q6rHJZ15TzdZQf1AgkyIF8xx0bKWIDlR+4KrSezz709cG1Bv5JYO8AGGFljJzWgSGwyJ3dY 5tIZQc4K85MTUWkxCxAMknSV3evNSVDeMSt9r0kWzZfsxutz6qJMEhlFnXmbXPFe7QHIH5dluSIV+ LgyCSCXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xWHbz-0000000AzB0-2rUJ; Wed, 25 Nov 2026 18:20:59 +0000 Received: from mail-southcentralusazlp170120001.outbound.protection.outlook.com ([2a01:111:f403:c10d::1] helo=SN4PR2101CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xWHbw-0000000AzAB-2c5F for linux-arm-kernel@lists.infradead.org; Wed, 25 Nov 2026 18:20:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YJIYzQCgBx6YxdFMghPpi+/FUw7xzD++bBUPJROz3t5iiaH3k2jbUW7q+bvHEVZu+xnqamWDknXkauM0KwGUxvUFRoGkVakAYKxBJINzN98YHrDEXv4g2nb3QiiL1CnbkIG1ex6dyQFa79aqD/clKSwLdfCu1Ph09SFLI6BtjdN3yrjM5b5VmbrZ0tplgLblNzyjumF+l1grW8dDp5n3UGF1Xq1js6r+/HMcbIFf3vC3vQUeYu5emWeOQgUCc0mWwY+w2wKWrufZ0f6sx5W38bOvRlm7K9WejG6z2ZtZMXpfCxaLdKnda6rMDFYEvtU++1XT0Dky1hfCFli4jMQFTQ== 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=7VscjMghDCeYXcEHLfTwJ3EFWx9w0392wl7vVUzTwmM=; b=ftkYFR2mW1omy5sCBdDk+suUxe819ZPhcTF1svT0jT6UvSCFKpk3ozYyapOpIc/+m2+sYeBzdinpytK68d6zT/SZ4MdksF5VHUmcTdPsZHetfhipMGwqgdxj0EX/aKKvA1UpWqBYSbn0Wmxgpm3FcEKmaHzZ8oTxF3RoZf2j/BF13SpTuZkybVhkhfq9moRsqDwhjsLuowUlAo+Gk+eCGmZW2XhRzqKIPGCUGqIIlYPOHCob0UZlbk7P/CPs9KMdhC6nnnqtVNO7r6z79uvDjWJ4xfVO188j4rpvKkA45e7s3gkWPdFMhwG1/PPNck4pxHe4VsbvGUWoBoruDxL61Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=ziepe.ca 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=7VscjMghDCeYXcEHLfTwJ3EFWx9w0392wl7vVUzTwmM=; b=HGsaveO4OOda15eSSVp8FtGG0urkCa9rHI52hyA0/iHJaLaKioIGN/iOnBsC7jgDGLa3VaOl+bOBwhvzW/NLCvAexAcPS4WWqGOOPfjx2A8foOf6CrsDiVVLc2C3dGB7gftZJU5V7NoxDY9U5Le88NKlyaGw7IVaAkbozPTl4iM9pMJMBOgKNVGNliTyncoyhyM73h1d6Mkcfg9PtbnYdr2Rigc5t4DpaaQ+FSPrh2pZ1fKuSW9Iz6zSi+8TUM5kuWnmQG7tmjbHMasij8BHyIc90eFz/T94pK3XyrIAhhdilg9Wv6PnLq8kkiP6Coc1tCWGYHldst68s3eNiK/qXQ== Received: from PH8P220CA0009.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:345::15) by DM4PR12MB7768.namprd12.prod.outlook.com (2603:10b6:8:102::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.639.12; Wed, 25 Nov 2026 18:20:43 +0000 Received: from SJ1PEPF000026C5.namprd04.prod.outlook.com (2603:10b6:510:345:cafe::91) by PH8P220CA0009.outlook.office365.com (2603:10b6:510:345::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.7 via Frontend Transport; Wed, 25 Nov 2026 18:20:42 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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 SJ1PEPF000026C5.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.3 via Frontend Transport; Wed, 25 Nov 2026 18:20:42 +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.2562.57; Wed, 25 Nov 2026 10:20:21 -0800 Received: from localhost (10.126.231.37) 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.2562.57; Wed, 25 Nov 2026 10:20:20 -0800 Date: Wed, 25 Nov 2026 20:20:12 +0200 From: Leon Romanovsky To: Jason Gunthorpe CC: Marek Szyprowski , Sibi Sankar , , , , , , , , , , Subject: Re: [PATCH] Revert "iommu/dma: simplify dma_iova_destroy() and drop the free_iova helper" Message-ID: <20261125182012.GA774860@unreal> References: <20261125135120.1126571-1-sibi.sankar@oss.qualcomm.com> <20261125175547.GM246011@ziepe.ca> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20261125175547.GM246011@ziepe.ca> X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000026C5:EE_|DM4PR12MB7768:EE_ X-MS-Office365-Filtering-Correlation-Id: a0483a18-dea7-4e42-e7a7-08df4b20d0dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|36860700016|376014|7416014|1800799024|82310400026|4143699003|261022105027099003|261026140227099003|11063799006|56012099006|261021121427099003|261102123227099003|10067099003|261009223027099003|261026121527099003|261028144727099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: I5M053D/bKxVqpXSAIGe0+TvJ1koYz/YgXXtfVvNaJlz+sOVF+zpj3Xc4gpZP5yad7B20P3Hi8HE5Zs8ihIPseMTPSX0cCagfEvB6DfGrE6p4dhfYnTgBUvF09BBuFTqU09O/0ZIIg++lZICa/FgBOVjulPhWu4f8UAl3mmISd32mdvXlJUPSopXSkfn+unDKh1Nws+7y7y4rsFIa8Jlop4giIVsvxevdJqZlMELZpO1EB/RcC0NlSw/QioYRxB2JEwzVp2hHdfSHaL9/oXD2nKmSJrveMvYtxndsh6Gr3B0WI/0KBM/d732m6lWHHstwNQr+b3SFCwadDsFbBIB1HSFaszzwB7/CIO/+Vg4/GSX1eTu65Ym5MxoOyfiHKdyxaOiW9tOOaUlL8a68TgcCqLLFM5kBkNZYPiG/F2M1Swm7H8TxpJh2eX//A77y/yG4gQvi7maJmXUzSDC/3x81SBXIcJ8fR1CRGXM/5vaEakjNjN40RxV1eNaf1Ub95zH8uUV6UqvgFhHSHz3Y99aytjxCJGx1SNzUyclLqTkC1gQX/UB+eQIIZ9EM0QFLImOM6qzHIKFJhsjFzOckjl9kiGXXdh5deUUyGXAuGyzqe5YEM/mZSVb8W1Lw/2nllKZhiMDeCpV/W1OoaIXarusCPlKnkyEbpn3Xm/kKsR1bEp/u2x/FF3+A8R0Ro7nFbeQETrYZM2GxBuJAjPafNsJug== 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)(23010399003)(36860700016)(376014)(7416014)(1800799024)(82310400026)(4143699003)(261022105027099003)(261026140227099003)(11063799006)(56012099006)(261021121427099003)(261102123227099003)(10067099003)(261009223027099003)(261026121527099003)(261028144727099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F01kC6OwuE7P9jZL36B58UAz+kOGIgRBj6Fkipwgc35pSPWqUlHz3cRXn9egRan1Cm6QtOgUA81xbeVcFlunyfiDjVt6IEYkRUrZP48GKuPftcBk8A9IuDGicPCLziJMjDds8UuKI46puv10EixhWlw2s1w4enSNUxewrSEejJAFVYWnGdrWzBTwTRFgn4DBO+W3TRcQdz6L79XRhzIpA7ECMgYLfe0F+t++cd/bVVexs5kHxV3iiwkqWBO8LIwrGGuNVApJXysUiSBD9hqrqC4KLhBjQHuQqC3NAtMA3hZky3o2pKHpU4QXWjbynEMzTEGLOLulZiJ5Pk9Mt9s7ae3Sso+g8woJiGgEzFTGN2vacs60s+PLjAWEcr/9/arYTEdtfx2s31QiV90EHrggy4L9yQqmUh0SmuPqfOqAdHLFVUOJyV+1cwik4vyCh+ex X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2026 18:20:42.4742 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0483a18-dea7-4e42-e7a7-08df4b20d0dd 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: SJ1PEPF000026C5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7768 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261125_102052_665284_ABF42AF1 X-CRM114-Status: GOOD ( 28.05 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Nov 25, 2026 at 01:55:47PM -0400, Jason Gunthorpe wrote: > On Wed, Nov 25, 2026 at 06:21:06PM +0100, Marek Szyprowski wrote: > > On 25.11.2026 14:51, Sibi Sankar wrote: > > > This reverts commit 1acce29926d93f3eba427696fe3da6451504dae2. > > > > > > Before this commit, dma_iova_destroy() unmapped through > > > __iommu_dma_iova_unlink(..., free_iova=true), which set > > > iotlb_gather.queued from cookie->fq_domain, skipped iommu_iotlb_sync() > > > and freed the IOVA with the queued gather, exactly like > > > __iommu_dma_unmap(). After it, dma_iova_destroy() calls > > > dma_iova_unlink() and then dma_iova_free(): > > > > > > - dma_iova_unlink() never marks its gather as queued and always calls > > > iommu_iotlb_sync() after iommu_unmap_fast(). > > > - dma_iova_free() passes a NULL gather to iommu_dma_free_iova(), so > > > the IOVA goes straight back to the allocator through > > > free_iova_fast() and never through queue_iova(). > > > > > > DMA-FQ domains therefore get strict invalidation on this path. That > > > includes the block layer's blk_rq_dma_map() path, which NVMe uses for > > > all data transfers, so iommu.strict=0 has no effect on NVMe I/O. > > > > > > hw/sw details: Qualcomm Glymur CRD: SMMUv3 with no RANGE_INV, > > > 4K pages; NVMe SSD on PCIe Gen5 x4 > > > > > > Fio sequential read/write numbers: > > > Domain seq write seq read > > > DMA (strict) 2694 MiB/s 2693 MiB/s > > > DMA-FQ (lazy), flush queue 2707 MiB/s 2803 MiB/s > > > bypassed (this regression) > > > DMA-FQ (lazy), flush queue 10.6 GiB/s 11.9 GiB/s > > > used by dma_iova_destroy() > > > > > > Fixes: 1acce29926d9 ("iommu/dma: simplify dma_iova_destroy() and drop the free_iova helper") > > > Cc: stable@vger.kernel.org # v7.3+ > > > Signed-off-by: Sibi Sankar > > > > > > The performance data clearly shows that the flush queue was there for > > the reason. Together with this revert it would probably make sense to > > apply the v1 of the reverted patch: > > > > https://lore.kernel.org/all/20260701092033.422867-1-honghuan@amd.com/ > > > > Leon, do You see any other option? > > Oh, there are a couple of issues here too, and reverting isn't fixing > the main problem with this.. > > The issue is the assumption we can separate the sync from the free: > > if (!iotlb_gather.queued) > iommu_iotlb_sync(domain, &iotlb_gather); > if (free_iova) > iommu_dma_free_iova(domain, addr, size, &iotlb_gather); > > We cannot. The gather must always be retired, either be calling > iommu_iotlb_sync() or by calling iommu_dma_free_iova(). It can never > just be left dangling. > > Further you can't call iommu_dma_free_iova() with a NULL gather once > unlink has been called. That risks things out of order where the > rbtree can show the freed iova before the associated queued flush has > happened. That is a correctness issue. > > I suppose the resolution here is to feed the gather up the call chain > and allow it to be retired correctly instead of trying to short > circuit it inside the API. I recall trying to cache the gather operation in an earlier revisions of link/unlink series, but that approach was not well received. Thanks > > Jason >