Skip to contentSkip to conversation

iommu/dma: fix incorrect error return on iommu deferred attach

PATCH In review Logan Gunthorpe 2 participants 2 messages Oct 27, 2021 – Nov 1, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/dma: fix incorrect error return on iommu deferred attach

scsi_dma_map() was reporting a failure during boot on an AMD machine with the IOMMU enabled.

scsi_dma_map failed: request for 36 bytes!

The issue was tracked down to a mistake in logic: should not return an error if iommu_deferred_attach() returns zero.

Fixes dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()")
Cc Joerg Roedel <[email protected]>
Cc Will Deacon <[email protected]>
---
 drivers/iommu/dma-iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

If possible, this fix should really get into Linus's tree before the v5.15 release.

drivers/iommu/dma-iommu.c +2 -1
index 896bea04c347..3e5a21b0bb24 100644
@@ -1016,7 +1016,8 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,
 
 	if (static_branch_unlikely(&iommu_deferred_attach_enabled)) {
 		ret = iommu_deferred_attach(dev, domain);
-		goto out;
+		if (ret)
+			goto out;
 	}
 
 	if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))

base-commit: 3906fe9bb7f1a2c8667ae54e967dc8690824f4ea --
2.30.2
_______________________________________________
iommu mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Logan Gunthorpe

scsi_dma_map() was reporting a failure during boot on an AMD machine with the IOMMU enabled.

scsi_dma_map failed: request for 36 bytes!

The issue was tracked down to a mistake in logic: should not return an error if iommu_deferred_attach() returns zero.

Quoted 6 lines
Fixes dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()")
Cc Joerg Roedel<[email protected]>
Cc Will Deacon<[email protected]>

Seems reasonable, FWIW:

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu