iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] iommu/dma: Fix IOVA reserve dma ranges
@ 2020-09-14  7:23 Srinath Mannam via iommu
  2021-06-02 20:18 ` Sven Peter via iommu
  2021-06-04 15:33 ` Joerg Roedel
  0 siblings, 2 replies; 4+ messages in thread
From: Srinath Mannam via iommu @ 2020-09-14  7:23 UTC (permalink / raw)
  To: Robin Murphy, Joerg Roedel, Lorenzo Pieralisi, Bjorn Helgaas, poza
  Cc: Srinath Mannam, iommu, bcm-kernel-feedback-list, linux-kernel

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 <srinath.mannam@broadcom.com>
---
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(-)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 5141d49a046b..5b9791f35c5e 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -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;
 		}
 
-- 
2.17.1

_______________________________________________
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 v3] iommu/dma: Fix IOVA reserve dma ranges
  2020-09-14  7:23 [PATCH v3] iommu/dma: Fix IOVA reserve dma ranges Srinath Mannam via iommu
@ 2021-06-02 20:18 ` Sven Peter via iommu
  2021-06-03 11:00   ` Robin Murphy
  2021-06-04 15:33 ` Joerg Roedel
  1 sibling, 1 reply; 4+ messages in thread
From: Sven Peter via iommu @ 2021-06-02 20:18 UTC (permalink / raw)
  To: Srinath Mannam, Robin Murphy, Joerg Roedel, Lorenzo Pieralisi,
	Bjorn Helgaas, poza
  Cc: iommu, bcm-kernel-feedback-list, linux-kernel

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.

Tested-by: Sven Peter <sven@svenpeter.dev>


Best,


Sven


On Mon, Sep 14, 2020, at 09:23, Srinath Mannam via iommu wrote:
> 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 <srinath.mannam@broadcom.com>
> ---
> 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(-)
> 
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 5141d49a046b..5b9791f35c5e 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -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;
>  		}
>  
> -- 
> 2.17.1
> 
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
> 
> 
_______________________________________________
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 v3] iommu/dma: Fix IOVA reserve dma ranges
  2021-06-02 20:18 ` Sven Peter via iommu
@ 2021-06-03 11:00   ` Robin Murphy
  0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2021-06-03 11:00 UTC (permalink / raw)
  To: Sven Peter, Srinath Mannam, Joerg Roedel, Lorenzo Pieralisi,
	Bjorn Helgaas, poza
  Cc: iommu, bcm-kernel-feedback-list, linux-kernel

On 2021-06-02 21:18, Sven Peter wrote:
> 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,

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Tested-by: Sven Peter <sven@svenpeter.dev>
> 
> 
> Best,
> 
> 
> Sven
> 
> 
> On Mon, Sep 14, 2020, at 09:23, Srinath Mannam via iommu wrote:
>> 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 <srinath.mannam@broadcom.com>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
>> index 5141d49a046b..5b9791f35c5e 100644
>> --- a/drivers/iommu/dma-iommu.c
>> +++ b/drivers/iommu/dma-iommu.c
>> @@ -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;
>>   		}
>>   
>> -- 
>> 2.17.1
>>
>> _______________________________________________
>> iommu mailing list
>> iommu@lists.linux-foundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/iommu
>>
>>
_______________________________________________
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 v3] iommu/dma: Fix IOVA reserve dma ranges
  2020-09-14  7:23 [PATCH v3] iommu/dma: Fix IOVA reserve dma ranges Srinath Mannam via iommu
  2021-06-02 20:18 ` Sven Peter via iommu
@ 2021-06-04 15:33 ` Joerg Roedel
  1 sibling, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2021-06-04 15:33 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: poza, linux-kernel, iommu, bcm-kernel-feedback-list,
	Bjorn Helgaas, Robin Murphy

On Mon, Sep 14, 2020 at 12:53:19PM +0530, Srinath Mannam wrote:
> 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 <srinath.mannam@broadcom.com>
> ---
> 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(-)

Applied, thanks.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, other threads:[~2021-06-04 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14  7:23 [PATCH v3] iommu/dma: Fix IOVA reserve dma ranges Srinath Mannam via iommu
2021-06-02 20:18 ` Sven Peter via iommu
2021-06-03 11:00   ` Robin Murphy
2021-06-04 15:33 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).