Re: interruptible_sleep_on, interrupts and device drivers

Russell King
2005-10-15T10:57:32Z

On Sat, Oct 15, 2005 at 12:36:29PM +0200, Arjan van de Ven wrote:
> On Sat, 2005-10-15 at 12:29 +0200, Gabriele Brugnoni wrote:
> > save_flags(flags); cli();
>
> this is broken code; cli() cannot and should not be used. (and isn't
> even available on SMP kernels anymore)
>
> > if( !rs.txdone ) {
> > if( arg < 0 ) arg = rs.ttimeout;
> > if( arg > 0 )
> > interruptible_sleep_on_timeout ( &rs.txwait, arg );
> > else
> > interruptible_sleep_on ( &rs.txwait );
> > }
> > restore_flags(flags);
>
> and this is missing a sti()

Err, no, that's wrong. sti() unconditionally enables interrupts - if
an sti() was placed here, it's pointless using save_flags() (which
saves the old interrupt enable state) and restore_flags() (which
restores the interrupt enable state).

Also remember that interruptible_sleep_* is only safe on UP machines
provided it's called with interrupts disabled.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core