iommu/dma: Fix IOVA reserve dma ranges
Subsystems (2)
PATCH v2 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.
---
Changes from v1:
Removed unnecessary changes based on Robin's review comments.
drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
@@ -217,7 +217,7 @@ 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" );return -EINVAL ;
Signature · 1 line
2.17.1
Quoted 17 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")Signed-off-by Srinath Mannam <[email protected]>---
Changes from v1:
Removed unnecessary changes based on Robin's review comments.drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/dma-iommu.c +0
-0
drivers/iommu/dma-iommu.c static int iova_reserve_pci_windows(struct pci_dev *dev, · line 222
Quoted 7 lines
drivers/iommu/dma-iommu.c +1
-1@@ -217,7 +217,7 @@ 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" );
You didn't actually change the error message, but the message would be way more useful if it included the IOVA address range, e.g., the format used in pci_register_host_bridge():
bus address [%#010llx-%#010llx]
Incidentally, the pr_err() in copy_reserved_iova() looks bogus; it prints iova->pfn_low twice, when it should probably print the base and size or (my preference) something like the above:
pr_err("Reserve iova range %lx@%lx failed\n",
iova->pfn_lo, iova->pfn_lo);
Quoted 4 lines
drivers/iommu/dma-iommu.c +0
-0return -EINVAL ;Signature · 1 line
2.17.1
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 1 line · Bjorn Helgaas
Hi Bjorn,
Thanks for review.
Quoted 13 lines · Srinath Mannam
Quoted 12 lines
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")Signed-off-by Srinath Mannam <[email protected]>---
Changes from v1:
Removed unnecessary changes based on Robin's review comments.drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
drivers/iommu/dma-iommu.c static int iova_reserve_pci_windows(struct pci_dev *dev, · line 222
Quoted 12 lines
drivers/iommu/dma-iommu.c +1
-1@@ -217,7 +217,7 @@ 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" );
It is very unlikely to come to this error, dma_ranges list is sorted in "devm_of_pci_get_host_bridge_resources" function.
Quoted 5 lines
You didn't actually change the error message, but the message would be way more useful if it included the IOVA address range, e.g., the format used in
pci_register_host_bridge():bus address [%#010llx-%#010llx]
I will add this change and send the next patchset.
Thanks & Regards,
Srinath.
Quoted 12 lines
Incidentally, the
pr_err()incopy_reserved_iova()looks bogus; it printsiova->pfn_lowtwice, when it should probably print the base and size or (my preference) something like the above:pr_err("Reserve iova range %lx@%lx failed\n",
iova->pfn_lo,iova->pfn_lo);Quoted 4 lines
drivers/iommu/dma-iommu.c +0
-1return -EINVAL ; --2.17.1
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu