Skip to contentSkip to conversation

iommu/dma: Fix IOVA reserve dma ranges

PATCH Applied Srinath Mannam 4 participants 4 messages Sep 14, 2020 – Jun 4, 2021

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

PATCH v3 1/1 iommu/dma: Fix IOVA reserve dma ranges

Fix IOVA reserve failure in the case when address of first memory region listed in dma-ranges is equal to 0x0.

Fixes aadad097cd46f ("iommu/dma: Reserve IOVA for PCIe inaccessible DMA address")

---
Changes from v2:
Modify error message with useful information based on Bjorn's comments.

Changes from v1:
Removed unnecessary changes based on Robin's review comments.

 drivers/iommu/dma-iommu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +4 -2
index 5141d49a046b..5b9791f35c5e 100644
@@ -217,9 +217,11 @@ static int iova_reserve_pci_windows(struct pci_dev *dev,
 			lo = iova_pfn(iovad, start);
 			hi = iova_pfn(iovad, end);
 			reserve_iova(iovad, lo, hi);
-		} else {
+		} else if (end < start) {
 			/* dma_ranges list should be sorted */
-			dev_err(&dev->dev, "Failed to reserve IOVA\n");
+			dev_err(&dev->dev,
+				"Failed to reserve IOVA [%#010llx-%#010llx]\n",
+				start, end);
 			return -EINVAL;
 		}
 
Signature · 1 line
2.17.1
Tested-by on v3 1/1
#1 lore raw

Hi,

I just ran into the exact same issue while working on the M1 DART IOMMU driver and it was fixed by this commit. Thanks!

Would be great if this could be picked up.

Best,

Sven

Quoted 44 lines · Srinath Mannam via iommu

Fix IOVA reserve failure in the case when address of first memory region listed in dma-ranges is equal to 0x0.

Fixes aadad097cd46f ("iommu/dma: Reserve IOVA for PCIe inaccessible

DMA address")

---
Changes from v2:
Modify error message with useful information based on Bjorn's
comments.

Changes from v1:
Removed unnecessary changes based on Robin's review comments.

 drivers/iommu/dma-iommu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +4 -2
index 5141d49a046b..5b9791f35c5e 100644
@@ -217,9 +217,11 @@ static int iova_reserve_pci_windows(struct pci_dev *dev,
 			lo = iova_pfn(iovad, start);
 			hi = iova_pfn(iovad, end);
 			reserve_iova(iovad, lo, hi);
-		} else {
+		} else if (end < start) {
 			/* dma_ranges list should be sorted */
-			dev_err(&dev->dev, "Failed to reserve IOVA\n");
+			dev_err(&dev->dev,
+				"Failed to reserve IOVA [%#010llx-%#010llx]\n",
+				start, end);
 			return -EINVAL;
 		}
 
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer Reviewed-by
#2 lore raw
Quoted 6 lines · Sven Peter

Hi,

I just ran into the exact same issue while working on the M1 DART IOMMU driver and it was fixed by this commit. Thanks!

Would be great if this could be picked up.

Oops, apparently I was happy enough with this 9 months ago to forget about it, so if it helps,

Quoted 54 lines

Best,

Sven

Quoted 44 lines · Srinath Mannam via iommu

Fix IOVA reserve failure in the case when address of first memory region listed in dma-ranges is equal to 0x0.

Fixes aadad097cd46f ("iommu/dma: Reserve IOVA for PCIe inaccessible

DMA address")

---
Changes from v2:
Modify error message with useful information based on Bjorn's
comments.

Changes from v1:
Removed unnecessary changes based on Robin's review comments.

  drivers/iommu/dma-iommu.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +4 -2
index 5141d49a046b..5b9791f35c5e 100644
@@ -217,9 +217,11 @@ static int iova_reserve_pci_windows(struct pci_dev *dev,
  			lo = iova_pfn(iovad, start);
  			hi = iova_pfn(iovad, end);
  			reserve_iova(iovad, lo, hi);
-		} else {
+		} else if (end < start) {
  			/* dma_ranges list should be sorted */
-			dev_err(&dev->dev, "Failed to reserve IOVA\n");
+			dev_err(&dev->dev,
+				"Failed to reserve IOVA [%#010llx-%#010llx]\n",
+				start, end);
  			return -EINVAL;
  		}
 
Signature · 6 lines
2.17.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer Applied
#3 lore raw
In reply to Srinath Mannam
Quoted 9 lines · Srinath Mannam

Fix IOVA reserve failure in the case when address of first memory region listed in dma-ranges is equal to 0x0.

Fixes aadad097cd46f ("iommu/dma: Reserve IOVA for PCIe inaccessible DMA address")

---
Changes from v2:
Modify error message with useful information based on Bjorn's comments.

Quoted 5 lines

Changes from v1:
Removed unnecessary changes based on Robin's review comments.

 drivers/iommu/dma-iommu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Applied, thanks.