Skip to contentSkip to conversation

rockchip: Skip serial pinctrl at pre-reloc phase

PATCH In review Jonas Karlman 3 participants 10 messages Aug 5, 2024 – Sep 30, 2024 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover rockchip: Skip serial pinctrl at pre-reloc phase

UART pinctrl for serial is typically applied multiple times:
- in external TPL or in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

This series change bootph props for the UART pinctrl to not include them in pre-reloc phase to save some boot time:

- Radxa ROCK Pi S (RK3308): ~80 ms
- Radxa ZERO 3W (RK3566): ~120 ms
- Radxa ROCK 5B (RK3588): ~150 ms

Similar change has already been applied for RK3328 and RK3399 boards.

The change for PX30 has not been runtime tested, and only include change for uart2, not uart0 and uart5 used on two of the supported px30 boards.

Jonas Karlman (4):
rockchip: rk3308: Skip serial pinctrl at pre-reloc phase
rockchip: rk356x: Skip serial pinctrl at pre-reloc phase
rockchip: rk3588: Skip serial pinctrl at pre-reloc phase
rockchip: px30: Skip serial pinctrl at pre-reloc phase

 arch/arm/dts/px30-u-boot.dtsi                | 3 ++-
 arch/arm/dts/rk3308-evb-u-boot.dtsi          | 3 ++-
 arch/arm/dts/rk3308-roc-cc-u-boot.dtsi       | 3 ++-
 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi    | 3 ++-
 arch/arm/dts/rk3308-rock-s0-u-boot.dtsi      | 3 ++-
 arch/arm/dts/rk356x-u-boot.dtsi              | 3 ++-
 arch/arm/dts/rk3588-tiger-haikou-u-boot.dtsi | 3 ++-
 arch/arm/dts/rk3588-turing-rk1-u-boot.dtsi   | 3 ++-
 arch/arm/dts/rk3588s-u-boot.dtsi             | 3 ++-
 9 files changed, 18 insertions(+), 9 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/4 rockchip: rk3308: Skip serial pinctrl at pre-reloc phase

UART pinctrl for serial is typically applied multiple times:
- in external TPL
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Skip including UART pinctrl for the pre-reloc phase to save time during boot. On a Radxa ROCK Pi S this reduce boot time by ~80 ms.

After this a warning may be shown with LOGLEVEL=5 (or higher), it is safe to ignore this warning as device probe is successful even when pinctrl cannot be applied:

ns16550_serial serial@ff0a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

---
 arch/arm/dts/rk3308-evb-u-boot.dtsi       | 3 ++-
 arch/arm/dts/rk3308-roc-cc-u-boot.dtsi    | 3 ++-
 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi | 3 ++-
 arch/arm/dts/rk3308-rock-s0-u-boot.dtsi   | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)
arch/arm/dts/rk3308-evb-u-boot.dtsi +2 -1
index 007a69f9a60e..ce826667dcc2 100644
@@ -10,5 +10,6 @@
 };
 
 &uart4_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
arch/arm/dts/rk3308-roc-cc-u-boot.dtsi +2 -1
index 3e01e7af6113..72b6f223838b 100644
@@ -29,7 +29,8 @@
 };
 
 &uart2m0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
 
 &vcc_sd {
arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi +2 -1
index ff5bab316a34..3059a0246086 100644
@@ -14,7 +14,8 @@
 };
 
 &uart0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
 
 &vcc5v0_otg {
arch/arm/dts/rk3308-rock-s0-u-boot.dtsi +2 -1
index 84ca2ee0d5fb..dd4cb8660b8d 100644
@@ -13,7 +13,8 @@
 };
 
 &uart0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
 
 &vdd_core {
Signature · 1 line
2.45.2
#2 lore raw

PATCH 2/4 rockchip: rk356x: Skip serial pinctrl at pre-reloc phase

In reply to Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Skip including UART pinctrl for the pre-reloc phase to save time during boot. On a Radxa ZERO 3W this reduce boot time by ~120 ms.

After this a warning may be shown with LOGLEVEL=5 (or higher), it is safe to ignore this warning as device probe is successful even when pinctrl cannot be applied:

ns16550_serial serial@fe660000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

---
 arch/arm/dts/rk356x-u-boot.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/rk356x-u-boot.dtsi +2 -1
index 0a0943b462a9..9e03d2d8eb97 100644
@@ -163,7 +163,8 @@
 };
 
 &uart2m0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
 
 &xin24m {
Signature · 1 line
2.45.2
#3 lore raw

PATCH 3/4 rockchip: rk3588: Skip serial pinctrl at pre-reloc phase

In reply to Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Skip including UART pinctrl for the pre-reloc phase to save time during boot. On a Radxa ROCK 5B this reduce boot time by ~150 ms.

After this a warning may be shown with LOGLEVEL=5 (or higher), it is safe to ignore this warning as device probe is successful even when pinctrl cannot be applied:

ns16550_serial serial@feb50000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

---
 arch/arm/dts/rk3588-tiger-haikou-u-boot.dtsi | 3 ++-
 arch/arm/dts/rk3588-turing-rk1-u-boot.dtsi   | 3 ++-
 arch/arm/dts/rk3588s-u-boot.dtsi             | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
arch/arm/dts/rk3588-tiger-haikou-u-boot.dtsi +2 -1
index 275ae6fdaead..08ebb0af4482 100644
@@ -33,5 +33,6 @@
 };
 
 &uart2m2_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
