Skip to content

Commit 71cdec4

Browse files
rientjesChristoph Hellwig
authored andcommitted
dma-mapping: warn when coherent pool is depleted
When a DMA coherent pool is depleted, allocation failures may or may not get reported in the kernel log depending on the allocator. The admin does have a workaround, however, by using coherent_pool= on the kernel command line. Provide some guidance on the failure and a recommended minimum size for the pools (double the size). Signed-off-by: David Rientjes <rientjes@google.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 9ebcfad commit 71cdec4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎kernel/dma/pool.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size,
239239
}
240240

241241
val = gen_pool_alloc(pool, size);
242-
if (val) {
242+
if (likely(val)) {
243243
phys_addr_t phys = gen_pool_virt_to_phys(pool, val);
244244

245245
*ret_page = pfn_to_page(__phys_to_pfn(phys));
246246
ptr = (void *)val;
247247
memset(ptr, 0, size);
248+
} else {
249+
WARN_ONCE(1, "DMA coherent pool depleted, increase size "
250+
"(recommended min coherent_pool=%zuK)\n",
251+
gen_pool_size(pool) >> 9);
248252
}
249253
if (gen_pool_avail(pool) < atomic_pool_size)
250254
schedule_work(&atomic_pool_work);

0 commit comments

Comments
 (0)