RE: CMA Regression issue - [PATCH v2] of: reserved_mem: Restructure code to call reserved mem init functions earlier

From: Aisheng Dong
Date: Tue Jul 09 2024 - 04:38:04 EST


> From: Oreoluwa Babatunde <quic_obabatun@xxxxxxxxxxx>
> Sent: 2024年7月9日 7:10
>
> On 7/4/2024 4:41 AM, Aisheng Dong wrote:
> > Hi Oreoluwa,
> >
> > We observed a CMA regression issue on MX8MN that the CMA region failed
> > to be setup by rmem_cma_setup() since the following patch:
> > f2a524d9ef5b ("of: reserved_mem: Restructure code to call reserved mem
> > init functions earlier") [1] And the CMA node was incorrect parsed (e.g.
> non-reuseable) due to NULL node pointer.
> > Below is one line boot log tested with the tag next-20240703 of linux-next
> tree.
> > OF: reserved mem: 0x0000000058000000..0x000000007fffffff (655360 KiB)
> > map non-reusable linux,cma
> > NOTE: actually there is a reusable property:
> > linux,cma {
> > compatible = "shared-dma-pool";
> > reusable;
> > size = <0 0x28000000>;
> > alloc-ranges = <0 0x40000000 0 0x40000000>;
> > linux,cma-default;
> > };
> >
> > The root cause was that the CMA region was initialized at a very early
> > stage since above commit in question.
> > The call flow became:
> > early_init_fdt_scan_reserved_mem()->fdt_scan_reserved_mem()->
> > __reserved_mem_alloc_size()->of_reserved_mem_save_node(NULL, xxx)->
> > of_init_reserved_mem_node()->__reserved_mem_init_node().
> >
> > The rmem->dev_node is still NULL when calling
> > __reserved_mem_init_node() which fails to call the rmem_cma_setup().
> >
> > Please let me know if there's already a fix patch.
> >
>
> I have uploaded a fix here:
> https://lore.kernel.org/all/20240708230613.448846-1-quic_obabatun@xxxxxxxxxxx/
>
> Please test and see if this fixes the issue.

Tested it worked. Thanks for the fix.

Regards
Aisheng