arch/arm/dts/rk3588-turing-rk1-u-boot.dtsi +2 -1
index a50bcc45f216..59886b9828a4 100644
@@ -17,5 +17,6 @@
 };
 
 &uart9m0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
arch/arm/dts/rk3588s-u-boot.dtsi +2 -1
index 09d8b311cec5..df7e93d19c52 100644
@@ -154,7 +154,8 @@
 };
 
 &uart2m0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
 
 &xin24m {
Signature · 1 line
2.45.2
#4 lore raw

PATCH 4/4 rockchip: px30: Skip serial pinctrl at pre-reloc phase

In reply to Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Skip including UART pinctrl for the pre-reloc phase to save time during boot.

After this a warning may be shown with LOGLEVEL=5 (or higher), it is safe to ignore this warning as device probe is successful even when pinctrl cannot be applied:

ns16550_serial serial@ff160000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

---
 arch/arm/dts/px30-u-boot.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/px30-u-boot.dtsi +2 -1
index 3dc70d4e432b..2a0e85d92a2a 100644
@@ -38,7 +38,8 @@
 };
 
 &uart2m0_xfer {
-	bootph-all;
+	bootph-pre-sram;
+	bootph-pre-ram;
 };
 
 &uart5 {
Signature · 1 line
2.45.2
#5 lore raw
In reply to Jonas Karlman

Hi Jonas,

Quoted 10 lines · Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL or in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

This series change bootph props for the UART pinctrl to not include them in pre-reloc phase to save some boot time:

NACK. I feel like this is a hack for vendor trees only.

1) The Device Tree represents the hardware. We need the mux at all times.
2) This breaks users who want to have no serial in TPL/SPL but in proper (where you want it as soon as possible I assume, thus pre-reloc).
3) This likely also means if BL31 is configured to output on a different UART mux of the same controller for some reason (I've seen weird stuff), now U-Boot proper pre-reloc will not output anything as well.

Adding Lukasz in Cc who's trying to fix U-Boot so that this is possible on PX30 (therefore, not just a theoretical use case I'm bringing up ;) ).

Quoted 6 lines

- Radxa ROCK Pi S (RK3308): ~80 ms
- Radxa ZERO 3W (RK3566): ~120 ms
- Radxa ROCK 5B (RK3588): ~150 ms

Similar change has already been applied for RK3328 and RK3399 boards.

Then I believe this was a mistake.

Quoted 3 lines

The change for PX30 has not been runtime tested, and only include change for uart2, not uart0 and uart5 used on two of the supported px30 boards.

This means we have uart2 pinctrl at all stages even though we make no use of it?

I'm starting to wonder if this optimization isn't orthogonal to having as much support as possible via an <soc>-u-boot.dtsi which was done to make bring-up and maintenance easier. If you're really after optimization AND we keep the pinctrl for the debug uart (thus, not breaking 2) above), then what we want is cleaning up the default px30-u-boot.dtsi and move bootph properties to the board DTS instead?

I was a bit against this "turn-key" solution wrt u-boot DT for rk3568/rk3588 but we went ahead, are we changing our mind now? Just to know what exactly is the direction we are planning to take.

