Messages in this thread | | | Date | Mon, 09 Mar 2009 13:16:48 -0500 | From | Timur Tabi <> | Subject | Re: [PATCH v2] add function spin_event_timeout() |
| |
Peter Zijlstra wrote:
> This changelog utterly fails to justify this interface. And to me it > seems a rather bad one.
I'll update the commit to include a justification, but in the meantime, let me answer your question.
The primary purpose of this macro is to provide a way for drivers to poll a status register waiting for a bit to change. In most cases, this bit should change very quickly, even within a few cycles. The timeout is used as a way to easily deal with situations where the hardware is misprogrammed such that the bit never changes.
Too often, developers do something like this:
while (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0));
If something goes wrong and RFF0 never gets set, then this loop will never exit. So to encourage developers to do it the right way, and to make it simpler to identify code which does this sort of thing, I'm introducing spin_event_timeout().
> Why would we ever be wanting to spin in order of > jiffies?
I picked jiffies because it seems straightforward, but I think I see your point. It has two drawbacks:
1) It's too coarse of a time measurement. Most people will probably use a value of 1 or 2.
2) It can't be used if interrupts are disabled, because then jiffies won't be updated.
So I can switch that to using ndelay().
-- Timur Tabi Linux kernel developer at Freescale
| |