Skip to contentSkip to conversation

console: USB: KBD: Fix incorrect autoboot timeout

PATCH Superseded Jim Lin 2 participants 3 messages Jan 23, 2013

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jim Lin

author
#0 lore raw

PATCH 1/1 console: USB: KBD: Fix incorrect autoboot timeout

Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in configuration file and when tstc() function for checking key pressed takes longer time than 10 ms (e.g., 50 ms) to finish.

---
 common/main.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
common/main.c +10 -3
index b145f85..8cdfb8b 100644
@@ -225,6 +225,7 @@ static inline
 int abortboot(int bootdelay)
 {
 	int abort = 0;
+	unsigned long ts;
 
 #ifdef CONFIG_MENUPROMPT
 	printf(CONFIG_MENUPROMPT);
@@ -248,11 +249,13 @@ int abortboot(int bootdelay)
 #endif
 
 	while ((bootdelay > 0) && (!abort)) {
-		int i;
+		int i, j;
 
 		--bootdelay;
 		/* delay 100 * 10ms */
-		for (i=0; !abort && i<100; ++i) {
+		j = 100;
+		for (i = 0; !abort && i < j; ++i) {
+			ts = get_timer(0);
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/
@@ -263,7 +266,11 @@ int abortboot(int bootdelay)
 # endif
 				break;
 			}
-			udelay(10000);
+			ts = get_timer(ts);
+			if (ts < 10)
+				mdelay(10 - ts);
+			else
+				j = 1000 / (int) ts;
 		}
 
 		printf("\b\b\b%2d ", bootdelay);
Signature · 9 lines
1.7.3


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
#1 lore raw

PATCH 1/1 console: USB: KBD: Fix incorrect autoboot timeout

Dear Jim Lin,

Quoted 4 lines · In message <[email protected]> you wrote:

Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in configuration file and when tstc() function for checking key pressed takes longer time than 10 ms (e.g., 50 ms) to finish.

...

Quoted 9 lines
common/main.c +3 -1
 		/* delay 100 * 10ms */
-		for (i=0; !abort && i<100; ++i) {
+		j = 100;
+		for (i = 0; !abort && i < j; ++i) {
+			ts = get_timer(0);
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/

common/main.c int abortboot(int bootdelay) · line 274

Quoted 10 lines
common/main.c +5 -1
@@ -263,7 +266,11 @@ int abortboot(int bootdelay)
 # endif
 				break;
 			}
-			udelay(10000);
+			ts = get_timer(ts);
+			if (ts < 10)
+				mdelay(10 - ts);
+			else
+				j = 1000 / (int) ts;
 		}

This is a pretty awkward implementation. If you feel the current plain delay loop based approach is not exact enough, then please implement a real timeout - you are calling the timer anyway, so just use the timer values instead of a loop count.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Quantum particles: The dreams that stuff is made of.
author
#2 lore raw

PATCH 1/1 console: USB: KBD: Fix incorrect autoboot timeout

Quoted 25 lines · Wolfgang Denk

Dear Jim Lin,

Quoted 4 lines · In message <[email protected]> you wrote:

Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in configuration file and when tstc() function for checking key pressed takes longer time than 10 ms (e.g., 50 ms) to finish.

...

Quoted 16 lines
common/main.c +6 -2
 		/* delay 100 * 10ms */
-		for (i=0; !abort && i<100; ++i) {
+		j = 100;
+		for (i = 0; !abort && i < j; ++i) {
+			ts = get_timer(0);
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/
@@ -263,7 +266,11 @@ int abortboot(int bootdelay)
 # endif
 				break;
 			}
-			udelay(10000);
+			ts = get_timer(ts);
+			if (ts < 10)
+				mdelay(10 - ts);
Quoted 9 lines

common/main.c int abortboot(int bootdelay) · line 274

Quoted 3 lines
common/main.c +2 -0
+			else
+				j = 1000 / (int) ts;
 		}

This is a pretty awkward implementation. If you feel the current plain delay loop based approach is not exact enough, then please implement a real timeout - you are calling the timer anyway, so just use the timer values instead of a loop count.

Thanks for pointing this out. I will improve it and resend.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------