All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/dma-iommu: Fix wrong scatterlist length assignment in P2PDMA path
@ 2026-05-30 11:28 lirongqing
  2026-06-01 16:02 ` Logan Gunthorpe
  0 siblings, 1 reply; 9+ messages in thread
From: lirongqing @ 2026-05-30 11:28 UTC (permalink / raw)
  To: Robin Murphy, Joerg Roedel, Will Deacon, Lu Baolu,
	Luis Chamberlain, Leon Romanovsky, Logan Gunthorpe, Bjorn Helgaas,
	iommu, linux-kernel
  Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

In iommu_dma_map_sg(), when handling PCI P2PDMA cases, the DMA length
of the current scatterlist segment `s` is incorrectly assigned from the
head entry `sg->length` instead of the current entry `s->length`.

This typo causes all P2PDMA segments in the scatterlist to inherit the
length of the first segment, leading to corrupted DMA lengths for multi-
segment scatterlists.

Fix this by using `s->length` instead of `sg->length`.

Fixes: a25e7962db ("PCI/P2PDMA: Refactor the p2pdma mapping helpers")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/iommu/dma-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 54d96e8..e8d4c2d 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1465,7 +1465,7 @@ int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 			 */
 			s->dma_address = pci_p2pdma_bus_addr_map(
 				p2pdma_state.mem, sg_phys(s));
-			sg_dma_len(s) = sg->length;
+			sg_dma_len(s) = s->length;
 			sg_dma_mark_bus_address(s);
 			continue;
 		default:
-- 
2.9.4


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

end of thread, other threads:[~2026-06-12 13:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-30 11:28 [PATCH] iommu/dma-iommu: Fix wrong scatterlist length assignment in P2PDMA path lirongqing
2026-06-01 16:02 ` Logan Gunthorpe
2026-06-02  6:12   ` 答复: [外部邮件] " Li,Rongqing
2026-06-02  9:48     ` Li,Rongqing
2026-06-02 15:51       ` Logan Gunthorpe
2026-06-02 15:42     ` Logan Gunthorpe
2026-06-11 11:59       ` Jason Gunthorpe
2026-06-11 12:21         ` 答复: " Li,Rongqing
2026-06-12 13:23           ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.