Re: [PATCH] dma-pool: use single atomic pool for both DMA zones

From: Robin Murphy
Date: Wed Jul 08 2020 - 12:20:20 EST


On 2020-07-08 16:36, Christoph Hellwig wrote:
On Wed, Jul 08, 2020 at 12:35:34PM +0200, Nicolas Saenz Julienne wrote:
Which allows me to switch between ACPI/DT on the machine. In DT mode it
works fine now,

Nice, would that count as a Tested-by from you?

but with ACPI I continue to have failures unless I
disable CMA via cma=0 on the kernel command line.

Yes, I see why, in atomic_pool_expand() memory is allocated from CMA without
checking its correctness. That calls for a separate fix. I'll try to think of
something.

I think we need a dma_coherent_ok for the allocations from the
pool and then fall back to the next better one to get started. And
yes, CMA is a bit of a mess, that generally needs better checks.

Yeah, another thought that came to mind later is that iommu-dma can use pages from any pool regardless of the device's DMA mask, so we could stand to be a lot less restrictive in that case too.

Perhaps it is better to just bite the bullet, keep the straightforward one-pool-per-zone setup, and implement the dma_coherent_ok() type fallback logic. More complexity for dma_alloc_from_pool(), but everything else stays nice and simple - lose the assumption that dev_to_pool() can work for this and and just let callers pass an allocation mask directly, and have dma_free_from_pool() simply check all available pools.

Robin.