lkml.org 
[lkml]   [2001]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Timers
On Sun, May 13, 2001 at 05:45:13PM +0100, Matt wrote:
> I'm having some major headaches trying to get a timer working in my
> driver.
>
> The timer is started when the device node is opened, and deleted when it's
> closed. The timer code itself calls mod_timer to add itself back in
> again. At the moment, it runs every second and does nothing more than
> issue a debug printk to say it's working okay.
>
> The problem comes when I try and wrap the timer code inside some down()
> and up() calls to make sure it's not fiddling with the hardware at the
> same time as some other calls. When I do this, I get a huge oops which
> goes right off my screen and I get the "Aieee..." message afterwards and I
> have to push the reset button :(.

You're trying to sleep in an interrupt, which is not allowed.

>
> Should I be using spin_(un)lock_irqsave() calls anywhere instead of just a
> semaphore? Or is there anything else I should be doing?

Yes you should. The only way to use a semaphore from interrupt context
(=timers) is to use down_trylock() and retry when it was locked, e.g. by
resetting the timer. That is normally awkward and irqsafe spinlocks are
probably better. Of course they cannot be held schedules or anything
that may sleep.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.036 / U:13.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site