diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h index ed69618cf1fc..80f0dbac77c4 100644 --- a/include/linux/dma-direct.h +++ b/include/linux/dma-direct.h @@ -37,11 +37,16 @@ static inline bool zone_dma32_is_empty(int node) static inline bool zone_dma32_are_empty(void) { +#ifdef CONFIG_NUMA int node; for_each_node(node) if (!zone_dma32_is_empty(node)) return false; +#else + if (!zone_dma32_is_empty(numa_node_id())) + return false; +#endif return true; } diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 6f58cde1558b..8ca84610d4d4 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -62,7 +62,7 @@ static gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask, if (*phys_limit <= DMA_BIT_MASK(zone_dma_bits)) return GFP_DMA; if (*phys_limit <= DMA_BIT_MASK(32) && - !zone_dma32_is_empty(dev_to_node(dev))) + !zone_dma32_are_empty()) return GFP_DMA32; return 0; } @@ -103,7 +103,7 @@ again: if (IS_ENABLED(CONFIG_ZONE_DMA32) && phys_limit < DMA_BIT_MASK(64) && !(gfp & (GFP_DMA32 | GFP_DMA)) && - !zone_dma32_is_empty(node)) { + !zone_dma32_are_empty()) { gfp |= GFP_DMA32; goto again; }