public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/pages: Fix iommu_pages_flush_incoherent() for non-x86
@ 2026-04-24 11:50 Mostafa Saleh
  2026-04-24 13:07 ` Jason Gunthorpe
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mostafa Saleh @ 2026-04-24 11:50 UTC (permalink / raw)
  To: iommu, linux-kernel
  Cc: joro, robin.murphy, will, jgg, baolu.lu, kevin.tian,
	Mostafa Saleh

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>
---
 drivers/iommu/iommu-pages.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h
index ae9da4f571f6..e9e605b5fa3a 100644
--- a/drivers/iommu/iommu-pages.h
+++ b/drivers/iommu/iommu-pages.h
@@ -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,
-- 
2.54.0.rc2.544.gc7ae2d5bb8-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-27 11:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 11:50 [PATCH] iommu/pages: Fix iommu_pages_flush_incoherent() for non-x86 Mostafa Saleh
2026-04-24 13:07 ` Jason Gunthorpe
2026-04-25  5:36 ` Pranjal Shrivastava
2026-04-27  2:50 ` Baolu Lu
2026-04-27 11:59 ` Jörg Rödel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox