dma-pool: warn when coherent pool is depleted
Guenter Roeck
Tested-byQuoted 10 lines · David Rientjes
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]>
Also confirmed that coherent_pool=256k works around the crash I had observed.
Guenter
Quoted 15 lines
--- kernel/dma/pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)kernel/dma/pool.c +1
-1@@ -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);
kernel/dma/pool.c void *dma_alloc_from_pool(struct device *dev, size_t size, · line 254
Quoted 10 lines
kernel/dma/pool.c +4
-0*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);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 9 lines · Guenter Roeck
Quoted 9 lines
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).
Quoted 7 lines
Quoted 1 line
Signed-off-by David Rientjes <[email protected]>Tested-by Guenter Roeck <[email protected]>Also confirmed that coherent_pool=256k works around the crash I had observed.
Thanks Guenter. Christoph, does it make sense to apply this patch since there may not be an artifact left behind in the kernel log on allocation failure by the caller?
Quoted 28 lines
Guenter
Quoted 25 lines
--- kernel/dma/pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)kernel/dma/pool.c +5
-1@@ -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);
Quoted 3 lines · David Rientjes
Thanks Guenter. Christoph, does it make sense to apply this patch since there may not be an artifact left behind in the kernel log on allocation failure by the caller?
Sorry, this fell through the cracks. I've added it to the dma-mapping tree now.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu