Skip to content

Commit

Permalink
dma-direct: don't retry allocation for no-op GFP_DMA
Browse files Browse the repository at this point in the history
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: 95f1839 ("dma-direct: retry allocations using GFP_DMA for small masks")
Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
tiwai authored and Christoph Hellwig committed Apr 23, 2018
1 parent 6d08b06 commit 504a918
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/dma-direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
__free_pages(page, page_order);
page = 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;
Expand Down

0 comments on commit 504a918

Please sign in to comment.