Cheers,
Quentin

#6 lore raw

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 7 lines · Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL or in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Quoted 5 lines
Quoted 3 lines

This series change bootph props for the UART pinctrl to not include them in pre-reloc phase to save some boot time:

NACK. I feel like this is a hack for vendor trees only.

I disagree, this just relaxes the bootph props currently enforced by <soc>-u-boot.dtsi files. For boards that has special need they can still add bootph-all or the bootph-some-ram prop to restore prior behavior.

Also please do not associate me with any vendor, I am a hobbyist :-)

Quoted 2 lines

1) The Device Tree represents the hardware. We need the mux at all times.

I do not think this changes the the description of the hardware in any way. The bootph props is currently already more of a representation of how software should behave than hardware.

In general for Rockchip use of the bootph-some-ram prop (pre-relocation phase) does not fully make any sense, since we already have full SDRAM in SPL.

If we where to fully follow the dtschema description for the bootph props, for Rockchip they should probably map to something like:

TPL:
- bootph-pre-sram: Enable this node when SRAM is not available.
- bootph-pre-ram: Enable this node in the phase that sets up SDRAM.

SPL:
- bootph-some-ram: Enable this node in the phase that is run after SDRAM is working but before all of it is available.

U-Boot pre-reloc:
- no prop mapping, we have all SDRAM and can use all devices, ideally for Rockchip we should just do bare minimum to relocate without loading any driver and then move to main post-reloc phase.

Instead they map to the different U-Boot software stages:
- bootph-pre-sram: TPL
- bootph-pre-ram: SPL
- bootph-some-ram: U-Boot pre-reloc

Quoted 2 lines

2) This breaks users who want to have no serial in TPL/SPL but in proper (where you want it as soon as possible I assume, thus pre-reloc).

Do you know of any such user/board? Adding the bootph-some-ram or bootph-all prop can easily be done in <board>-u-boot.dtsi for such user/board to restore current behavior.

Quoted 3 lines

3) This likely also means if BL31 is configured to output on a different UART mux of the same controller for some reason (I've seen weird stuff), now U-Boot proper pre-reloc will not output anything as well.

Same as for 2), adding the bootph-some-ram or bootph-all can and should be done at board level for boards that have special, or weird, requirements.

It is also possible to add board specific code that call debug_uart_init() early if you want to ensure pinmux without adding the unnecessary delay that use of pinctrl in pre-reloc brings.

Quoted 4 lines

Adding Lukasz in Cc who's trying to fix U-Boot so that this is possible on PX30 (therefore, not just a theoretical use case I'm bringing up ;) ).

Quoted 8 lines
Quoted 6 lines

- Radxa ROCK Pi S (RK3308): ~80 ms
- Radxa ZERO 3W (RK3566): ~120 ms
- Radxa ROCK 5B (RK3588): ~150 ms

Similar change has already been applied for RK3328 and RK3399 boards.

Then I believe this was a mistake.

My wording may have been misleading, when we added broad use of pinctrl props to SPL for rk3328/rk3399 we limited so that the uart pinctrl group was only enabled for TPL/SPL and not pre-reloc phase, because also including it at pre-reloc added 200-300 ms in extra boot time.

This series tries to apply same findings on remaining Rockchip aarch64 boards.

Quoted 7 lines
Quoted 4 lines

The change for PX30 has not been runtime tested, and only include change for uart2, not uart0 and uart5 used on two of the supported px30 boards.

This means we have uart2 pinctrl at all stages even though we make no use of it?

Yes, in my opinion the px30-u-boot.dtsi include lots of nodes that seem very board specific, some that probably should move to board specific u-boot.dtsi files.

Quoted 7 lines

I'm starting to wonder if this optimization isn't orthogonal to having as much support as possible via an <soc>-u-boot.dtsi which was done to make bring-up and maintenance easier. If you're really after optimization AND we keep the pinctrl for the debug uart (thus, not breaking 2) above), then what we want is cleaning up the default px30-u-boot.dtsi and move bootph properties to the board DTS instead?

Agree, for other aarch64 socs I have already tried to cleanup <soc>-u-boot.dtsi to only contain what more than 70-80% of all supported boards may need. For rk3399 bob and kevin even use /delete-property/ to remove some of the common boothp props because all other rk3399 boards benefited from those common boothp props.

