linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* document dma-direct zone selection
@ 2018-10-01 20:10 Christoph Hellwig
  2018-10-01 20:10 ` [PATCH] dma-direct: document the zone selection logic Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-01 20:10 UTC (permalink / raw)
  To: iommu
  Cc: Marek Szyprowski, Robin Murphy, Benjamin Herrenschmidt, linux-kernel

Hi all,

this patch documents the dma-direct zone selection, as it doesn't
seem quite obvuious enough.

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

* [PATCH] dma-direct: document the zone selection logic
  2018-10-01 20:10 document dma-direct zone selection Christoph Hellwig
@ 2018-10-01 20:10 ` Christoph Hellwig
  2018-10-01 20:22   ` Randy Dunlap
  2018-10-08  7:03   ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-01 20:10 UTC (permalink / raw)
  To: iommu
  Cc: Marek Szyprowski, Robin Murphy, Benjamin Herrenschmidt, linux-kernel

What we are doing here isn't quite obvious, so add a comment explaining
it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 kernel/dma/direct.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index ba6f5956a291..14b966e2349a 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -84,7 +84,14 @@ static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
 	else
 		*phys_mask = dma_to_phys(dev, dma_mask);
 
-	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
+	/*
+	 * Optimistically try the zone that the physicall address mask falls
+	 * into first.  If that returns memory that isn't actually addressable
+	 * we will fallback to the next lower zone and try again.
+	 *
+	 * Note that GFP_DMA32 and GFP_DMA are no ops without the corresponding
+	 * zones.
+	 */
 	if (*phys_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
 		return GFP_DMA;
 	if (*phys_mask <= DMA_BIT_MASK(32))
-- 
2.19.0


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

* Re: [PATCH] dma-direct: document the zone selection logic
  2018-10-01 20:10 ` [PATCH] dma-direct: document the zone selection logic Christoph Hellwig
@ 2018-10-01 20:22   ` Randy Dunlap
  2018-10-08  7:03   ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2018-10-01 20:22 UTC (permalink / raw)
  To: Christoph Hellwig, iommu
  Cc: Marek Szyprowski, Robin Murphy, Benjamin Herrenschmidt, linux-kernel

On 10/1/18 1:10 PM, Christoph Hellwig wrote:
> What we are doing here isn't quite obvious, so add a comment explaining
> it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  kernel/dma/direct.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index ba6f5956a291..14b966e2349a 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -84,7 +84,14 @@ static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
>  	else
>  		*phys_mask = dma_to_phys(dev, dma_mask);
>  
> -	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
> +	/*
> +	 * Optimistically try the zone that the physicall address mask falls

	                                        physical

> +	 * into first.  If that returns memory that isn't actually addressable
> +	 * we will fallback to the next lower zone and try again.
> +	 *
> +	 * Note that GFP_DMA32 and GFP_DMA are no ops without the corresponding
> +	 * zones.
> +	 */
>  	if (*phys_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
>  		return GFP_DMA;
>  	if (*phys_mask <= DMA_BIT_MASK(32))
> 

thanks for the documentation.

-- 
~Randy

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

* Re: [PATCH] dma-direct: document the zone selection logic
  2018-10-01 20:10 ` [PATCH] dma-direct: document the zone selection logic Christoph Hellwig
  2018-10-01 20:22   ` Randy Dunlap
@ 2018-10-08  7:03   ` Christoph Hellwig
  2018-10-08 22:56     ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-08  7:03 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: iommu, Robin Murphy, linux-kernel

Ben, does this resolve your issues with the confusing zone selection?

On Mon, Oct 01, 2018 at 01:10:16PM -0700, Christoph Hellwig wrote:
> What we are doing here isn't quite obvious, so add a comment explaining
> it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  kernel/dma/direct.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index ba6f5956a291..14b966e2349a 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -84,7 +84,14 @@ static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
>  	else
>  		*phys_mask = dma_to_phys(dev, dma_mask);
>  
> -	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
> +	/*
> +	 * Optimistically try the zone that the physicall address mask falls
> +	 * into first.  If that returns memory that isn't actually addressable
> +	 * we will fallback to the next lower zone and try again.
> +	 *
> +	 * Note that GFP_DMA32 and GFP_DMA are no ops without the corresponding
> +	 * zones.
> +	 */
>  	if (*phys_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
>  		return GFP_DMA;
>  	if (*phys_mask <= DMA_BIT_MASK(32))
> -- 
> 2.19.0
> 
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
---end quoted text---

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

* Re: [PATCH] dma-direct: document the zone selection logic
  2018-10-08  7:03   ` Christoph Hellwig
@ 2018-10-08 22:56     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2018-10-08 22:56 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: iommu, Robin Murphy, linux-kernel

On Mon, 2018-10-08 at 09:03 +0200, Christoph Hellwig wrote:
> Ben, does this resolve your issues with the confusing zone selection?

The comment does make things a tad clearer yes :)

Thanks !

Cheers,
Ben.

> On Mon, Oct 01, 2018 at 01:10:16PM -0700, Christoph Hellwig wrote:
> > What we are doing here isn't quite obvious, so add a comment explaining
> > it.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  kernel/dma/direct.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> > index ba6f5956a291..14b966e2349a 100644
> > --- a/kernel/dma/direct.c
> > +++ b/kernel/dma/direct.c
> > @@ -84,7 +84,14 @@ static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
> >  	else
> >  		*phys_mask = dma_to_phys(dev, dma_mask);
> >  
> > -	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
> > +	/*
> > +	 * Optimistically try the zone that the physicall address mask falls
> > +	 * into first.  If that returns memory that isn't actually addressable
> > +	 * we will fallback to the next lower zone and try again.
> > +	 *
> > +	 * Note that GFP_DMA32 and GFP_DMA are no ops without the corresponding
> > +	 * zones.
> > +	 */
> >  	if (*phys_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
> >  		return GFP_DMA;
> >  	if (*phys_mask <= DMA_BIT_MASK(32))
> > -- 
> > 2.19.0
> > 
> > _______________________________________________
> > iommu mailing list
> > iommu@lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/iommu
> 
> ---end quoted text---


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

end of thread, other threads:[~2018-10-08 22:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 20:10 document dma-direct zone selection Christoph Hellwig
2018-10-01 20:10 ` [PATCH] dma-direct: document the zone selection logic Christoph Hellwig
2018-10-01 20:22   ` Randy Dunlap
2018-10-08  7:03   ` Christoph Hellwig
2018-10-08 22:56     ` Benjamin Herrenschmidt

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