From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4] ARM: bcm283x: Switch to generic timer
Date: Wed, 6 May 2015 20:13:57 +0200 [thread overview]
Message-ID: <201505062013.57612.marex@denx.de> (raw)
In-Reply-To: <554A38C5.9070206@wwwdotorg.org>
On Wednesday, May 06, 2015 at 05:52:37 PM, Stephen Warren wrote:
[...]
> >>> So, if now is close to 0x7fffffff (which it can), then if endtime is
> >>> big-ish, diff will become negative and this udelay() will not perform
> >>> the correct delay, right ?
> >>
> >> I don't believe so, no.
> >>
> >> endtime and now are both unsigned. My (admittedly intuitive rather than
> >> well-researched) understanding of C math promotion rules means that
> >> "endtime - now" will be calculated as an unsigned value, then converted
> >> into a signed value to be stored in the signed diff. As such, I would
> >> expect the value of diff to be a small value in this case. I wrote a
> >> test program to validate this; endtime = 0x80000002, now = 0x7ffffffe,
> >> yields diff=4 as expected.
> >>
> >> Perhaps you meant a much larger endtime value than 0x80000002; perhaps
> >> 0xffffffff? This doesn't cause issues either. All that's relevant is the
> >> difference between endtime and now, not their absolute values, and not
> >> whether endtime has wrapped but now has or hasn't. For example, endtime
> >> = 0x00000002, now = 0xfffffff0 yields diff=18 as expected.
> >
> > So what if the difference is bigger than 1 << 31 ?
>
> As I said, I don't believe that case is relevant; it can only happen if
> passing ridiculously large delay values into __udelay() (i.e. greater
> than the 1<<31value you mention), and I don't believe there's any need
> to support that.
So what you say is that it's OK to have a function which is buggy in
corner cases ?
> The implementation in lib/time.c probably has exactly the same problem,
> except that since it uses 64-bit math rather than 32-bit math, so the
> issue happens at 1<<63 rather than 1<<31. It's probably equally
> problematic for delay values as large as 1<<63:-) In practice, given
> 1<<31 us is so large, I don't think there's any practical difference.
The implementation in lib/time.c uses 32bit usec argument though, so
it's not prone to this overflow. Please correct me if I'm wrong.
> >>>> Besides, what's passing a value >~36 minutes to udelay()?
> >>>
> >>> Nothing, but that doesn't mean we can have a possibly broken
> >>> implementation, right ?
> >>
> >> True. However, I'd expect that any specification for udelay would
> >> disallow such large parameter values, and hence its behaviour wouldn't
> >> be relevant if such values were passed.
> >
> > Do you think you can pick this patch and drop the "fixes overflow" part
> > or do you need resubmission ?
>
> Tom Rini (or in the past Albert Aribaud) actually apply the patches.
>
> Re: the patch description: I'd certainly be happy if it was re-written
> to say something more like "replace bcm2835-specific timer logic with
> common code to reduce the number of different implementations for the
> same thing".
Tom, do you want a repost ?
> I think you'd mentioned on IRC that this change fixed something
> USB-related for you, and I still don't understand how that could be
> possible. Perhaps there's some intermittent problem, and it just
> happened not to show up when you tested after this patch?
I think Tyler can elaborate on that, but in his test case, he still
triggers the USB issue.
next prev parent reply other threads:[~2015-05-06 18:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 20:54 [U-Boot] [PATCH 1/4] ARM: bcm283x: Repair wdog.h Marek Vasut
2015-05-04 20:54 ` [U-Boot] [PATCH 2/4] ARM: bcm283x: Reorder timer.h Marek Vasut
2015-05-28 13:25 ` [U-Boot] [U-Boot,2/4] " Tom Rini
2015-05-04 20:54 ` [U-Boot] [PATCH 3/4] ARM: mmc: bcm283x: Remove get_timer_us() from mmc driver Marek Vasut
2015-05-05 9:40 ` Pantelis Antoniou
2015-06-16 3:44 ` Stephen Warren
2015-06-17 10:44 ` Marek Vasut
2015-06-17 16:13 ` Jakub Kiciński
2015-06-18 12:35 ` Marek Vasut
2015-06-18 12:51 ` Jakub Kiciński
2015-06-19 21:39 ` Marek Vasut
2015-06-18 1:55 ` Stephen Warren
2015-05-04 20:54 ` [U-Boot] [PATCH 4/4] ARM: bcm283x: Switch to generic timer Marek Vasut
2015-05-05 21:46 ` Stephen Warren
2015-05-05 22:17 ` Marek Vasut
2015-05-05 22:37 ` Stephen Warren
2015-05-05 22:42 ` Marek Vasut
2015-05-05 22:57 ` Stephen Warren
2015-05-05 23:37 ` Marek Vasut
2015-05-06 15:52 ` Stephen Warren
2015-05-06 18:13 ` Marek Vasut [this message]
2015-05-06 19:51 ` Tyler Baker
2015-05-08 16:06 ` Stephen Warren
2015-05-08 16:23 ` Marek Vasut
2015-05-08 16:03 ` Stephen Warren
2015-05-08 16:31 ` Marek Vasut
2015-05-08 16:40 ` Stephen Warren
2015-05-08 18:20 ` Marek Vasut
2015-05-28 13:25 ` [U-Boot] [U-Boot,4/4] " Tom Rini
2015-05-28 13:25 ` [U-Boot] [U-Boot,1/4] ARM: bcm283x: Repair wdog.h Tom Rini
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=201505062013.57612.marex@denx.de \
--to=marex@denx.de \
--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 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.