All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout
@ 2013-01-23 10:38 Jim Lin
  2013-01-23 19:33 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Lin @ 2013-01-23 10:38 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Jim Lin <jilin@nvidia.com>
---
Changes in v2:
   - use do-while and get_timer to count timeout

 common/main.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/common/main.c b/common/main.c
index b145f85..4dac01d 100644
--- a/common/main.c
+++ b/common/main.c
@@ -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);
 	}
-- 
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.
-----------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout
  2013-01-23 10:38 [U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout Jim Lin
@ 2013-01-23 19:33 ` Wolfgang Denk
  2013-01-24 10:38   ` Jim Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2013-01-23 19:33 UTC (permalink / raw)
  To: u-boot

Dear Jim Lin,

In message <1358937511-32664-1-git-send-email-jilin@nvidia.com> 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...

> +		/* 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

-- 
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@denx.de
Oblivion together does not frighten me, beloved.
	-- Thalassa (in Anne Mulhall's body), "Return to Tomorrow",
	   stardate 4770.3.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout
  2013-01-23 19:33 ` Wolfgang Denk
@ 2013-01-24 10:38   ` Jim Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Lin @ 2013-01-24 10:38 UTC (permalink / raw)
  To: u-boot

On Thu, 2013-01-24 at 03:33 +0800, Wolfgang Denk wrote:
> Dear Jim Lin,
> 
> In message <1358937511-32664-1-git-send-email-jilin@nvidia.com> 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...
> 
> > +		/* 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.
> 
I will keep
   udelay(10000);
for safety in next patch.

Thanks.

-- nvpublic

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-24 10:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 10:38 [U-Boot] [PATCH 1/1 v2] console: USB: KBD: Fix incorrect autoboot timeout Jim Lin
2013-01-23 19:33 ` Wolfgang Denk
2013-01-24 10:38   ` Jim Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.