Skip to content

Commit 56c430c

Browse files
sskartheekadivimszyprow
authored andcommitted
dma/pool: distinguish between missing and exhausted atomic pools
Currently, dma_alloc_from_pool() unconditionally warns and dumps a stack trace when an allocation fails, with the message "Failed to get suitable pool". This conflates two distinct failure modes: 1. Configuration error: No atomic pool is available for the requested DMA mask (a fundamental system setup issue) 2. Resource Exhaustion: A suitable pool exists but is currently full (a recoverable runtime state) This lack of distinction prevents drivers from using __GFP_NOWARN to suppress error messages during temporary pressure spikes, such as when awaiting synchronous reclaim of descriptors. Refactor the error handling to distinguish these cases: - If no suitable pool is found, keep the unconditional WARN regarding the missing pool. - If a pool was found but is exhausted, respect __GFP_NOWARN and update the warning message to explicitly state "DMA pool exhausted". Fixes: 9420139 ("dma-pool: fix coherent pool allocations for IOMMU mappings") Signed-off-by: Sai Sree Kartheek Adivi <s-adivi@ti.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://lore.kernel.org/r/20260128133554.3056582-1-s-adivi@ti.com
1 parent 0fd17e5 commit 56c430c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

kernel/dma/pool.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,20 @@ struct page *dma_alloc_from_pool(struct device *dev, size_t size,
277277
{
278278
struct gen_pool *pool = NULL;
279279
struct page *page;
280+
bool pool_found = false;
280281

281282
while ((pool = dma_guess_pool(pool, gfp))) {
283+
pool_found = true;
282284
page = __dma_alloc_from_pool(dev, size, pool, cpu_addr,
283285
phys_addr_ok);
284286
if (page)
285287
return page;
286288
}
287289

288-
WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
290+
if (pool_found)
291+
WARN(!(gfp & __GFP_NOWARN), "DMA pool exhausted for %s\n", dev_name(dev));
292+
else
293+
WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
289294
return NULL;
290295
}
291296

0 commit comments

Comments
 (0)