I have no px30 board and the only rk3326 board I do have does not include the px30-u-boot.dtsi, so I will not try to do any cleanup of that file.

Quoted 4 lines

I was a bit against this "turn-key" solution wrt u-boot DT for rk3568/rk3588 but we went ahead, are we changing our mind now? Just to know what exactly is the direction we are planning to take.

Please elaborate, I do not understand what you mean by this.

The noticeable effect of boot time was discovered when reworking rk3399-u-boot.dtsi, after rk3568/rk3588 u-boot.dtsi already had gained a bootph-all prop in its uart2m0_xfer node. This try to apply those findings on a few more SoCs.

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#7 lore raw

Hi Jonas,

Quoted 17 lines · Jonas Karlman

Hi Quentin,

Quoted 14 lines · Quentin Schulz

Hi Jonas,

Quoted 10 lines · Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL or in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

This series change bootph props for the UART pinctrl to not include them in pre-reloc phase to save some boot time:

Quoted 9 lines
Quoted 1 line

NACK. I feel like this is a hack for vendor trees only.

I disagree, this just relaxes the bootph props currently enforced by <soc>-u-boot.dtsi files. For boards that has special need they can still add bootph-all or the bootph-some-ram prop to restore prior behavior.

Also please do not associate me with any vendor, I am a hobbyist :-)

Non-upstream = vendor for me :)

Quoted 32 lines
Quoted 2 lines

1) The Device Tree represents the hardware. We need the mux at all times.

I do not think this changes the the description of the hardware in any way. The bootph props is currently already more of a representation of how software should behave than hardware.

In general for Rockchip use of the bootph-some-ram prop (pre-relocation phase) does not fully make any sense, since we already have full SDRAM in SPL.

If we where to fully follow the dtschema description for the bootph props, for Rockchip they should probably map to something like:

TPL:
- bootph-pre-sram: Enable this node when SRAM is not available.
- bootph-pre-ram: Enable this node in the phase that sets up SDRAM.

SPL:
- bootph-some-ram: Enable this node in the phase that is run after SDRAM is working but before all of it is available.

U-Boot pre-reloc:
- no prop mapping, we have all SDRAM and can use all devices, ideally for Rockchip we should just do bare minimum to relocate without loading any driver and then move to main post-reloc phase.

Instead they map to the different U-Boot software stages:
- bootph-pre-sram: TPL
- bootph-pre-ram: SPL
- bootph-some-ram: U-Boot pre-reloc

Quoted 7 lines
Quoted 2 lines

2) This breaks users who want to have no serial in TPL/SPL but in proper (where you want it as soon as possible I assume, thus pre-reloc).

Do you know of any such user/board? Adding the bootph-some-ram or bootph-all prop can easily be done in <board>-u-boot.dtsi for such user/board to restore current behavior.

Yes, Lukasz in Cc has a device that is doing that, he'll be fixing a few things related to that soon (tm).

I would suggest to have one commit that basically moves bootph-all to all boards which currently include the -u-boot.dtsi where bootph-all is, and add bootph-pre-sram+pre-ram to -u-boot.dtsi. 0-sum change and then on a per-board basis remove this bootph-all? Basically, I'm not sure this is a sane default to have. For non-upstreamed boards, they can figure this out whenever they contribute. For upstreamed boards, I would aim at not possibly breaking stuff in the name of optimization?

The issue I believe is that you wouldn't be able to tell if there are users today since this should be a Kconfig symbol selection (SPL/TPL_SERIAL for example).

We could start having #ifdefs in -u-boot.dtsi for when $(SPL_TPL_)SERIAL is enabled if we wanted too. Not sure it's a welcomed added complexity though.

Quoted 8 lines
Quoted 3 lines

3) This likely also means if BL31 is configured to output on a different UART mux of the same controller for some reason (I've seen weird stuff), now U-Boot proper pre-reloc will not output anything as well.

Same as for 2), adding the bootph-some-ram or bootph-all can and should be done at board level for boards that have special, or weird, requirements.

It's just super weird to me to enter some corner cases because it works in most cases today and is bringing ~100ms boot time decrease.

Quoted 17 lines

