* [PATCH] ARM: rpi: parse memory from vc fdt
@ 2023-01-10 19:32 Marcin Niestroj
2023-01-10 19:56 ` Ahmad Fatoum
0 siblings, 1 reply; 3+ messages in thread
From: Marcin Niestroj @ 2023-01-10 19:32 UTC (permalink / raw)
To: barebox; +Cc: 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>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 16 +++++++++++++++-
1 file changed, 15 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..0855eee872 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,20 @@ 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) {
+ int err;
+
+ memory = of_find_node_by_type(memory, "memory");
+ if (!memory)
+ break;
+
+ err = of_add_memory(memory, false);
+ if (err)
+ ret = err;
+ }
+
out:
if (root)
of_delete_node(root);
--
2.39.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: rpi: parse memory from vc fdt
2023-01-10 19:32 [PATCH] ARM: rpi: parse memory from vc fdt Marcin Niestroj
@ 2023-01-10 19:56 ` Ahmad Fatoum
2023-01-11 8:28 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2023-01-10 19:56 UTC (permalink / raw)
To: Marcin Niestroj, barebox; +Cc: Marcin Niestroj
On 10.01.23 20:32, Marcin Niestroj wrote:
> 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>
Thanks for your patch. I suggest this be applied to master.
I think it may be worthwhile in future to only query the mailbox
interface for memory in PBL (lowlevel.c) for use as early mem and
depend solely on DT in barebox proper.
> ---
> arch/arm/boards/raspberry-pi/rpi-common.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
> + err = of_add_memory(memory, false);
> + if (err)
> + ret = err;
No one does anything wither either err or ret, so you can drop that.
Anyways:
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> + }
> +
> 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] ARM: rpi: parse memory from vc fdt
2023-01-10 19:56 ` Ahmad Fatoum
@ 2023-01-11 8:28 ` Sascha Hauer
0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-01-11 8:28 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: Marcin Niestroj, barebox, Marcin Niestroj
On Tue, Jan 10, 2023 at 08:56:13PM +0100, Ahmad Fatoum wrote:
> On 10.01.23 20:32, Marcin Niestroj wrote:
> > 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>
>
> Thanks for your patch. I suggest this be applied to master.
>
> I think it may be worthwhile in future to only query the mailbox
> interface for memory in PBL (lowlevel.c) for use as early mem and
> depend solely on DT in barebox proper.
>
> > ---
> > arch/arm/boards/raspberry-pi/rpi-common.c | 16 +++++++++++++++-
> > 1 file changed, 15 insertions(+), 1 deletion(-)
>
> > + err = of_add_memory(memory, false);
> > + if (err)
> > + ret = err;
>
> No one does anything wither either err or ret, so you can drop that.
Did that and applied to master.
Sascha
--
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
end of thread, other threads:[~2023-01-11 8:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 19:32 [PATCH] ARM: rpi: parse memory from vc fdt Marcin Niestroj
2023-01-10 19:56 ` Ahmad Fatoum
2023-01-11 8:28 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox