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).
Unified · Split
| @@ -239,12 +239,16 @@ void *dma_alloc_from_pool(struct device *dev, size_t size, · 238 unmodified lines | |||
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | val = gen_pool_alloc(pool, size); | 241 | val = gen_pool_alloc(pool, size); |
| 242 | if (val) { | 242 | if (likely(val)) { |
| 243 | phys_addr_t phys = gen_pool_virt_to_phys(pool, val); | 243 | phys_addr_t phys = gen_pool_virt_to_phys(pool, val); |
| 244 | 244 | ||
| 245 | *ret_page = pfn_to_page(__phys_to_pfn(phys)); | 245 | *ret_page = pfn_to_page(__phys_to_pfn(phys)); |
| 246 | ptr = (void *)val; | 246 | ptr = (void *)val; |
| 247 | memset(ptr, 0, size); | 247 | 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); | ||
| 248 | } | 252 | } |
| 249 | if (gen_pool_avail(pool) < atomic_pool_size) | 253 | if (gen_pool_avail(pool) < atomic_pool_size) |
| 250 | schedule_work(&atomic_pool_work); | 254 | schedule_work(&atomic_pool_work); |