It is also possible to add board specific code that call debug_uart_init() early if you want to ensure pinmux without adding the unnecessary delay that use of pinctrl in pre-reloc brings.

Quoted 4 lines

Adding Lukasz in Cc who's trying to fix U-Boot so that this is possible on PX30 (therefore, not just a theoretical use case I'm bringing up ;) ).

Quoted 8 lines
Quoted 6 lines

- Radxa ROCK Pi S (RK3308): ~80 ms
- Radxa ZERO 3W (RK3566): ~120 ms
- Radxa ROCK 5B (RK3588): ~150 ms

Similar change has already been applied for RK3328 and RK3399 boards.

Then I believe this was a mistake.

Quoted 8 lines

My wording may have been misleading, when we added broad use of pinctrl props to SPL for rk3328/rk3399 we limited so that the uart pinctrl group was only enabled for TPL/SPL and not pre-reloc phase, because also including it at pre-reloc added 200-300 ms in extra boot time.

This series tries to apply same findings on remaining Rockchip aarch64 boards.

What I'm complaining about in this patch series applies as well to the patches that are already merged if the intent and result are the same.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

The change for PX30 has not been runtime tested, and only include change for uart2, not uart0 and uart5 used on two of the supported px30 boards.

Quoted 7 lines
Quoted 2 lines

This means we have uart2 pinctrl at all stages even though we make no use of it?

Yes, in my opinion the px30-u-boot.dtsi include lots of nodes that seem very board specific, some that probably should move to board specific u-boot.dtsi files.

That I would welcome.

Quoted 14 lines
Quoted 7 lines

I'm starting to wonder if this optimization isn't orthogonal to having as much support as possible via an <soc>-u-boot.dtsi which was done to make bring-up and maintenance easier. If you're really after optimization AND we keep the pinctrl for the debug uart (thus, not breaking 2) above), then what we want is cleaning up the default px30-u-boot.dtsi and move bootph properties to the board DTS instead?

Agree, for other aarch64 socs I have already tried to cleanup <soc>-u-boot.dtsi to only contain what more than 70-80% of all supported boards may need. For rk3399 bob and kevin even use /delete-property/ to remove some of the common boothp props because all other rk3399 boards benefited from those common boothp props.

Quoted 4 lines

I have no px30 board and the only rk3326 board I do have does not include the px30-u-boot.dtsi, so I will not try to do any cleanup of that file.

Understood, this falls on someone else's shoulders then :)

Quoted 7 lines
Quoted 4 lines

I was a bit against this "turn-key" solution wrt u-boot DT for rk3568/rk3588 but we went ahead, are we changing our mind now? Just to know what exactly is the direction we are planning to take.

Please elaborate, I do not understand what you mean by this.

I looked a bit and could only find:
https://lore.kernel.org/u-boot/[email protected]/

This doesn't really match what I remembered of an "argument" I believe I had with Kever about putting stuff **I** didn't need for my boards in <soc>-u-boot.dtsi of which the answer was "I prefer to have something that works with minimal work than something that is optimized and require more work for newer boards". But cannot find it anymore, so maybe it was all in my head :)

Cheers,
Quentin

#8 lore raw

Hi Quentin,

Quoted 26 lines · Quentin Schulz

Hi Jonas,

Quoted 23 lines · Jonas Karlman

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 7 lines · Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL or in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Quoted 5 lines
Quoted 3 lines

This series change bootph props for the UART pinctrl to not include them in pre-reloc phase to save some boot time:

NACK. I feel like this is a hack for vendor trees only.

I disagree, this just relaxes the bootph props currently enforced by <soc>-u-boot.dtsi files. For boards that has special need they can still add bootph-all or the bootph-some-ram prop to restore prior behavior.

The pinctrl setting for the same module for multi times is obviously not a good idea,

and for SPL, it used to work without pinctrl which is simple and fast and enough for use.

Because in most case, people use the UART and storage with is the same as the bootrom

used, so the IO has been already been initialized.

This change works for most of the boards and for  different design can customize for its

usage, them the patch is acceptable, this is different default setting instead of hack.

Thanks,

- Kever

Quoted 145 lines
Quoted 3 lines

Also please do not associate me with any vendor, I am a hobbyist :-)

Non-upstream = vendor for me :)

