Skip to contentSkip to conversation

board_r: re-order the board_early_init_r()

PATCH New Kever Yang 4 participants 8 messages Jul 24, 2019 – Aug 1, 2019

lore
Share & tools
lore

Kever Yang

author
#0 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

---

 common/board_r.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/board_r.c +3 -3
index abc31b17b8..c5e33c4654 100644
@@ -681,6 +681,9 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_DM
 	initr_dm,
 #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_R)
+	board_early_init_r,
+#endif
 #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
 	defined(CONFIG_SANDBOX)
 	board_init,	/* Setup chipselects */
@@ -712,9 +715,6 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_ADDR_MAP
 	initr_addr_map,
-#endif
-#if defined(CONFIG_BOARD_EARLY_INIT_R)
-	board_early_init_r,
 #endif
 	INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_POST
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

Quoted 6 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

Searching through the code, elixir.bootlin.com gives me 52 definitions of board_early_init_r(). Does this patch break any of those boards when it changes the order of those calls?

Regards,
Simon

Quoted 34 lines

---

 common/board_r.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/board_r.c +3 -4
index abc31b17b8..c5e33c4654 100644
@@ -681,6 +681,9 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_DM
        initr_dm,
 #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_R)
+       board_early_init_r,
+#endif
 #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
        defined(CONFIG_SANDBOX)
        board_init,     /* Setup chipselects */
@@ -712,9 +715,6 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_ADDR_MAP
        initr_addr_map,
-#endif
-#if defined(CONFIG_BOARD_EARLY_INIT_R)
-       board_early_init_r,
 #endif
        INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_POST
--

2.17.1

author
#2 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

Quoted 9 lines · Simon Goldschmidt
Quoted 5 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

Searching through the code, elixir.bootlin.com gives me 52 definitions of board_early_init_r(). Does this patch break any of those boards when it changes the order of those calls?

I do have check some of the implement and most of them should be OK, but to be honest,

I'm don't have any of those boards, and not sure if this break any of them, and I'm not sure

if people using this interface have notice it's after the board_init().

When I try to use this board_early_init_r(), I thought this is before board_init(), but it actually

after the board_init(), that make people confusing.

I think the _early_ one should be at the first, isn't it?

Thanks,
- Kever

Quoted 37 lines

Regards,
Simon

Quoted 33 lines

---

  common/board_r.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
