From: Timur Tabi <timur@freescale.com>
To: Roland Dreier <rdreier@cisco.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] add function spin_event_timeout()
Date: Fri, 6 Mar 2009 19:25:08 -0600 [thread overview]
Message-ID: <ed82fe3e0903061725y40dc246ehd3482690ee3898fa@mail.gmail.com> (raw)
In-Reply-To: <adaiqmmf87v.fsf@cisco.com>
On Fri, Mar 6, 2009 at 7:11 PM, Roland Dreier <rdreier@cisco.com> wrote:
> > The function spin_event_timeout() takes a condition and timeout value
> > (in jiffies) as parameters. It spins until either the condition is true
> > or the timeout expires. It returns non-zero if the condition is true,
> > zero otherwise.
>
> What's the motivation for this? Where do you plan to use it?
I expect it would be useful for drivers that need to wait until a
specific register has changed its value, but don't want to risk an
infinite loop if the hardware is not functioning. For example, to
replace the while loop and subsequent check in this code:
long timeout = jiffies + 10;
setbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE);
/* Wait until the SSI has filled its FIFO. Without this
* delay, ALSA complains about overruns. When the FIFO
* is full, the DMA controller initiates its first
* transfer. Until then, however, the DMA's DAR
* register is zero, which translates to an
* out-of-bounds pointer. This makes ALSA think an
* overrun has occurred.
*/
while (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0) &&
(jiffies < timeout));
if (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0))
return -EIO;
> If we're going to make this core infrastructure, it seems we should
> implement it with all best practices... eg I would think the while loop
> should include cpu_relax().
Ok. I'll post version 2 on Monday. Anything else I'm missing?
--
Timur Tabi
Linux kernel developer at Freescale
next prev parent reply other threads:[~2009-03-07 1:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 0:13 Timur Tabi
2009-03-07 1:11 ` Roland Dreier
2009-03-07 1:25 ` Timur Tabi [this message]
2009-03-07 9:13 ` Jiri Slaby
2009-03-09 20:47 ` Jeremy Fitzhardinge
2009-03-09 20:51 ` Timur Tabi
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=ed82fe3e0903061725y40dc246ehd3482690ee3898fa@mail.gmail.com \
--to=timur@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rdreier@cisco.com \
/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
Powered by JetHome