From: Tom Rini Date: Fri, 13 Dec 2013 09:09:10 -0500 Subject: [U-Boot] [PATCH] lib/time - fix "usec_to_tick" calculation for hi freq system timers In-Reply-To: <20131213130751.GD420@bill-the-cat> References: <1386593830-3197-1-git-send-email-abrodkin@synopsys.com> <1386918067.2883.1.camel@abrodkin-8560l.internal.synopsys.com> <20131213130751.GD420@bill-the-cat> Message-ID: <20131213140910.GG420@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Dec 13, 2013 at 08:07:51AM -0500, Tom Rini wrote: > On Fri, Dec 13, 2013 at 07:01:07AM +0000, Alexey Brodkin wrote: > > > Hi Tom, > > > > On Mon, 2013-12-09 at 16:57 +0400, Alexey Brodkin wrote: > > > Current implementation works fine if "usec * get_tbclk()" fits in 32 > > > bits. Otherwise result will be cut down to 32-bit. > > > > > > Fix is obvious - first extend data type of either operand. > > > > > > Signed-off-by: Alexey Brodkin > > > > > > Cc: Rob Herring > > > Cc: Mischa Jonker > > > --- > > > lib/time.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/lib/time.c b/lib/time.c > > > index 09bb05a..80003c3 100644 > > > --- a/lib/time.c > > > +++ b/lib/time.c > > > @@ -71,7 +71,7 @@ unsigned long __weak notrace timer_get_us(void) > > > } > > > static unsigned long long usec_to_tick(unsigned long usec) > > > { > > > - uint64_t tick = usec * get_tbclk(); > > > + uint64_t tick = (uint64_t)usec * get_tbclk(); > > > usec *= get_tbclk(); > > > do_div(tick, 1000000); > > > return tick; > > > > Any chance to get it applied? > > Yes, it's on my TODO list shortly, thanks. Please note that I'm taking http://patchwork.ozlabs.org/patch/297361/ as the solution for this problem, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: