Re: [PATCH v6 4/5] dma-buf: heaps: Add CMA heap to dmabuf heaps

From: Christoph Hellwig
Date: Thu Jul 25 2019 - 14:06:09 EST


On Wed, Jul 24, 2019 at 10:08:54AM +0200, Benjamin Gaignard wrote:
> CMA has made possible to get large regions of memories and to give some
> priority on device allocating pages on it. I don't think that possible
> with system
> heap so I suggest to keep CMA heap if we want to be able to port a maximum
> of applications on dma-buf-heap.

Yes, CMA is a way to better allocate contigous regions, but it isn't
the only way to do that.

So at least for the system default CMA area it really should be a helper
for the system heap, especially given that CMA is an optional feature
and we can do high order contigous allocations using alloc_pages as
well.

Something like:

if (!require_contigous && order > 0) {
for (i = 0; i < nr_pages; i++)
page[i] = alloc_page();
goto done;
} else if (order > 0)
page = cma_alloc();
if (page)
goto done;
}

page = alloc_pages(order);