Re: [PATCH v2] iommu/dma: Skip iova_to_phys() on unmap when unneeded
From: Joe Damato
Date: Wed Dec 02 2026 - 12:51:10 EST
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 <robin.murphy@xxxxxxx>
>
> 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.