Quoted 32 lines
Quoted 2 lines

1) The Device Tree represents the hardware. We need the mux at all times.

I do not think this changes the the description of the hardware in any way. The bootph props is currently already more of a representation of how software should behave than hardware.

In general for Rockchip use of the bootph-some-ram prop (pre-relocation phase) does not fully make any sense, since we already have full SDRAM in SPL.

If we where to fully follow the dtschema description for the bootph props, for Rockchip they should probably map to something like:

TPL:
- bootph-pre-sram: Enable this node when SRAM is not available.
- bootph-pre-ram: Enable this node in the phase that sets up SDRAM.

SPL:
- bootph-some-ram: Enable this node in the phase that is run after SDRAM is working but before all of it is available.

U-Boot pre-reloc:
- no prop mapping, we have all SDRAM and can use all devices, ideally for Rockchip we should just do bare minimum to relocate without loading any driver and then move to main post-reloc phase.

Instead they map to the different U-Boot software stages:
- bootph-pre-sram: TPL
- bootph-pre-ram: SPL
- bootph-some-ram: U-Boot pre-reloc

Quoted 7 lines
Quoted 2 lines

2) This breaks users who want to have no serial in TPL/SPL but in proper (where you want it as soon as possible I assume, thus pre-reloc).

Do you know of any such user/board? Adding the bootph-some-ram or bootph-all prop can easily be done in <board>-u-boot.dtsi for such user/board to restore current behavior.

Yes, Lukasz in Cc has a device that is doing that, he'll be fixing a few things related to that soon (tm).

I would suggest to have one commit that basically moves bootph-all to all boards which currently include the -u-boot.dtsi where bootph-all is, and add bootph-pre-sram+pre-ram to -u-boot.dtsi. 0-sum change and then on a per-board basis remove this bootph-all? Basically, I'm not sure this is a sane default to have. For non-upstreamed boards, they can figure this out whenever they contribute. For upstreamed boards, I would aim at not possibly breaking stuff in the name of optimization?

The issue I believe is that you wouldn't be able to tell if there are users today since this should be a Kconfig symbol selection (SPL/TPL_SERIAL for example).

We could start having #ifdefs in -u-boot.dtsi for when $(SPL_TPL_)SERIAL is enabled if we wanted too. Not sure it's a welcomed added complexity though.

Quoted 8 lines
Quoted 3 lines

3) This likely also means if BL31 is configured to output on a different UART mux of the same controller for some reason (I've seen weird stuff), now U-Boot proper pre-reloc will not output anything as well.

Same as for 2), adding the bootph-some-ram or bootph-all can and should be done at board level for boards that have special, or weird, requirements.

It's just super weird to me to enter some corner cases because it works in most cases today and is bringing ~100ms boot time decrease.

Quoted 17 lines

It is also possible to add board specific code that call debug_uart_init() early if you want to ensure pinmux without adding the unnecessary delay that use of pinctrl in pre-reloc brings.

Quoted 4 lines

Adding Lukasz in Cc who's trying to fix U-Boot so that this is possible on PX30 (therefore, not just a theoretical use case I'm bringing up ;) ).

Quoted 8 lines
Quoted 6 lines

- Radxa ROCK Pi S (RK3308): ~80 ms
- Radxa ZERO 3W (RK3566): ~120 ms
- Radxa ROCK 5B (RK3588): ~150 ms

Similar change has already been applied for RK3328 and RK3399 boards.

Then I believe this was a mistake.

Quoted 8 lines

My wording may have been misleading, when we added broad use of pinctrl props to SPL for rk3328/rk3399 we limited so that the uart pinctrl group was only enabled for TPL/SPL and not pre-reloc phase, because also including it at pre-reloc added 200-300 ms in extra boot time.

This series tries to apply same findings on remaining Rockchip aarch64 boards.

What I'm complaining about in this patch series applies as well to the patches that are already merged if the intent and result are the same.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

The change for PX30 has not been runtime tested, and only include change for uart2, not uart0 and uart5 used on two of the supported px30 boards.

Quoted 7 lines
Quoted 2 lines

This means we have uart2 pinctrl at all stages even though we make no use of it?

Yes, in my opinion the px30-u-boot.dtsi include lots of nodes that seem very board specific, some that probably should move to board specific u-boot.dtsi files.

