All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/dma: fix incorrect error return on iommu deferred attach
@ 2021-10-27 17:47 ` Logan Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2021-10-27 17:47 UTC (permalink / raw)
  To: linux-kernel, iommu, Christoph Hellwig
  Cc: Logan Gunthorpe, Marshall Midden, Joerg Roedel, Will Deacon

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.

Reported-by: Marshall Midden <marshallmidden@gmail.com>
Fixes: dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()")
Link: https://lore.kernel.org/all/CAD2CkAWjS8=kKwEEN4cgVNjyFORUibzEiCUA-X+SMtbo0JoMmA@mail.gmail.com
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Will Deacon <will@kernel.org>
---
 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.

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 896bea04c347..3e5a21b0bb24 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -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

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

* [PATCH] iommu/dma: fix incorrect error return on iommu deferred attach
@ 2021-10-27 17:47 ` Logan Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2021-10-27 17:47 UTC (permalink / raw)
  To: linux-kernel, iommu, Christoph Hellwig
  Cc: Will Deacon, Marshall Midden, 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.

Reported-by: Marshall Midden <marshallmidden@gmail.com>
Fixes: dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()")
Link: https://lore.kernel.org/all/CAD2CkAWjS8=kKwEEN4cgVNjyFORUibzEiCUA-X+SMtbo0JoMmA@mail.gmail.com
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Will Deacon <will@kernel.org>
---
 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.

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 896bea04c347..3e5a21b0bb24 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -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
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH] iommu/dma: fix incorrect error return on iommu deferred attach
  2021-10-27 17:47 ` Logan Gunthorpe
@ 2021-11-01  9:21   ` John Garry
  -1 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2021-11-01  9:21 UTC (permalink / raw)
  To: Logan Gunthorpe, linux-kernel, iommu, Christoph Hellwig
  Cc: Marshall Midden, Will Deacon

On 27/10/2021 18:47, Logan Gunthorpe wrote:
> 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.
> 
> Reported-by: Marshall Midden<marshallmidden@gmail.com>
> Fixes: dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()")
> Link:https://lore.kernel.org/all/CAD2CkAWjS8=kKwEEN4cgVNjyFORUibzEiCUA-X+SMtbo0JoMmA@mail.gmail.com
> Signed-off-by: Logan Gunthorpe<logang@deltatee.com>
> Cc: Joerg Roedel<joro@8bytes.org>
> Cc: Will Deacon<will@kernel.org>

Seems reasonable, FWIW:
Reviewed-by: John Garry <john.garry@huawei.com>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH] iommu/dma: fix incorrect error return on iommu deferred attach
@ 2021-11-01  9:21   ` John Garry
  0 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2021-11-01  9:21 UTC (permalink / raw)
  To: Logan Gunthorpe, linux-kernel, iommu, Christoph Hellwig
  Cc: Will Deacon, Marshall Midden

On 27/10/2021 18:47, Logan Gunthorpe wrote:
> 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.
> 
> Reported-by: Marshall Midden<marshallmidden@gmail.com>
> Fixes: dabb16f67215 ("iommu/dma: return error code from iommu_dma_map_sg()")
> Link:https://lore.kernel.org/all/CAD2CkAWjS8=kKwEEN4cgVNjyFORUibzEiCUA-X+SMtbo0JoMmA@mail.gmail.com
> Signed-off-by: Logan Gunthorpe<logang@deltatee.com>
> Cc: Joerg Roedel<joro@8bytes.org>
> Cc: Will Deacon<will@kernel.org>

Seems reasonable, FWIW:
Reviewed-by: John Garry <john.garry@huawei.com>

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

end of thread, other threads:[~2021-11-01  9:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 17:47 [PATCH] iommu/dma: fix incorrect error return on iommu deferred attach Logan Gunthorpe
2021-10-27 17:47 ` Logan Gunthorpe
2021-11-01  9:21 ` John Garry
2021-11-01  9:21   ` John Garry

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.