linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/1] Fix Random Kernel panic from when fail to reserve memory
@ 2023-04-12 22:46 Lucas Tanure
  2023-04-12 22:46 ` [PATCH v3 1/1] of: fdt: Scan /memreserve/ last Lucas Tanure
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Tanure @ 2023-04-12 22:46 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Mike Rapoport, Andrew Morton
  Cc: devicetree, linux-kernel, linux-mm, jbrunet, linux-amlogic,
	linux-arm-kernel, martin.blumenstingl, narmstrong, stefan,
	Lucas Tanure

I am trying to fix an issue where the kernel panics randomly on my Vim3
board. The problem happens when the ARM Trusted Firmware memory is not
removed from the available ram.

This happens because my u-boot provides /memreserve/, but it doesn't flag
it as nomap. And the kernel scan of /reserved-memory node can't map as
nomap as the region is already reserved.

The idea now is to scan /memreserve/ after /reserved-memory node, and
/memreserve/ will skip regions already reserved by /reserved-memory node.

Previous Threads:
#regzbot link: https://lore.kernel.org/linux-arm-kernel/40ca11f84b7cdbfb9ad2ddd480cb204a@agner.ch/#regzbot
#regzbot link: https://lore.kernel.org/all/CAJX_Q+1Tjc+-TjZ6JW9X0NxEdFe=82a9626yL63j7uVD4LpxEA@mail.gmail.com/

V1: https://lore.kernel.org/all/20230406151429.524591-1-tanure@linux.com/
v2: https://lore.kernel.org/all/20230410120017.41664-1-tanure@linux.com/

Change from V2:
 - Remove region overlap and reserved checks

Change from V1:
 - Instead of allowing to mark nomap a region already reserved, give
precedence to /reserved-memory node scan.

Lucas Tanure (1):
  of: fdt: Scan /memreserve/ last

 drivers/of/fdt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.40.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v3 1/1] of: fdt: Scan /memreserve/ last
  2023-04-12 22:46 [PATCH v3 0/1] Fix Random Kernel panic from when fail to reserve memory Lucas Tanure
@ 2023-04-12 22:46 ` Lucas Tanure
  2023-04-17 13:31   ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Tanure @ 2023-04-12 22:46 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Mike Rapoport, Andrew Morton
  Cc: devicetree, linux-kernel, linux-mm, jbrunet, linux-amlogic,
	linux-arm-kernel, martin.blumenstingl, narmstrong, stefan,
	Lucas Tanure

Change the order of scanning /memreserve/ and /reserved-memory node.
/reserved-memory node should go first, as it has a more updated
description of the memory regions and it can apply flags, like nomap.
Also, /memreserve/ should avoid reserving regions described in
/reserved-memory node.

Signed-off-by: Lucas Tanure <tanure@linux.com>
---
 drivers/of/fdt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1a68b6d03b3..c28aedd7ae1f 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -635,6 +635,9 @@ void __init early_init_fdt_scan_reserved_mem(void)
 	if (!initial_boot_params)
 		return;
 
+	fdt_scan_reserved_mem();
+	fdt_reserve_elfcorehdr();
+
 	/* Process header /memreserve/ fields */
 	for (n = 0; ; n++) {
 		fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
@@ -643,8 +646,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
 		memblock_reserve(base, size);
 	}
 
-	fdt_scan_reserved_mem();
-	fdt_reserve_elfcorehdr();
 	fdt_init_reserved_mem();
 }
 
-- 
2.40.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/1] of: fdt: Scan /memreserve/ last
  2023-04-12 22:46 ` [PATCH v3 1/1] of: fdt: Scan /memreserve/ last Lucas Tanure
@ 2023-04-17 13:31   ` Rob Herring
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2023-04-17 13:31 UTC (permalink / raw)
  To: Lucas Tanure, Michael Ellerman, linuxppc-dev
  Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
	linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
	martin.blumenstingl, narmstrong, stefan

On Wed, Apr 12, 2023 at 5:46 PM Lucas Tanure <tanure@linux.com> wrote:
>
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.

Please give some background details why we need to make this change.
As-is, sounds like some theoretical issue. IOW, incorporate some of
the details in the cover letter here. For single patches, you don't
need a cover letter anyways.

Powerpc folks, please comment and/or test. I worry there could be some
subtle differences with this change.

>
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
>  drivers/of/fdt.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..c28aedd7ae1f 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,6 +635,9 @@ void __init early_init_fdt_scan_reserved_mem(void)
>         if (!initial_boot_params)
>                 return;
>
> +       fdt_scan_reserved_mem();
> +       fdt_reserve_elfcorehdr();
> +
>         /* Process header /memreserve/ fields */
>         for (n = 0; ; n++) {
>                 fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> @@ -643,8 +646,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
>                 memblock_reserve(base, size);
>         }
>
> -       fdt_scan_reserved_mem();
> -       fdt_reserve_elfcorehdr();
>         fdt_init_reserved_mem();
>  }
>
> --
> 2.40.0
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-17 13:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 22:46 [PATCH v3 0/1] Fix Random Kernel panic from when fail to reserve memory Lucas Tanure
2023-04-12 22:46 ` [PATCH v3 1/1] of: fdt: Scan /memreserve/ last Lucas Tanure
2023-04-17 13:31   ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).