Skip to content

Commit b31ac41

Browse files
rmurphy-armmszyprow
authored andcommitted
dma/pool: Improve pool lookup
If CONFIG_ZONE_DMA32 is enabled, but we have not allocated the corresponding atomic_pool_dma32, dma_guess_pool() may return the NULL value of that and fail a GFP_DMA32 allocation without trying to fall back to other pools which may exist. Furthermore, if no GFP_DMA pool exists, it is preferable to try GFP_DMA32 rather than immediately fall back to GFP_KERNEL with even less chance of success. Improve matters by encoding an explicit order of pool preference for each flag. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Tested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com> Reviewed-by: Baoquan He <bhe@redhat.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://lore.kernel.org/r/c846b1a2f43295cac926c7af2ce907f62baec518.1768230104.git.robin.murphy@arm.com
1 parent 7f2e8e1 commit b31ac41

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

kernel/dma/pool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ postcore_initcall(dma_atomic_pool_init);
224224
static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp)
225225
{
226226
if (prev == NULL) {
227-
if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
228-
return atomic_pool_dma32;
229-
if (atomic_pool_dma && (gfp & GFP_DMA))
230-
return atomic_pool_dma;
227+
if (gfp & GFP_DMA)
228+
return atomic_pool_dma ?: atomic_pool_dma32 ?: atomic_pool_kernel;
229+
if (gfp & GFP_DMA32)
230+
return atomic_pool_dma32 ?: atomic_pool_dma ?: atomic_pool_kernel;
231231
return atomic_pool_kernel;
232232
}
233233
if (prev == atomic_pool_kernel)

0 commit comments

Comments
 (0)