From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Matthias_Wei=DFer?= Date: Mon, 09 Aug 2010 08:55:37 +0200 Subject: [U-Boot] [PATCH V5 1/3] arm: Add support for MB86R0x SoCs In-Reply-To: <20100807213541.ACF031536EF@gemini.denx.de> References: <1280734550-18403-1-git-send-email-weisserm@arcor.de> <1280734550-18403-2-git-send-email-weisserm@arcor.de> <20100807213541.ACF031536EF@gemini.denx.de> Message-ID: <4C5FA669.6070303@arcor.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Wolfgang Am 07.08.2010 23:35, schrieb Wolfgang Denk: > Dear Matthias Weisser, > > In message<1280734550-18403-2-git-send-email-weisserm@arcor.de> you wrote: >> +void __udelay(unsigned long usec) >> +{ >> + unsigned long long tmp; >> + ulong tmo; >> + >> + tmo = usec_to_tick(usec); >> + tmp = get_ticks() + tmo; /* get current timestamp */ >> + >> + while (get_ticks()< tmp) /* loop till event */ >> + /*NOP*/; > > This is broken when the timer wraps around. Compare the limit against > the difference, to make use of unsigned arithmetics. Isn't this a theoretical problem? The timer increments with approx. 160kHz. get_ticks() returns a 64 bit value which wraps all ~ 3*10^6 years. I don't expect my hardware to work that long without a reboot. Can you point me to an example where the timer stuff is done right? I see it done differently on nearly all ARM SOCs. Thanks for the review Matthias