From mboxrd@z Thu Jan 1 00:00:00 1970 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 BBC0CD6AAE6 for ; Thu, 2 Apr 2026 15:49:27 +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: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-Owner; bh=oUBZ8LHrLBmMldmlkg0IxYXlcz4TIbmGgxhLQM0d8KQ=; b=mqMKoYm3wdhIbEVjT6fXbvKC70 Xna2ATBLY6cZP6tHguc8LqnxkP48mq9x6RtS/7xKL41CLCkWt05iD5NEU9JplXjF275qmj9G35WOR zfhPKkemWwyq+Kk/ve+6W24CcbjZjw74LqTViYFJMyrtCSOb6xMhErnTZlXBLmk+Ul8XyWWjMm84i U63L3PKOhwU2Y2bWO0MWo8FsH7IeEmTEC1TQ8DZoqgmuNd9f03/sb3tyVD9k/CJV6B50JGLf3jfh4 BxP+t7AT9ZgTO/1MJJFVrXRXedIYHDIIBnCXH2JS+KVit1+CyS0lLz58k38EX0jSnm4kQTu7zz8L2 msumJ31Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w8KIN-00000000T1X-0CPi; Thu, 02 Apr 2026 15:49:23 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w8KIK-00000000T0k-0CCo; Thu, 02 Apr 2026 15:49:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 49FF24408A; Thu, 2 Apr 2026 15:49:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4634CC19423; Thu, 2 Apr 2026 15:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775144959; bh=ETKq7zpXTNX+jfpHKOz+WPkBvuAndyFKqifyTs989fQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vDcw1prILIQAXHJowYDTJb6Nn1rk2kMRffrcqcdVG1vKoLbLy61HSdGnHVqlkKx4q ylg/MMGiQlKZe28tTkDSkOan0AGo1g+dPj/2nlK4S1pZ/d6kp0OuWyo/d0fkH2NCF6 xDn8/HO4hkB4cT2GGVpv80jHaaYSdWeTyjMVyo1o= Date: Thu, 2 Apr 2026 17:49:10 +0200 From: Greg KH To: Jason Gunthorpe Cc: Alexandre Ghiti , AngeloGioacchino Del Regno , Albert Ou , asahi@lists.linux.dev, Baolin Wang , iommu@lists.linux.dev, Janne Grunau , Jernej Skrabec , Joerg Roedel , Jean-Philippe Brucker , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-riscv@lists.infradead.org, linux-sunxi@lists.linux.dev, Matthias Brugger , Neal Gompa , Orson Zhai , Palmer Dabbelt , Paul Walmsley , Samuel Holland , Sven Peter , virtualization@lists.linux.dev, Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang , Lu Baolu , Janusz Krzysztofik , Joerg Roedel , Jon Hunter , patches@lists.linux.dev, Pranjal Shrivastava , Robin Murphy , Samiullah Khawaja , stable@vger.kernel.org, Vasant Hegde Subject: Re: [PATCH v2] iommu: Always fill in gather when unmapping Message-ID: <2026040202-uneaten-nutrient-b6e1@gregkh> References: <0-v2-b24668f107b2+11bbe-iommu_gather_always_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0-v2-b24668f107b2+11bbe-iommu_gather_always_jgg@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260402_084920_160312_25145162 X-CRM114-Status: GOOD ( 23.86 ) 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 On Thu, Apr 02, 2026 at 11:25:16AM -0300, Jason Gunthorpe wrote: > The fixed commit assumed that the gather would always be populated if an > iotlb_sync was required. > > arm-smmu-v3, amd, VT-d, riscv, s390, and mtk all use information from the > gather during their iotlb_sync() and this approach works for them. > > However, arm-smmu, qcom_iommu, ipmmu-vmsa, sun50i, sprd, virtio, and > apple-dart all ignore the gather during their iotlb_sync(). They mostly > issue a full flush. > > Unfortunately the latter set of drivers often don't bother to add anything > to the gather since they don't intend on using it. Since the core code now > blocks gathers that were never filled, this caused those drivers to stop > getting their iotlb_sync() calls and breaks them. > > Since it is impossible to tell the difference between gathers that are > empty because there is nothing to do and gathers that are empty because > they are not used, fill in the gathers for the missing cases. > > mtk uses io-pgtable-arm-v7s but added the range to the gather in the unmap > callback. Move this into the io-pgtable-arm-v7s unmap itself. That will > fix all the armv7 using drivers (arm-smmu, qcom_iommu, ipmmu-vmsa). > > io-pgtable-arm needs to accommodate drivers like arm-smmu that don't want > to use the gather by just adding a simple range, and drivers like SMMUv3 > that need to use gather->pgsize and also have a disjoint check. Move > SMMUv3 to a new tlb_add_range() op which replaces calling > iommu_iotlb_gather_add_page() in a loop with a single call to update the > gather with the range and required pgsize. > > iommu_iotlb_gather_add_page() is repurposed since nothing but SMMUv3 uses it > now that amd, VT-d and riscv are using iommupt. > > Add a trivial gather population to io-pgtable-dart. > > Add trivial populations to sprd, sun50i and virtio-iommu in their unmap > functions. > > Fixes: 90c5def10bea ("iommu: Do not call drivers for empty gathers") > Reported-by: Jon Hunter > Closes: https://lore.kernel.org/r/8800a38b-8515-4bbe-af15-0dae81274bf7@nvidia.com > Tested-by: Jon Hunter > Acked-by: Pranjal Shrivastava > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 ++++++----- > drivers/iommu/io-pgtable-arm-v7s.c | 4 ++++ > drivers/iommu/io-pgtable-arm.c | 19 ++++++++++++++++--- > drivers/iommu/io-pgtable-dart.c | 3 +++ > drivers/iommu/mtk_iommu.c | 1 - > drivers/iommu/sprd-iommu.c | 1 + > drivers/iommu/sun50i-iommu.c | 1 + > drivers/iommu/virtio-iommu.c | 2 ++ > include/linux/io-pgtable.h | 3 +++ > include/linux/iommu.h | 19 ++++++++++--------- > 10 files changed, 46 insertions(+), 18 deletions(-) > This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.