public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jon Hunter <jon-hunter@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1 v3] console: USB: KBD: Fix incorrect autoboot timeout
Date: Thu, 21 Mar 2013 10:10:51 -0500	[thread overview]
Message-ID: <514B22FB.1000503@ti.com> (raw)
In-Reply-To: <201303210119.26050.marex@denx.de>

Hi Marek,

On 03/20/2013 07:19 PM, Marek Vasut wrote:
> Dear Jon Hunter,
> 
>> On 01/24/2013 05:05 AM, Jim Lin 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.
>>>
>>> Signed-off-by: Jim Lin <jilin@nvidia.com>
>>> ---
>>>
>>> Changes in v2:
>>>    - use do-while and get_timer to count timeout.
>>>
>>> Changes in v3:
>>>    - revert original udelay(10000); for safety.
>>>  
>>>  common/main.c |   10 +++++-----
>>>  1 files changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/common/main.c b/common/main.c
>>> index b145f85..dcd2a42 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	*/
>>>
>>> @@ -264,7 +264,7 @@ int abortboot(int bootdelay)
>>>
>>>  				break;
>>>  			
>>>  			}
>>>  			udelay(10000);
>>>
>>> -		}
>>> +		} while (!abort && get_timer(ts) < 1000);
>>>
>>>  		printf("\b\b\b%2d ", bootdelay);
>>>  	
>>>  	}
>>
>> This change is causing problems with auto-delay on one of my boards by
>> making it inaccurate :-(
>>
>> The question is what should get_timer() be returning? If it is meant to
>> be milliseconds then I guess I need to fix get_timer() for my board.
>> However, if it is just meant to be timer ticks at the SYS_HZ rate then I
>> don't see how the above change guarantees the do-while loop waits 1000
>> ms per iteration without normalising to SYS_HZ.
> 
> What board is it ?

It is an OMAP2420-H4 board (ARM11). The timer is using a very odd SYS_HZ
value of ~46875 (I believe this is because this is the most they can
divide down the 12MHz clock source by). The timer could be switched to
use a 32kHz clock source instead of the 12MHz clock source and get
something closer to 1ms. However, I would need to test to see if this
causes any other problems.

Cheers
Jon

  reply	other threads:[~2013-03-21 15:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24 11:05 [U-Boot] [PATCH 1/1 v3] console: USB: KBD: Fix incorrect autoboot timeout Jim Lin
2013-01-26  3:17 ` Marek Vasut
2013-01-26 13:14   ` Wolfgang Denk
2013-01-26 17:04     ` Marek Vasut
     [not found]     ` <5FBF8E85CA34454794F0F7ECBA79798F37A4D1D582@HQMAIL04.nvidia.com>
2013-01-28 16:37       ` Marek Vasut
2013-01-28 16:37       ` Tom Rini
2013-02-04 16:40 ` [U-Boot] [U-Boot, 1/1, " Tom Rini
2013-03-20 23:56 ` [U-Boot] [PATCH 1/1 " Jon Hunter
2013-03-21  0:19   ` Marek Vasut
2013-03-21 15:10     ` Jon Hunter [this message]
2013-03-21 19:19       ` Wolfgang Denk
2013-03-21  6:06   ` Jim Lin
2013-03-21  6:18   ` Stephen Warren
2013-03-21  6:57     ` Wolfgang Denk
2013-03-21 15:17       ` Jon Hunter
2013-03-21 19:15         ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=514B22FB.1000503@ti.com \
    --to=jon-hunter@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox