]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/pages: Fix iommu_pages_flush_incoherent() for non-x86
authorMostafa Saleh <smostafa@google.com>
Fri, 24 Apr 2026 11:50:51 +0000 (11:50 +0000)
committerJoerg Roedel <joerg.roedel@amd.com>
Mon, 27 Apr 2026 11:59:36 +0000 (13:59 +0200)
The dma_sync_single_for_device() function expects a dma_addr_t, but
iommu_pages_flush_incoherent() was incorrectly passing a virtual
address.

Since iommu_pages_start_incoherent() enforces a 1:1 mapping between
DMA addresses and physical addresses (checked via WARN_ON), we can
convert the virtual address to a physical address before passing it to
the DMA API.

This also  matches the behaviour of the other non-x86 in
iommu_pages_free_incoherent(), which uses virt_to_phys(virt);

Fixes: 36ae67b13976 ("iommu/pages: Add support for incoherent IOMMU page table walkers")
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/iommu-pages.h

index ae9da4f571f614fc5d240c73449e508d54aee693..e9e605b5fa3afc5084273c0af7a1bfeb142c2e0f 100644 (file)
@@ -137,7 +137,7 @@ static inline void iommu_pages_flush_incoherent(struct device *dma_dev,
                                                void *virt, size_t offset,
                                                size_t len)
 {
-       dma_sync_single_for_device(dma_dev, (uintptr_t)virt + offset, len,
+       dma_sync_single_for_device(dma_dev, virt_to_phys(virt) + offset, len,
                                   DMA_TO_DEVICE);
 }
 void iommu_pages_stop_incoherent_list(struct iommu_pages_list *list,