document dma-direct zone selection
Hi all,
this patch documents the dma-direct zone selection, as it doesn't seem quite obvuious enough.
PATCH 1/1 dma-direct: document the zone selection logic
What we are doing here isn't quite obvious, so add a comment explaining it.
--- kernel/dma/direct.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/dma/direct.c +8 -1
@@ -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 ))
Signature · 1 line
2.19.0
Re: [PATCH] dma-direct: document the zone selection logic
Quoted 13 lines · Christoph Hellwig
What we are doing here isn't quite obvious, so add a comment explaining it.
Signed-off-by Christoph Hellwig <[email protected]>--- kernel/dma/direct.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)kernel/dma/direct.c +0
-0
kernel/dma/direct.c static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask, · line 88
Quoted 6 lines
kernel/dma/direct.c +2
-1@@ -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
kernel/dma/direct.c static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask, · line 97
Quoted 10 lines
kernel/dma/direct.c +6
-0+* 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.
Signature · 1 line
~Randy
Re: [PATCH] dma-direct: document the zone selection logic
In reply to Christoph HellwigBen, does this resolve your issues with the confusing zone selection?
Quoted 35 lines · Christoph Hellwig
What we are doing here isn't quite obvious, so add a comment explaining it.
Signed-off-by Christoph Hellwig <[email protected]>--- kernel/dma/direct.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)kernel/dma/direct.c +8
-1@@ -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 ))Signature · 6 lines
2.19.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
---end quoted text---
Re: [PATCH] dma-direct: document the zone selection logic
Quoted 1 line · Christoph Hellwig
Ben, does this resolve your issues with the confusing zone selection?
The comment does make things a tad clearer yes :)
Thanks !
Cheers,
Ben.
Quoted 38 lines · Christoph Hellwig
Quoted 35 lines
What we are doing here isn't quite obvious, so add a comment explaining it.
Signed-off-by Christoph Hellwig <[email protected]>--- kernel/dma/direct.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)kernel/dma/direct.c +8
-1@@ -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 ))Signature · 6 lines
2.19.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu---end quoted text---