iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range
       [not found] <20210126045404.2492588-1-npiggin@gmail.com>
@ 2021-01-26  4:54 ` Nicholas Piggin
  2021-01-26  6:38   ` Christoph Hellwig
  2021-01-26 22:08   ` Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 5+ messages in thread
From: Nicholas Piggin @ 2021-01-26  4:54 UTC (permalink / raw)
  To: linux-mm, Andrew Morton
  Cc: linux-kernel, Nicholas Piggin, iommu, Robin Murphy, Christoph Hellwig

vunmap will remove ptes.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: iommu@lists.linux-foundation.org
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 kernel/dma/remap.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c
index 905c3fa005f1..b4526668072e 100644
--- a/kernel/dma/remap.c
+++ b/kernel/dma/remap.c
@@ -66,6 +66,5 @@ void dma_common_free_remap(void *cpu_addr, size_t size)
 		return;
 	}
 
-	unmap_kernel_range((unsigned long)cpu_addr, PAGE_ALIGN(size));
 	vunmap(cpu_addr);
 }
-- 
2.23.0

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

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

* Re: [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range
  2021-01-26  4:54 ` [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range Nicholas Piggin
@ 2021-01-26  6:38   ` Christoph Hellwig
  2021-01-26 22:08   ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-01-26  6:38 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: linux-kernel, linux-mm, iommu, Andrew Morton, Robin Murphy,
	Christoph Hellwig

On Tue, Jan 26, 2021 at 02:54:01PM +1000, Nicholas Piggin wrote:
> vunmap will remove ptes.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range
  2021-01-26  4:54 ` [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range Nicholas Piggin
  2021-01-26  6:38   ` Christoph Hellwig
@ 2021-01-26 22:08   ` Konrad Rzeszutek Wilk
  2021-01-27  7:10     ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2021-01-26 22:08 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: linux-kernel, linux-mm, iommu, Andrew Morton, Robin Murphy,
	Christoph Hellwig

On Tue, Jan 26, 2021 at 02:54:01PM +1000, Nicholas Piggin wrote:
> vunmap will remove ptes.

Should there be some ASSERT after the vunmap to make sure that is the
case? 
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: iommu@lists.linux-foundation.org
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  kernel/dma/remap.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c
> index 905c3fa005f1..b4526668072e 100644
> --- a/kernel/dma/remap.c
> +++ b/kernel/dma/remap.c
> @@ -66,6 +66,5 @@ void dma_common_free_remap(void *cpu_addr, size_t size)
>  		return;
>  	}
>  
> -	unmap_kernel_range((unsigned long)cpu_addr, PAGE_ALIGN(size));
>  	vunmap(cpu_addr);
>  }
> -- 
> 2.23.0
> 
> _______________________________________________
> 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] 5+ messages in thread

* Re: [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range
  2021-01-26 22:08   ` Konrad Rzeszutek Wilk
@ 2021-01-27  7:10     ` Christoph Hellwig
  2021-01-27 23:44       ` Nicholas Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-01-27  7:10 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: linux-kernel, Nicholas Piggin, linux-mm, iommu, Andrew Morton,
	Robin Murphy, Christoph Hellwig

On Tue, Jan 26, 2021 at 05:08:46PM -0500, Konrad Rzeszutek Wilk wrote:
> On Tue, Jan 26, 2021 at 02:54:01PM +1000, Nicholas Piggin wrote:
> > vunmap will remove ptes.
> 
> Should there be some ASSERT after the vunmap to make sure that is the
> case? 

Not really.  removing the PTEs is the whole point of vunmap.  Everything
else is just house keeping.

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

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

* Re: [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range
  2021-01-27  7:10     ` Christoph Hellwig
@ 2021-01-27 23:44       ` Nicholas Piggin
  0 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2021-01-27 23:44 UTC (permalink / raw)
  To: Christoph Hellwig, Konrad Rzeszutek Wilk
  Cc: linux-mm, Andrew Morton, Robin Murphy, iommu, linux-kernel

Excerpts from Christoph Hellwig's message of January 27, 2021 5:10 pm:
> On Tue, Jan 26, 2021 at 05:08:46PM -0500, Konrad Rzeszutek Wilk wrote:
>> On Tue, Jan 26, 2021 at 02:54:01PM +1000, Nicholas Piggin wrote:
>> > vunmap will remove ptes.
>> 
>> Should there be some ASSERT after the vunmap to make sure that is the
>> case? 
> 
> Not really.  removing the PTEs is the whole point of vunmap.  Everything
> else is just house keeping.

Agree. I did double check this and wrote a quick test to check ptes were 
there before the vunmap and cleared after, just to make sure I didn't 
make a silly mistake with the patch. But in general drivers should be 
able to trust code behind the API call will do the right thing. Such 
assertions should go in the vunmap() implementation as appropriate.

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

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

end of thread, other threads:[~2021-01-27 23:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210126045404.2492588-1-npiggin@gmail.com>
2021-01-26  4:54 ` [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range Nicholas Piggin
2021-01-26  6:38   ` Christoph Hellwig
2021-01-26 22:08   ` Konrad Rzeszutek Wilk
2021-01-27  7:10     ` Christoph Hellwig
2021-01-27 23:44       ` Nicholas Piggin

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).