mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: base: move memory init from DT to initcall
@ 2020-08-16 21:43 Lucas Stach
  2020-08-17  6:06 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2020-08-16 21:43 UTC (permalink / raw)
  To: barebox

Instead of calling it from of_probe, convert it to a initcall at
the appropriate level. This allows to move of_probe to later in
the init sequence while keeping the memory init at the same place,
which is important as many other drivers need the valid memory area
to be set up properly.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 drivers/of/base.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4c633bcd4948..2fc87528ebfd 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2116,10 +2116,13 @@ const struct of_device_id of_default_bus_match_table[] = {
 	}
 };
 
-static void of_probe_memory(void)
+static int of_probe_memory(void)
 {
 	struct device_node *memory = root_node;
 
+	if(!IS_ENABLED(CONFIG_OFDEVICE))
+		return 0;
+
 	/* Parse all available node with "memory" device_type */
 	while (1) {
 		memory = of_find_node_by_type(memory, "memory");
@@ -2128,7 +2131,10 @@ static void of_probe_memory(void)
 
 		of_add_memory(memory, false);
 	}
+
+	return 0;
 }
+mem_initcall(of_probe_memory);
 
 int of_probe(void)
 {
@@ -2143,8 +2149,6 @@ int of_probe(void)
 	if (of_model)
 		barebox_set_model(of_model);
 
-	of_probe_memory();
-
 	firmware = of_find_node_by_path("/firmware");
 	if (firmware)
 		of_platform_populate(firmware, NULL, NULL);
-- 
2.26.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] of: base: move memory init from DT to initcall
  2020-08-16 21:43 [PATCH] of: base: move memory init from DT to initcall Lucas Stach
@ 2020-08-17  6:06 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-08-17  6:06 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

Hi Lucas,

On Sun, Aug 16, 2020 at 11:43:00PM +0200, Lucas Stach wrote:
> Instead of calling it from of_probe, convert it to a initcall at
> the appropriate level. This allows to move of_probe to later in
> the init sequence while keeping the memory init at the same place,
> which is important as many other drivers need the valid memory area
> to be set up properly.

With this the latest point where of_probe() could be called would be
one before mem_initcall, so postconsole_initcall.

On some architectures we have a driver for the SDRAM controller which
configures the RAM banks based on values read from the controller. On
others we depend on the device tree information and finally there are
cases where we have both and hope for the best that both information
sources do not clash. This is all not very nice and moving the initcall
level for registering the RAM might have undesired side effects.
In this situation I'm a bit hesitant to merge this patch when it doesn't
have a concrete user.

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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-08-17  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16 21:43 [PATCH] of: base: move memory init from DT to initcall Lucas Stach
2020-08-17  6:06 ` Sascha Hauer

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