Re: [PATCH] dma-direct: fix the page free when it is not addressable
From: Christoph Hellwig
Date: Tue Sep 03 2024 - 03:35:33 EST
On Sat, Aug 31, 2024 at 07:01:19PM +0800, Chen Yu wrote:
> When the CMA allocation succeeds but isn't addressable, its
> buffer has already been released and the page is set to NULL.
> So later when the normal page allocation succeeds but isn't
> addressable, __free_pages() should be used to free that normal
> page rather than freeing continuous page(CMA).
So the patch is obviously correct and probably useful, but I don't think
the existing code is buggy.
dma_free_contiguous calls into cma_release, which uses cma_pages_valid to
check if the page belongs to the CMA pool and retuns early if not,
letting dma_free_contiguous fall back to __free_pages eventually.
What am I missing here?