From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796233868; b=CQex51dIfXZ1C2AAqirgphJOfzve1J9r+J24+tdb9CoEeIffEGTncKOFArmkFAegMjXE +ARNDtlLYFNEqfTYN6A1ACVhJEtDXKcbZYGwlQR5SVW7BuKqLXbKEr5+Wr/umzZeNthJj TIx5ZCEiLI7Ge9AZbhjFb7a7klt3Hhuaz49kpYEEgm0Exp6E+mIoqkGHrbKuu5k93q34W qwIAzc13xwXanxZXhBN480jt2EjL3ZToEYRSkE1wD6UB6vokit8De0EfzdmY1leL2g++D 1v2ajVecq00TInV6Nw72g+/nFoaDpuV5xPSzOlow+U0afvYBQoZiFzPMRJ0NcvblxiA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796233868; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=o/CTlF/i3MmvrOhIsYrSeMJHrlcnRXNY2igRqXLW11Y=; b=OVLDGmY7hmCGuGyQQZ3fIleU3KyUFvNvCo0lpnllcW5oDukdKspF6K0QI3ktdAy06OGJ 9Gug/qH2gvYFlUi2qgqN4F+Zrs5Dv7lJ43BzuSqwZVETubCaCFfUgipWwq7CcLkmBA4Zm QxOCtDZ2KDS0/jJqo3Q2Np1Nnhce7ehAjGn+o7b8OPjaOPSVRoYS7htUf+jPLCg75b9hK EHEHprI1Pdf0E77MR4Zq4LSBa24FWZG0hw9TvMPJODPGFXGhR+Qj5lvaFDxsu4zxtqSNs zPZdfgcAaqiU1n2hcbXDst8oQrCIgzFAcGiTGJoa2HQlMoXbZmlqJiL2QufO+GnKS5g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=dama.to; spf=none smtp.mailfrom=dama.to; dkim=pass header.d=dama-to.20260707.gappssmtp.com header.i=@dama-to.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=KxJLlI4p; arc=none smtp.remote-ip=209.85.216.50 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8905606A32C for ; Wed, 2 Dec 2026 17:51:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8905606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dama.to Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=dama.to Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=dama-to.20260707.gappssmtp.com header.i=@dama-to.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=KxJLlI4p Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-3b0e0e65adbso5966587a91.3 for ; Wed, 02 Dec 2026 09:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dama-to.20260707.gappssmtp.com; s=20260707; t=1796233862; x=1796838662; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=o/CTlF/i3MmvrOhIsYrSeMJHrlcnRXNY2igRqXLW11Y=; b=KxJLlI4pUpaYJFg2LXoShojI++kWdAGyeT+wlp43IOXCOVqADCuxPGByLaYhC8jcmg uj3NyubcjY91jBeYdls1fPzyqtMdzx+m7fFkPgJXJc1hB52ET3lpUO+4nEOXEPJrQfa/ HG65JZc8340Fyyb3GwaHATp1NPXH8AjRpw92Utwqz/5B4SJ0Gm8s8/E7ThckKXUqN5dl A4fTtA96xrDp2JcJnX+EFwBqZlKCWqrR3Szg3z08o5DyGhIDPpQmEnQCDcMO/wLq08eN 2hb5FcwsnUSehCWUXUCTFEOJ8xPYtJd0itHWFE+vyjtibe3Oodyc4L5yDGs7ibMzvKp7 qZfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796233862; x=1796838662; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=o/CTlF/i3MmvrOhIsYrSeMJHrlcnRXNY2igRqXLW11Y=; b=xp1W1wqJydnNK/cfBYeOFHSZIehWLRxMG5Nt/gmfkkDWj/4SnQLUnkcU/3jIRdgBkS 2TivRm4Dzl3mKYgOfFXI3JWzDFdq/KLWRUZBXUHg0bGDlEpAaA1nf5JunrjQFOCC5hkz TKQ5fQCCKlW5rmy8+wS8HNA/Ix6ldY4+nTGqOK9pRgnGBFJJcQ5k0XbY/c7Gca1HSsFC wbIAENEV2PqA++1dKIXdpj8syupSpJlEV50kKplTDDQSF+Yhpz/+03ZXAoMPjLd0Ov3e 0yYqxqhRZ6354Kj5xW1DYKdqMUX0epkTgQVgNeM1hyK5U8hn4A1dtepOfWxY5mM3XMA1 7fsA== X-Forwarded-Encrypted: i=1; AL+hErE/g0yfxGt7meI/1L76rFtgFZpO0FlzBgJLuKRT44AvjavU1XSAwsV0KFKdIk2Kwz1yJzi0g7PmeFepeD8=@vger.kernel.org X-Gm-Message-State: APuU4Z8mHyLERZwETmvBo435s+Y9j2rbEVKhAqWGe+a9RqmJqDvdq05A l2bWv+RGsk8nVf+9HXCbJqdeQ+c+ZUaGVcNgXspt8rNBT2q5akoxu3ubtVCGyp3cm74= X-Gm-Gg: AZFdTZeX4ykkhucHa+hc8DfL/Lf0kgkqudKJuide7QOVlCqd45iEEPgYI+WoSCQOHBI 7IXSQSNg3jqgO07m5bDLH+9FHpTWoTMIHvUtS7WKmlR+vFg2bKXMPeoXPf5l7HbYuU19uM761a7 Bkn/6M6DvS28bQWq1WXTyWM+DGIotNvqFND2xPT+89vUs9qHkvVUTO1BDJbByYBMOzs7TfnixIE r8dRwc3VPAi46Gze/zASv2R+XnfdoawmOiM6GCHerJLzWYrbi8HLcazSQIzKpxi8rcrsGWJ6GOV 7UPlUtOm/f6tfZr8rZ0N5hdjl+gEAaWstDhGF/PIefDsmellDAg/BFv1dwLRdpIFf+AI8HIMJxf 3JXM5cWV+gWPxCai7d4/MPmgxnd5RiHMOzgRqls10Jr01LTDsZl/oMXRlyIEqRD4sUsdSzaXin+ aEydNprEnTqNoIBP+rcayc2cJQIbn+uGf3LMrnDjvEsnGBDm6dF1ZUa/WP+1Fir/ArthZyoGxgU h7xFonVAp1tXIL7xmmiEgRn+ySL+5kLathEsqr5jm9O94ZFj1PrdFhPeOruD4fUYvr/gSvTDmI4 gB5ybaT5ji42BeQ/u6UgwQrAqt80zyDDutuRjOtP X-Received: by 2002:a17:90b:2d8a:b0:3ab:189b:6981 with SMTP id 98e67ed59e1d1-3b41c953639mr40918828a91.48.1796233861768; Wed, 02 Dec 2026 09:51:01 -0800 (PST) Received: from localhost ([2a03:2880:2ff:6::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c764a033sm224219a91.1.2026.12.02.09.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 09:51:00 -0800 (PST) Date: Wed, 2 Dec 2026 09:50:59 -0800 From: Joe Damato To: Robin Murphy Cc: "Joerg Roedel (AMD)" , Will Deacon , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iommu/dma: Skip iova_to_phys() on unmap when unneeded Message-ID: References: <20261202153325.2819538-1-joe@dama.to> <38e90198-68c0-4cb3-959b-4f4c7759a18d@arm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <38e90198-68c0-4cb3-959b-4f4c7759a18d@arm.com> On Wed, Dec 02, 2026 at 04:36:27PM +0000, Robin Murphy wrote: > On 02/12/2026 3:33 pm, Joe Damato wrote: > > iommu_dma_unmap_phys() looks up the physical address of every mapping > > with iommu_iova_to_phys() before unmapping it. > > > > This is unneeded for a coherent device that does not use a swiotlb. > > Skipping this saves a page table walk. > > > > iommu_dma_sync_single_for_cpu() already skips the walk for these > > devices, so do the same in iommu_dma_unmap_phys(). > > > > For these devices the WARN_ON(!phys) is no longer reached, so unmapping > > an IOVA that is not mapped no longer warns there. CONFIG_DMA_API_DEBUG > > still catches this class of driver bug. > > Thanks Joe! > > Acked-by: Robin Murphy > > Although now I've made the mistake of remembering we have the higher-level > dma_dev_need_sync() thing as well, and starting to wonder how much that now > might effectively cover these conditions both here and for > iommu_dma_sync_single*()... I see what you mean. I did not know about that before, my bad. Your call: I would be happy to send a followup cleaning up all of those sites to use dma_dev_need_sync once the patch above is applied or If you prefer, I can send a v3 as a single patch that cleans up the existing sites and inserts the call in unmap.