[PATCH 0/4] Revert use of Unflatten_devicetree APIs from reserved_mem

Oreoluwa Babatunde posted 4 patches 1 year, 5 months ago
drivers/of/fdt.c                |   2 +-
drivers/of/of_private.h         |   2 +-
drivers/of/of_reserved_mem.c    | 103 +++++++++++++++++---------------
include/linux/of_reserved_mem.h |   2 +-
kernel/dma/coherent.c           |  10 ++--
kernel/dma/contiguous.c         |   8 +--
kernel/dma/swiotlb.c            |  10 ++--
7 files changed, 72 insertions(+), 65 deletions(-)
[PATCH 0/4] Revert use of Unflatten_devicetree APIs from reserved_mem
Posted by Oreoluwa Babatunde 1 year, 5 months ago
With recent changes made to initialize the cma regions before the page
tables are setup, commit f2a524d9ef5b ("of: reserved_mem: Restructure
code to call reserved mem init functions earlier"), an issue was
introduced where the initialization of the cma regions fail and are
initialized as "non-reusable" regions instead of "reusable". [1], [2]

This issue occurs because the device_node of the regions are not yet
created by the time the cma regions are being initialized.

The cma regions need to be initialized before the page tables are setup
for them to be configured correctly as was realized in [3].

Hence, since the unflatten_devicetree APIs are not available until after
the page tables have been setup, revert back to using the fdt APIs. This
makes it possible to store a reference to each cma node in the
reserved_mem array by the time it is needed in the init function.

[1] https://lore.kernel.org/all/DU0PR04MB9299C3EC247E1FE2C373440F80DE2@DU0PR04MB9299.eurprd04.prod.outlook.com/

[2] https://lore.kernel.org/all/986361f4-f000-4129-8214-39f2fb4a90da@gmail.com/

[3] https://lore.kernel.org/all/20240610213403.GA1697364@thelio-3990X/

Oreoluwa Babatunde (4):
  Revert "of: reserved_mem: Restructure code to call reserved mem init
    functions earlier"
  Revert "of: reserved_mem: Rename fdt_* functions to refelct the change
    from using fdt APIs"
  Revert "of: reserved_mem: Use unflatten_devicetree APIs to scan
    reserved memory nodes"
  of: reserved_mem: Restructure code to call rmem init functions earlier

 drivers/of/fdt.c                |   2 +-
 drivers/of/of_private.h         |   2 +-
 drivers/of/of_reserved_mem.c    | 103 +++++++++++++++++---------------
 include/linux/of_reserved_mem.h |   2 +-
 kernel/dma/coherent.c           |  10 ++--
 kernel/dma/contiguous.c         |   8 +--
 kernel/dma/swiotlb.c            |  10 ++--
 7 files changed, 72 insertions(+), 65 deletions(-)

-- 
2.34.1
Re: [PATCH 0/4] Revert use of Unflatten_devicetree APIs from reserved_mem
Posted by Klara Modin 1 year, 5 months ago
Hi,

Den tis 9 juli 2024 kl 01:06 skrev Oreoluwa Babatunde
<quic_obabatun@quicinc.com>:
>
> With recent changes made to initialize the cma regions before the page
> tables are setup, commit f2a524d9ef5b ("of: reserved_mem: Restructure
> code to call reserved mem init functions earlier"), an issue was
> introduced where the initialization of the cma regions fail and are
> initialized as "non-reusable" regions instead of "reusable". [1], [2]
>
> This issue occurs because the device_node of the regions are not yet
> created by the time the cma regions are being initialized.
>
> The cma regions need to be initialized before the page tables are setup
> for them to be configured correctly as was realized in [3].
>
> Hence, since the unflatten_devicetree APIs are not available until after
> the page tables have been setup, revert back to using the fdt APIs. This
> makes it possible to store a reference to each cma node in the
> reserved_mem array by the time it is needed in the init function.
>
> [1] https://lore.kernel.org/all/DU0PR04MB9299C3EC247E1FE2C373440F80DE2@DU0PR04MB9299.eurprd04.prod.outlook.com/
>
> [2] https://lore.kernel.org/all/986361f4-f000-4129-8214-39f2fb4a90da@gmail.com/
>
> [3] https://lore.kernel.org/all/20240610213403.GA1697364@thelio-3990X/
>

These reverts also fixes the issue for me. Feel free to CC me when you
decide to send the next version if you want and I can retest it.

Regards,
Tested-by: Klara Modin <klarasmodin@gmail.com>

> Oreoluwa Babatunde (4):
>   Revert "of: reserved_mem: Restructure code to call reserved mem init
>     functions earlier"
>   Revert "of: reserved_mem: Rename fdt_* functions to refelct the change
>     from using fdt APIs"
>   Revert "of: reserved_mem: Use unflatten_devicetree APIs to scan
>     reserved memory nodes"
>   of: reserved_mem: Restructure code to call rmem init functions earlier
>
>  drivers/of/fdt.c                |   2 +-
>  drivers/of/of_private.h         |   2 +-
>  drivers/of/of_reserved_mem.c    | 103 +++++++++++++++++---------------
>  include/linux/of_reserved_mem.h |   2 +-
>  kernel/dma/coherent.c           |  10 ++--
>  kernel/dma/contiguous.c         |   8 +--
>  kernel/dma/swiotlb.c            |  10 ++--
>  7 files changed, 72 insertions(+), 65 deletions(-)
>
> --
> 2.34.1
>
Re: [PATCH 0/4] Revert use of Unflatten_devicetree APIs from reserved_mem
Posted by Oreoluwa Babatunde 1 year, 4 months ago
On 7/9/2024 4:30 AM, Klara Modin wrote:
> Hi,
>
> Den tis 9 juli 2024 kl 01:06 skrev Oreoluwa Babatunde
> <quic_obabatun@quicinc.com>:
>> With recent changes made to initialize the cma regions before the page
>> tables are setup, commit f2a524d9ef5b ("of: reserved_mem: Restructure
>> code to call reserved mem init functions earlier"), an issue was
>> introduced where the initialization of the cma regions fail and are
>> initialized as "non-reusable" regions instead of "reusable". [1], [2]
>>
>> This issue occurs because the device_node of the regions are not yet
>> created by the time the cma regions are being initialized.
>>
>> The cma regions need to be initialized before the page tables are setup
>> for them to be configured correctly as was realized in [3].
>>
>> Hence, since the unflatten_devicetree APIs are not available until after
>> the page tables have been setup, revert back to using the fdt APIs. This
>> makes it possible to store a reference to each cma node in the
>> reserved_mem array by the time it is needed in the init function.
>>
>> [1] https://lore.kernel.org/all/DU0PR04MB9299C3EC247E1FE2C373440F80DE2@DU0PR04MB9299.eurprd04.prod.outlook.com/
>>
>> [2] https://lore.kernel.org/all/986361f4-f000-4129-8214-39f2fb4a90da@gmail.com/
>>
>> [3] https://lore.kernel.org/all/20240610213403.GA1697364@thelio-3990X/
>>
> These reverts also fixes the issue for me. Feel free to CC me when you
> decide to send the next version if you want and I can retest it.
>
> Regards,
> Tested-by: Klara Modin <klarasmodin@gmail.com>
Hi Klara,

I have uploaded a new version of this patch set and cc'ed you on it.
Please help me retest to see if it still works for you.
https://lore.kernel.org/all/20240809184814.2703050-1-quic_obabatun@quicinc.com/

Thank you!
Oreoluwa