From: Joe Perches <joe@perches.com>
To: Mischa Jonker <Mischa.Jonker@synopsys.com>
Cc: "Vineet.Gupta1@synopsys.com" <Vineet.Gupta1@synopsys.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ARC: Fix __udelay parentheses
Date: Wed, 28 Aug 2013 18:43:50 -0700 [thread overview]
Message-ID: <1377740630.1928.71.camel@joe-AO722> (raw)
In-Reply-To: <E6BF041E97966E4DB955F0DF883AD2D684F1F648@de02wembxa.internal.synopsys.com>
On Wed, 2013-08-28 at 19:12 +0000, Mischa Jonker wrote:
> Hello Joe,
>
> > I don't see the loops_per_jiffy initial shift << 32.
>
> loops_per_jiffy * HZ = loops_per_second
> loops_per_jiffy * HZ = 1,000,000 * loops_per_us
> loops_per_jiffy * HZ * 4295 = 4,295,000 * loops_per_us
>
> loops_per_jiffy * HZ * 4294.967296 = 2^32 * loops_per_us
>
> > > > > - loops = ((long long)(usecs * 4295 * HZ) *
> > > > > - (long long)(loops_per_jiffy)) >> 32;
> > > > > + loops = (((long long) usecs) * 4295 * HZ *
> > > > > + (long long) loops_per_jiffy) >> 32;
>
> >
> > I know that. It's the use of a signed long long vs the unsigned long long
> > that I think wrong.
>
> Yes that is wrong too.
>
> >
> > Why cast a unsigned to a signed?
>
> I don't know, this was in the original file. The issue that I was trying to solve, was that usleep didn't sleep long enough, and that is fixed by this patch.
>
> Wrt signed/unsigned: would you like me to update this patch or create a separate one?
I think the whole thing is odd and it should simply be
loops = loops_per_jiffy * usecs_to_jiffies(usecs);
and if it's really necessary to have a u64 delay
then __delay should be rewritten to take an one
as an argument and this calc should be:
u64 loops = (u64)loops_per_jiffy * usecs_to_jiffies(usecs);
next prev parent reply other threads:[~2013-08-29 1:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-28 18:29 Mischa Jonker
2013-08-28 18:45 ` Joe Perches
2013-08-28 18:53 ` Mischa Jonker
2013-08-28 19:01 ` Joe Perches
2013-08-28 19:12 ` Mischa Jonker
2013-08-29 1:43 ` Joe Perches [this message]
2013-08-29 5:55 ` Vineet Gupta
2013-08-29 6:01 ` Joe Perches
2013-08-29 6:24 ` Vineet Gupta
2013-08-29 6:37 ` Joe Perches
2013-08-29 6:49 ` Vineet Gupta
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=1377740630.1928.71.camel@joe-AO722 \
--to=joe@perches.com \
--cc=Mischa.Jonker@synopsys.com \
--cc=Vineet.Gupta1@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®