Skip to content

Commit

Permalink
dma-mapping: warn when coherent pool is depleted
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
rientjes authored and Christoph Hellwig committed Jun 29, 2020
1 parent 9ebcfad commit 71cdec4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/dma/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size,
}

val = gen_pool_alloc(pool, size);
if (val) {
if (likely(val)) {
phys_addr_t phys = gen_pool_virt_to_phys(pool, val);

*ret_page = pfn_to_page(__phys_to_pfn(phys));
ptr = (void *)val;
memset(ptr, 0, size);
} else {
WARN_ONCE(1, "DMA coherent pool depleted, increase size "
"(recommended min coherent_pool=%zuK)\n",
gen_pool_size(pool) >> 9);
}
if (gen_pool_avail(pool) < atomic_pool_size)
schedule_work(&atomic_pool_work);
Expand Down

0 comments on commit 71cdec4

Please sign in to comment.