of: base: move memory init from DT to initcall
PATCH 1/1 of: base: move memory init from DT to initcall
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.
--- drivers/of/base.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/of/base.c +7 -3
@@ -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 );
Signature · 7 lines
2.26.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Lucas,
Quoted 5 lines · Lucas Stach
Instead of calling it from
of_probe, convert it to a initcall at the appropriate level. This allows to moveof_probeto 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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox