dma-direct: document the zone selection logic
authorChristoph Hellwig <hch@lst.de>
Mon, 1 Oct 2018 14:40:53 +0000 (07:40 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 9 Oct 2018 05:43:25 +0000 (07:43 +0200)
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

index 674a8da228444d615a301f9d7bc491833bfd35fd..a5a943836c8ee1ef100d248a035602967b8a1875 100644 (file)
@@ -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 physical 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))