All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Propagate IOVA allocation failure
@ 2017-05-26 18:31 Robin Murphy
       [not found] ` <8c0c3a31fe97dd57102b35f9be1cd69487ef04a3.1495823154.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Murphy @ 2017-05-26 18:31 UTC (permalink / raw)
  To: joro-zLv9SwRftAIdnm+yROfE0A
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Unlike the old allocator, alloc_iova_fast() will return 0 if it failed
to allocate a PFN. Since the callers of dma_ops_alloc_iova() would end
up treating that as a valid address, translate it to the DMA_ERROR_CODE
that they would expect.

Fixes: 256e4621c21a ("iommu/amd: Make use of the generic IOVA allocator")
Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
---

Just something I spotted whilst comparing dma_map_page() callchains...

 drivers/iommu/amd_iommu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 63cacf5d6cf2..489dc302899e 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1555,6 +1555,9 @@ static unsigned long dma_ops_alloc_iova(struct device *dev,
 	if (!pfn)
 		pfn = alloc_iova_fast(&dma_dom->iovad, pages, IOVA_PFN(dma_mask));
 
+	if (!pfn)
+		return DMA_ERROR_CODE;
+
 	return (pfn << PAGE_SHIFT);
 }
 
-- 
2.12.2.dirty

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

* Re: [PATCH] iommu/amd: Propagate IOVA allocation failure
       [not found] ` <8c0c3a31fe97dd57102b35f9be1cd69487ef04a3.1495823154.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
@ 2017-05-30  9:48   ` Joerg Roedel
       [not found]     ` <20170530094837.GH2818-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2017-05-30  9:48 UTC (permalink / raw)
  To: Robin Murphy; +Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On Fri, May 26, 2017 at 07:31:26PM +0100, Robin Murphy wrote:
> Unlike the old allocator, alloc_iova_fast() will return 0 if it failed
> to allocate a PFN. Since the callers of dma_ops_alloc_iova() would end
> up treating that as a valid address, translate it to the DMA_ERROR_CODE
> that they would expect.
> 
> Fixes: 256e4621c21a ("iommu/amd: Make use of the generic IOVA allocator")
> Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
> ---
> 
> Just something I spotted whilst comparing dma_map_page() callchains...
> 
>  drivers/iommu/amd_iommu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
> index 63cacf5d6cf2..489dc302899e 100644
> --- a/drivers/iommu/amd_iommu.c
> +++ b/drivers/iommu/amd_iommu.c
> @@ -1555,6 +1555,9 @@ static unsigned long dma_ops_alloc_iova(struct device *dev,
>  	if (!pfn)
>  		pfn = alloc_iova_fast(&dma_dom->iovad, pages, IOVA_PFN(dma_mask));
>  
> +	if (!pfn)
> +		return DMA_ERROR_CODE;
> +

That shouldn't make a difference on x86 because the DMA_ERROR_CODE is 0
as well.


	Joerg

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

* Re: [PATCH] iommu/amd: Propagate IOVA allocation failure
       [not found]     ` <20170530094837.GH2818-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
@ 2017-05-30 17:31       ` Robin Murphy
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2017-05-30 17:31 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On 30/05/17 10:48, Joerg Roedel wrote:
> On Fri, May 26, 2017 at 07:31:26PM +0100, Robin Murphy wrote:
>> Unlike the old allocator, alloc_iova_fast() will return 0 if it failed
>> to allocate a PFN. Since the callers of dma_ops_alloc_iova() would end
>> up treating that as a valid address, translate it to the DMA_ERROR_CODE
>> that they would expect.
>>
>> Fixes: 256e4621c21a ("iommu/amd: Make use of the generic IOVA allocator")
>> Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
>> ---
>>
>> Just something I spotted whilst comparing dma_map_page() callchains...
>>
>>  drivers/iommu/amd_iommu.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
>> index 63cacf5d6cf2..489dc302899e 100644
>> --- a/drivers/iommu/amd_iommu.c
>> +++ b/drivers/iommu/amd_iommu.c
>> @@ -1555,6 +1555,9 @@ static unsigned long dma_ops_alloc_iova(struct device *dev,
>>  	if (!pfn)
>>  		pfn = alloc_iova_fast(&dma_dom->iovad, pages, IOVA_PFN(dma_mask));
>>  
>> +	if (!pfn)
>> +		return DMA_ERROR_CODE;
>> +
> 
> That shouldn't make a difference on x86 because the DMA_ERROR_CODE is 0
> as well.

Ha, now that I did manage to overlook. Oh well, never mind then :)

Thanks,
Robin.

> 
> 
> 	Joerg
> 

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

end of thread, other threads:[~2017-05-30 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 18:31 [PATCH] iommu/amd: Propagate IOVA allocation failure Robin Murphy
     [not found] ` <8c0c3a31fe97dd57102b35f9be1cd69487ef04a3.1495823154.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2017-05-30  9:48   ` Joerg Roedel
     [not found]     ` <20170530094837.GH2818-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-05-30 17:31       ` Robin Murphy

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.