That I would welcome.

Quoted 14 lines
Quoted 7 lines

I'm starting to wonder if this optimization isn't orthogonal to having as much support as possible via an <soc>-u-boot.dtsi which was done to make bring-up and maintenance easier. If you're really after optimization AND we keep the pinctrl for the debug uart (thus, not breaking 2) above), then what we want is cleaning up the default px30-u-boot.dtsi and move bootph properties to the board DTS instead?

Agree, for other aarch64 socs I have already tried to cleanup <soc>-u-boot.dtsi to only contain what more than 70-80% of all supported boards may need. For rk3399 bob and kevin even use /delete-property/ to remove some of the common boothp props because all other rk3399 boards benefited from those common boothp props.

Quoted 4 lines

I have no px30 board and the only rk3326 board I do have does not include the px30-u-boot.dtsi, so I will not try to do any cleanup of that file.

Understood, this falls on someone else's shoulders then :)

Quoted 7 lines
Quoted 4 lines

I was a bit against this "turn-key" solution wrt u-boot DT for rk3568/rk3588 but we went ahead, are we changing our mind now? Just to know what exactly is the direction we are planning to take.

Please elaborate, I do not understand what you mean by this.

I looked a bit and could only find:
https://lore.kernel.org/u-boot/[email protected]/

This doesn't really match what I remembered of an "argument" I believe I had with Kever about putting stuff **I** didn't need for my boards in <soc>-u-boot.dtsi of which the answer was "I prefer to have something that works with minimal work than something that is optimized and require more work for newer boards". But cannot find it anymore, so maybe it was all in my head :)

Cheers,
Quentin

#9 lore raw

Hi Kever,

Quoted 30 lines · Kever Yang

Hi Quentin,

Quoted 26 lines · Quentin Schulz

Hi Jonas,

Quoted 23 lines · Jonas Karlman

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 7 lines · Jonas Karlman

UART pinctrl for serial is typically applied multiple times:
- in external TPL or in TPL for DEBUG_UART in board_debug_uart_init()
- in SPL for DEBUG_UART in board_debug_uart_init()
- in SPL using pinctrl from DT
- in pre-reloc phase using pinctrl from DT
- after relocation using pinctrl from DT

Quoted 5 lines
Quoted 3 lines

This series change bootph props for the UART pinctrl to not include them in pre-reloc phase to save some boot time:

NACK. I feel like this is a hack for vendor trees only.

I disagree, this just relaxes the bootph props currently enforced by <soc>-u-boot.dtsi files. For boards that has special need they can still add bootph-all or the bootph-some-ram prop to restore prior behavior.

Quoted 8 lines

The pinctrl setting for the same module for multi times is obviously not a good idea,

and for SPL, it used to work without pinctrl which is simple and fast and enough for use.

Because in most case, people use the UART and storage with is the same as the bootrom

used, so the IO has been already been initialized.

Is the bootrom really initializing the UART? Are you sure you're not mixing bootrom and Rockchip's TPL blob? The latter, I know, the former, I'm surprised since it doesn't print anything as far as I am aware?

Quoted 4 lines

This change works for most of the boards and for  different design can customize for its

usage, them the patch is acceptable, this is different default setting instead of hack.

I disagree, this is working around the DT specs to make things faster by breaking some other usecases. I believe we shouldn't have to change the device tree when we change something in the defconfig for the board to still work.

I would be fine with a bunch of ifdefs in -u-boot.dtsi to have the appropriate bootph- properties guarded by the appropriate CONFIG_SPL_SERIAL/CONFIG_TPL_SERIAL, e.g. something like (not tested)

"""
// Optimize boot time by avoiding to reconfigure pinctrl already configured by earlier stages for console

#if IS_ENABLED(TPL_SERIAL)
    bootph-pre-sram;
#elif IS_ENABLED(SPL_SERIAL)
    bootph-pre-ram;
#else
    bootph-all;

#endif
"""

I also don't know what we should be doing with ROCKCHIP_EXTERNAL_TPL as we should probably have bootph-pre-ram/bootph-all set if that option is set, in case one uses the default blob from Rockchip but a different UART controller or mux so that they have console starting from upstream U-Boot at least.

What do you think?

Cheers,
Quentin