common/board_r.c +3 -4
index abc31b17b8..c5e33c4654 100644
@@ -681,6 +681,9 @@ static init_fnc_t init_sequence_r[] = {
  #ifdef CONFIG_DM
         initr_dm,
  #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_R)
+       board_early_init_r,
+#endif
  #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
         defined(CONFIG_SANDBOX)
         board_init,     /* Setup chipselects */
@@ -712,9 +715,6 @@ static init_fnc_t init_sequence_r[] = {
  #endif
  #ifdef CONFIG_ADDR_MAP
         initr_addr_map,
-#endif
-#if defined(CONFIG_BOARD_EARLY_INIT_R)
-       board_early_init_r,
  #endif
         INIT_FUNC_WATCHDOG_RESET
  #ifdef CONFIG_POST
--

2.17.1

#3 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

Quoted 18 lines · Kever Yang
Quoted 9 lines · Simon Goldschmidt
Quoted 5 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

Searching through the code, elixir.bootlin.com gives me 52 definitions of board_early_init_r(). Does this patch break any of those boards when it changes the order of those calls?

I do have check some of the implement and most of them should be OK, but to be honest,

I'm don't have any of those boards, and not sure if this break any of them, and I'm not sure

Quoted 8 lines

if people using this interface have notice it's after the board_init().

When I try to use this board_early_init_r(), I thought this is before board_init(), but it actually

after the board_init(), that make people confusing.

I think the _early_ one should be at the first, isn't it?

I agree. Maybe we should rename it to board_post_init?

Regards,
Matthias

author
#4 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

Quoted 20 lines · Matthias Brugger
Quoted 18 lines · Kever Yang
Quoted 9 lines · Simon Goldschmidt
Quoted 5 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

Searching through the code, elixir.bootlin.com gives me 52 definitions of board_early_init_r(). Does this patch break any of those boards when it changes the order of those calls?

I do have check some of the implement and most of them should be OK, but to be honest,

I'm don't have any of those boards, and not sure if this break any of them, and I'm not sure

if people using this interface have notice it's after the board_init().

Quoted 7 lines
Quoted 6 lines

When I try to use this board_early_init_r(), I thought this is before board_init(), but it actually

after the board_init(), that make people confusing.

I think the _early_ one should be at the first, isn't it?

I agree. Maybe we should rename it to board_post_init?

Sorry , do you mean add/rename a board_post_init() for what's done by board_early_init_r() now and then add/move ad board api before board_init()? There is a board_late_init(), which is after env init, a new board_post_init() seems
not a good idea.

Here is the Kconfig help for BOARD_EARLY_INIT_R, which also means we it should
be called before board_init().

config BOARD_EARLY_INIT_R
        bool "Call board-specific init after relocation"
help
          Some boards need to perform initialisation as directly after relocation. With this option, U-Boot calls board_early_init_r() in the post-relocation init sequence.

Thanks,

- Kever

Quoted 4 lines

Regards,
Matthias

#5 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

Quoted 27 lines · Kever Yang
Quoted 25 lines · Matthias Brugger
Quoted 23 lines · Kever Yang
Quoted 9 lines · Simon Goldschmidt
Quoted 5 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

Searching through the code, elixir.bootlin.com gives me 52 definitions of board_early_init_r(). Does this patch break any of those boards when it changes the order of those calls?

I do have check some of the implement and most of them should be OK, but to be honest,

I'm don't have any of those boards, and not sure if this break any of them, and I'm not sure

if people using this interface have notice it's after the board_init().

When I try to use this board_early_init_r(), I thought this is before board_init(), but it actually

after the board_init(), that make people confusing.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

I think the _early_ one should be at the first, isn't it?

I agree. Maybe we should rename it to board_post_init?

Sorry , do you mean add/rename a board_post_init() for what's done by board_early_init_r() now and then add/move ad board api before board_init()? There is a board_late_init(), which is after env init, a new board_post_init() seems
not a good idea.

My idea was to rename board_early_init_r to board_post_init as it is done after board_init but before board_late_init. It's not perfect but at least less confusing then the naming right now.

Regards,
Matthias

Quoted 22 lines

Here is the Kconfig help for BOARD_EARLY_INIT_R, which also means we it should be called before board_init().

config BOARD_EARLY_INIT_R
        bool "Call board-specific init after relocation"
help
          Some boards need to perform initialisation as directly after relocation. With this option, U-Boot calls board_early_init_r() in the post-relocation init sequence.

Thanks,

- Kever

Quoted 4 lines

Regards,
Matthias

#6 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

Hi Matthias,

Quoted 40 lines · Matthias Brugger
Quoted 27 lines · Kever Yang
Quoted 25 lines · Matthias Brugger
Quoted 23 lines · Kever Yang
Quoted 9 lines · Simon Goldschmidt
Quoted 5 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

Searching through the code, elixir.bootlin.com gives me 52 definitions of board_early_init_r(). Does this patch break any of those boards when it changes the order of those calls?

I do have check some of the implement and most of them should be OK, but to be honest,

I'm don't have any of those boards, and not sure if this break any of them, and I'm not sure

if people using this interface have notice it's after the board_init().

When I try to use this board_early_init_r(), I thought this is before board_init(), but it actually

after the board_init(), that make people confusing.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

I think the _early_ one should be at the first, isn't it?

I agree. Maybe we should rename it to board_post_init?

Sorry , do you mean add/rename a board_post_init() for what's done by board_early_init_r() now and then add/move ad board api before board_init()? There is a board_late_init(), which is after env init, a new board_post_init() seems
not a good idea.

Quoted 3 lines

My idea was to rename board_early_init_r to board_post_init as it is done after board_init but before board_late_init. It's not perfect but at least less confusing then the naming right now.

No I really think we should merge them. If we really cannot, then let's rename board_early_init_r() to board_init_powerpc() for now.

Regards,
Simon

Quoted 26 lines

Regards,
Matthias

Quoted 22 lines

Here is the Kconfig help for BOARD_EARLY_INIT_R, which also means we it should be called before board_init().

config BOARD_EARLY_INIT_R
bool "Call board-specific init after relocation"
help
Some boards need to perform initialisation as directly after relocation. With this option, U-Boot calls board_early_init_r() in the post-relocation init sequence.

Thanks,

- Kever

Quoted 4 lines

Regards,
Matthias

#7 lore raw

PATCH 1/1 board_r: re-order the board_early_init_r()

In reply to Kever Yang

Hi Kever,

Quoted 6 lines · Kever Yang

The board_early_init_r() suppose to be called before board_init(), then the board callback functions in board_r will be:
- board_early_init_r()
- board_init()
- board_late_init()

board_early_init_r() was introduced for PowerPC as part of creating the generic board-init code (board_f.c and board_r.c).

I wonder whether any board is actually using both board_init() and board_early_init_r(). To me they serve the same function.

So I think we should remove board_early_init_r() and change all uses to board_init() instead. I expect they will mostly be PowerPC.

Quoted 32 lines

---

 common/board_r.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/board_r.c +3 -4
index abc31b17b8..c5e33c4654 100644
@@ -681,6 +681,9 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_DM
        initr_dm,
 #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_R)
+       board_early_init_r,
+#endif
 #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
        defined(CONFIG_SANDBOX)
        board_init,     /* Setup chipselects */
@@ -712,9 +715,6 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_ADDR_MAP
        initr_addr_map,
-#endif
-#if defined(CONFIG_BOARD_EARLY_INIT_R)
-       board_early_init_r,
 #endif
        INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_POST
--
Quoted 2 lines

2.17.1

Regards,
Simon