From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: Guarantee udelay(N) spins at least N microseconds
Date: Fri, 10 Apr 2015 12:44:16 +0100 [thread overview]
Message-ID: <20150410114415.GC12732@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <5527B331.5000205@free.fr>
On Fri, Apr 10, 2015 at 01:25:37PM +0200, Mason wrote:
> If I understand correctly, most drivers expect udelay(N) to spin for
> at least N ?s. Is that correct? In that use case, spinning less might
> introduce subtle heisenbugs.
We've never guaranteed this.
The fact is that udelay() can delay for _approximately_ the time you
ask for - it might be slightly shorter, or it could be much longer
than you expect. On most UP implementations using the software loop
it will typically be around 1% slower than requested.
Adding 1us to every delay is going to be very bad. Rather than doing
that, why not arrange for the rounding error to be accomodated?
> Typical example
>
> timer->freq = 90 kHz && HZ = 100
> (thus UDELAY_MULT = 107374 && ticks_per_jiffy = 900)
>
> udelay(10) => __timer_const_udelay(10*107374)
> => __timer_delay((1073740*900) >> 30)
> => __timer_delay(0)
In other words, add (1 << 30) - 1 before shifting right by 30.
--
FTTC broadband for 0.8mile line: currently@10.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2015-04-10 11:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 11:25 Guarantee udelay(N) spins at least N microseconds Mason
2015-04-10 11:42 ` Willy Tarreau
2015-04-10 14:53 ` Mason
2015-04-10 15:06 ` Willy Tarreau
2015-04-10 11:44 ` Russell King - ARM Linux [this message]
2015-04-10 12:41 ` Mason
2015-04-10 15:06 ` Russell King - ARM Linux
2015-04-10 15:30 ` Mason
2015-04-10 16:08 ` Russell King - ARM Linux
2015-04-10 20:01 ` Mason
2015-04-10 20:42 ` Russell King - ARM Linux
2015-04-10 21:22 ` Mason
2015-04-11 7:30 ` Russell King - ARM Linux
2015-04-11 11:57 ` Mason
2015-04-11 12:10 ` Russell King - ARM Linux
2015-04-11 13:45 ` Mason
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=20150410114415.GC12732@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).