Skip to contentSkip to conversation

console: USB: KBD: Fix incorrect autoboot timeout

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

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jim Lin

author
#0 lore raw

PATCH v2 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.

---
Changes in v2:
- use do-while and get_timer to count timeout

 common/main.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
common/main.c +5 -6
index b145f85..4dac01d 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,10 @@ int abortboot(int bootdelay)
 #endif
 
 	while ((bootdelay > 0) && (!abort)) {
-		int i;
-
 		--bootdelay;
-		/* delay 100 * 10ms */
-		for (i=0; !abort && i<100; ++i) {
+		/* delay 1000 ms */
+		ts = get_timer(0);
+		do {
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/
@@ -263,8 +263,7 @@ int abortboot(int bootdelay)
 # endif
 				break;
 			}
-			udelay(10000);
-		}
+		} while (!abort && get_timer(ts) < 1000);
 
 		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 v2 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.

Thanks. One minor nitpick...

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

Quoted 13 lines
common/main.c +4 -2
+		/* delay 1000 ms */
+		ts = get_timer(0);
+		do {
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/
@@ -263,8 +263,7 @@ int abortboot(int bootdelay)
 # endif
 				break;
 			}
-			udelay(10000);
-		}
+		} while (!abort && get_timer(ts) < 1000);

I recommend to keep a short udelay() [say, an udelay(1000)] in the loop, as this will make sure that watchdog still gets triggered on systems that need this.

Thaks.

Best regards,

Wolfgang Denk

Signature · 6 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: [email protected]
Oblivion together does not frighten me, beloved.
	-- Thalassa (in Anne Mulhall's body), "Return to Tomorrow",
	   stardate 4770.3.
author
#2 lore raw

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

Quoted 19 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.

Thanks. One minor nitpick...

Quoted 9 lines
common/main.c +3 -0
+		/* delay 1000 ms */
+		ts = get_timer(0);
+		do {
 			if (tstc()) {	/* we got a key press	*/
 				abort  = 1;	/* don't auto boot	*/
 				bootdelay = 0;	/* no more delay	*/
@@ -263,8 +263,7 @@ int abortboot(int bootdelay)
 # endif
 				break;
Quoted 9 lines

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

Quoted 4 lines
common/main.c +1 -2
 			}
-			udelay(10000);
-		}
+		} while (!abort && get_timer(ts) < 1000);

I recommend to keep a short udelay() [say, an udelay(1000)] in the loop, as this will make sure that watchdog still gets triggered on systems that need this.

I will keep
udelay(10000);
for safety in next patch.

Thanks.

-- nvpublic