mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] ARM: rpi: parse memory from vc fdt
@ 2023-01-11  9:56 Johannes Schneider
  2023-01-11 10:07 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schneider @ 2023-01-11  9:56 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Marcin Niestroj

From: Marcin Niestroj <m.niestroj@emb.dev>

Currently for RaspberryPi platform there is only one memory bank
created, based on information fetched over mailbox. This is fine for
booting Barebox, but unfortunately all the other memory banks are not
propagated to Linux during boot, thus cannot be utilized. In fact, even
when using /vc.dtb as device-tree for Linux, all memory nodes in FDT are
deleted and new ones are created by Barebox by memory fixup mechanism,
using exising RAM information. As a result RaspberryPi 4 boots Linux
with 1GB RAM available, instead of 2GB (2 banks, each 1GB).

At the end of VideoCore FDT parsing, do the same as of_probe_memory() in
mem_initcall does, but for VideoCore provided devicetree/memory
information. During Linux boot this information is used for memory fixup
mechanism and in case of RaspberryPi 4 this results in 2 memory banks
being propagated:

  # ls /proc/device-tree/memory*
  /proc/device-tree/memory@0:
  device_type  name         reg

  /proc/device-tree/memory@40000000:
  device_type  name         reg

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230110193251.2821638-1-m.niestroj@grinn-global.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 77935e5c88..c6c7fd52bd 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -258,7 +258,7 @@ static u32 rpi_boot_mode, rpi_boot_part;
 static void rpi_vc_fdt_parse(void *fdt)
 {
 	int ret;
-	struct device_node *root, *chosen, *bootloader;
+	struct device_node *root, *chosen, *bootloader, *memory;
 	char *str;
 
 	root = of_unflatten_dtb(fdt, INT_MAX);
@@ -324,6 +324,16 @@ static void rpi_vc_fdt_parse(void *fdt)
 	if (IS_ENABLED(CONFIG_RESET_SOURCE))
 		reset_source_set(rpi_decode_pm_rsts(chosen, bootloader));
 
+	/* Parse all available nodes with "memory" device_type */
+	memory = root;
+	while (1) {
+		memory = of_find_node_by_type(memory, "memory");
+		if (!memory)
+			break;
+
+		of_add_memory(memory, false);
+	}
+
 out:
 	if (root)
 		of_delete_node(root);
-- 
2.25.1




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

* Re: [PATCH v2] ARM: rpi: parse memory from vc fdt
  2023-01-11  9:56 [PATCH v2] ARM: rpi: parse memory from vc fdt Johannes Schneider
@ 2023-01-11 10:07 ` Ahmad Fatoum
  2023-01-11 10:23   ` SCHNEIDER Johannes
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2023-01-11 10:07 UTC (permalink / raw)
  To: Johannes Schneider, barebox; +Cc: Marcin Niestroj

On 11.01.23 10:56, Johannes Schneider wrote:
> From: Marcin Niestroj <m.niestroj@emb.dev>

Did you mean to resend a patch already applied to next..?

> 
> Currently for RaspberryPi platform there is only one memory bank
> created, based on information fetched over mailbox. This is fine for
> booting Barebox, but unfortunately all the other memory banks are not
> propagated to Linux during boot, thus cannot be utilized. In fact, even
> when using /vc.dtb as device-tree for Linux, all memory nodes in FDT are
> deleted and new ones are created by Barebox by memory fixup mechanism,
> using exising RAM information. As a result RaspberryPi 4 boots Linux
> with 1GB RAM available, instead of 2GB (2 banks, each 1GB).
> 
> At the end of VideoCore FDT parsing, do the same as of_probe_memory() in
> mem_initcall does, but for VideoCore provided devicetree/memory
> information. During Linux boot this information is used for memory fixup
> mechanism and in case of RaspberryPi 4 this results in 2 memory banks
> being propagated:
> 
>   # ls /proc/device-tree/memory*
>   /proc/device-tree/memory@0:
>   device_type  name         reg
> 
>   /proc/device-tree/memory@40000000:
>   device_type  name         reg
> 
> Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> Link: https://lore.barebox.org/20230110193251.2821638-1-m.niestroj@grinn-global.com
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  arch/arm/boards/raspberry-pi/rpi-common.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
> index 77935e5c88..c6c7fd52bd 100644
> --- a/arch/arm/boards/raspberry-pi/rpi-common.c
> +++ b/arch/arm/boards/raspberry-pi/rpi-common.c
> @@ -258,7 +258,7 @@ static u32 rpi_boot_mode, rpi_boot_part;
>  static void rpi_vc_fdt_parse(void *fdt)
>  {
>  	int ret;
> -	struct device_node *root, *chosen, *bootloader;
> +	struct device_node *root, *chosen, *bootloader, *memory;
>  	char *str;
>  
>  	root = of_unflatten_dtb(fdt, INT_MAX);
> @@ -324,6 +324,16 @@ static void rpi_vc_fdt_parse(void *fdt)
>  	if (IS_ENABLED(CONFIG_RESET_SOURCE))
>  		reset_source_set(rpi_decode_pm_rsts(chosen, bootloader));
>  
> +	/* Parse all available nodes with "memory" device_type */
> +	memory = root;
> +	while (1) {
> +		memory = of_find_node_by_type(memory, "memory");
> +		if (!memory)
> +			break;
> +
> +		of_add_memory(memory, false);
> +	}
> +
>  out:
>  	if (root)
>  		of_delete_node(root);

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH v2] ARM: rpi: parse memory from vc fdt
  2023-01-11 10:07 ` Ahmad Fatoum
@ 2023-01-11 10:23   ` SCHNEIDER Johannes
  0 siblings, 0 replies; 3+ messages in thread
From: SCHNEIDER Johannes @ 2023-01-11 10:23 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox; +Cc: Marcin Niestroj

> Did you mean to resend a patch already applied to next..?

oh oops, that was a send-patch mishap... please ignore :-S


regards
Johannes

________________________________________
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
Sent: Wednesday, January 11, 2023 11:07
To: SCHNEIDER Johannes; barebox@lists.infradead.org
Cc: Marcin Niestroj; Sascha Hauer
Subject: Re: [PATCH v2] ARM: rpi: parse memory from vc fdt

This email is not from Hexagon’s Office 365 instance. Please be careful while clicking links, opening attachments, or replying to this email.


On 11.01.23 10:56, Johannes Schneider wrote:
> From: Marcin Niestroj <m.niestroj@emb.dev>

Did you mean to resend a patch already applied to next..?

>
> Currently for RaspberryPi platform there is only one memory bank
> created, based on information fetched over mailbox. This is fine for
> booting Barebox, but unfortunately all the other memory banks are not
> propagated to Linux during boot, thus cannot be utilized. In fact, even
> when using /vc.dtb as device-tree for Linux, all memory nodes in FDT are
> deleted and new ones are created by Barebox by memory fixup mechanism,
> using exising RAM information. As a result RaspberryPi 4 boots Linux
> with 1GB RAM available, instead of 2GB (2 banks, each 1GB).
>
> At the end of VideoCore FDT parsing, do the same as of_probe_memory() in
> mem_initcall does, but for VideoCore provided devicetree/memory
> information. During Linux boot this information is used for memory fixup
> mechanism and in case of RaspberryPi 4 this results in 2 memory banks
> being propagated:
>
>   # ls /proc/device-tree/memory*
>   /proc/device-tree/memory@0:
>   device_type  name         reg
>
>   /proc/device-tree/memory@40000000:
>   device_type  name         reg
>
> Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> Link: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.barebox.org%2F20230110193251.2821638-1-m.niestroj%40grinn-global.com&data=05%7C01%7C%7Ce22566ee1edc40d19e3108daf3bba3e1%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C638090284505422798%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=qzGOCullLi46yt9L8%2FpHfZ%2BpdTf0rkR7%2BenfsQlimSY%3D&reserved=0
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  arch/arm/boards/raspberry-pi/rpi-common.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
> index 77935e5c88..c6c7fd52bd 100644
> --- a/arch/arm/boards/raspberry-pi/rpi-common.c
> +++ b/arch/arm/boards/raspberry-pi/rpi-common.c
> @@ -258,7 +258,7 @@ static u32 rpi_boot_mode, rpi_boot_part;
>  static void rpi_vc_fdt_parse(void *fdt)
>  {
>       int ret;
> -     struct device_node *root, *chosen, *bootloader;
> +     struct device_node *root, *chosen, *bootloader, *memory;
>       char *str;
>
>       root = of_unflatten_dtb(fdt, INT_MAX);
> @@ -324,6 +324,16 @@ static void rpi_vc_fdt_parse(void *fdt)
>       if (IS_ENABLED(CONFIG_RESET_SOURCE))
>               reset_source_set(rpi_decode_pm_rsts(chosen, bootloader));
>
> +     /* Parse all available nodes with "memory" device_type */
> +     memory = root;
> +     while (1) {
> +             memory = of_find_node_by_type(memory, "memory");
> +             if (!memory)
> +                     break;
> +
> +             of_add_memory(memory, false);
> +     }
> +
>  out:
>       if (root)
>               of_delete_node(root);

--
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pengutronix.de%2F&data=05%7C01%7C%7Ce22566ee1edc40d19e3108daf3bba3e1%7C1b16ab3eb8f64fe39f3e2db7fe549f6a%7C0%7C0%7C638090284505422798%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=o%2FwdqemF%2BDEDZKYUjnPRZdmzieePXgQc8%2FUCpncyJfA%3D&reserved=0  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

end of thread, other threads:[~2023-01-11 10:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11  9:56 [PATCH v2] ARM: rpi: parse memory from vc fdt Johannes Schneider
2023-01-11 10:07 ` Ahmad Fatoum
2023-01-11 10:23   ` SCHNEIDER Johannes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox