lkml.org 
[lkml]   [2009]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2009-03-09 19:19    [W:0.028 / U:1.460 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site