Skip to contentSkip to conversation

board: ti: am33xx: Fix serial_getc comparision in spl_start_uboot()

PATCH In review Sidharth Seela 2 participants 5 messages Sep 5, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: ti: am33xx: Fix serial_getc comparision in spl_start_uboot()

Fixes issue of uninterruptible SPL boot to OS, in falcon mode. Correct order of logical AND operation is (serial_tstc() && ( serial_getc() == 'c')), which fixes (serial_tstc() && serial_getc == 'c').

---

board/ti/am335x/board.c +1 -1
index 4ada8b534c1..1fb7d165d0b 100644
@@ -252,7 +252,7 @@ int spl_start_uboot(void)
 {
 #ifdef CONFIG_SPL_SERIAL
 	/* break into full u-boot on 'c' */
-	if (serial_tstc() && serial_getc() == 'c')
+	if (serial_tstc() && (serial_getc() == 'c'))
 		return 1;
 #endif
 
Signature · 1 line
2.47.2
#1 lore raw
Quoted 3 lines · On Fri, 5 Sep 2025 16:15:34 +0530 Sidharth Seela <[email protected]>…

Fixes issue of uninterruptible SPL boot to OS, in falcon mode. Correct order of logical AND operation is (serial_tstc() && ( serial_getc() == 'c')), which fixes (serial_tstc() && serial_getc == 'c').

This seems weird. == precede in terms of priority to &&, therefore the parentheses should not be needed here.

Quoted 17 lines
Quoted 1 line
Cc Tom Rini <[email protected]>

---

board/ti/am335x/board.c +1 -1
index 4ada8b534c1..1fb7d165d0b 100644
@@ -252,7 +252,7 @@ int spl_start_uboot(void)
 {
 #ifdef CONFIG_SPL_SERIAL
 	/* break into full u-boot on 'c' */
-	if (serial_tstc() && serial_getc() == 'c')
+	if (serial_tstc() && (serial_getc() == 'c'))
 		return 1;
 #endif
 
Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#2 lore raw
Quoted 4 lines · Kory Maincent

This seems weird. == precede in terms of priority to &&, therefore the parentheses should not be needed here.

is the issue maybe left to right interpretation of code?

Signature · 2 lines
Thanks,
Sidharth Seela
#3 lore raw
Quoted 7 lines · On Fri, 5 Sep 2025 17:00:21 +0530 Sidharth Seela <[email protected]>…
Quoted 4 lines · Kory Maincent

This seems weird. == precede in terms of priority to &&, therefore the parentheses should not be needed here.

is the issue maybe left to right interpretation of code?

Indeed inverting the condition will change the behavior, but is it really the issue here.
With the current condition test, serial_tstc() is called then if it return something not null, serial_getc() will read one character and compare it to 'c'.

According to documentation:
serial_tstc() - Test if data is available on currently selected serial port serial_getc() - Read character from currently selected serial port

I think the current order is correct, we should test available data before reading it.
Your issue may be somewhere else.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#4 lore raw
Quoted 8 lines · Kory Maincent

Indeed inverting the condition will change the behavior, but is it really the issue here.
With the current condition test, serial_tstc() is called then if it return something not null, serial_getc() will read one character and compare it to 'c'.

Quoted 7 lines

According to documentation:
serial_tstc() - Test if data is available on currently selected serial port serial_getc() - Read character from currently selected serial port

I think the current order is correct, we should test available data before reading it.
Your issue may be somewhere else.

I think you are right. I have tested it again without this patch and spammed 'c' like a lot, It works. ( One has to be really quick to spam 'c') Somehow, In previous iterations this was not observed, repeatedly. I think this patch is not required.

Thankyou Kory for your time.

Signature · 2 lines
Thanks
Sidharth Seela