Blob Blame History Raw
From: Takashi Iwai <tiwai@suse.de>
Date: Sun, 15 Apr 2018 11:08:07 +0200
Subject: dma-direct: don't retry allocation for no-op GFP_DMA
Git-commit: 504a918e6714b551b7b39940dbab32610fafa1fe
Patch-mainline: v4.17-rc3
References: jsc#SLE-6197 FATE#327012 bsc#1140559 LTC#173150

When an allocation with lower dma_coherent mask fails, dma_direct_alloc()
retries the allocation with GFP_DMA.  But, this is useless for
architectures that hav no ZONE_DMA.

Fix it by adding the check of CONFIG_ZONE_DMA before retrying the
allocation.

Fixes: 95f183916d4b ("dma-direct: retry allocations using GFP_DMA for small masks")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 lib/dma-noop.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/lib/dma-noop.c
+++ b/lib/dma-noop.c
@@ -25,7 +25,8 @@ again:
 		free_pages((unsigned long)ret, get_order(size));
 		ret = NULL;
 
-		if (dev->coherent_dma_mask < DMA_BIT_MASK(32) &&
+		if (IS_ENABLED(CONFIG_ZONE_DMA) &&
+		    dev->coherent_dma_mask < DMA_BIT_MASK(32) &&
 		    !(gfp & GFP_DMA)) {
 			gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
 			goto again;