Re: interruptible_sleep_on, interrupts and device drivers

Arjan van de Ven
2005-10-15T10:36:40Z

On Sat, 2005-10-15 at 12:29 +0200, Gabriele Brugnoni wrote:
> Arjan van de Ven wrote:
>
> >
> > don't.
> >
> > interruptible_sleep_on() is a broken interface (see the comments in the
> > header) and should not be used in any new code (where "new" is "since
> > the year 2000" :)
> >
> > Just use the wait_event() interfaces .... or just a simple semaphore
> > even if what you want to do is simple and performance isn't too
> > critical.
> >
>
> OK, i'll not use, but the kernel has a lot of device drivers using it, that
> may present the problem explained in my message.
>
> In my code i've try the following:
>
> 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()

> return rs.txdone;

your code is just wrong. Yes I know many really old drivers do this, but
those are getting extinct fast..