Re: [PATCH] Video : Amba: Use in_interrupt() in clcdfb_sleep().

From
Russell King - ARM Linux <hidden>
Date
2012-03-11 15:49:00
Also in
kernel-janitors, lkml
Reply to
santosh prasad nayak, 2012-03-11
On Sun, Mar 11, 2012 at 08:49:27PM +0530, santosh prasad nayak wrote:
On Sun, Mar 11, 2012 at 8:33 PM, Russell King - ARM Linux
[off-list ref] wrote:
quoted
in_interrupt() won't tell us if we're being called with spinlocks held,
which _is_ a possibility because this can be called from printk(), for
oops dumps and the like.

in_interrupt() just means that we're inside a hard or soft interrupt,
or nmi.  It says nothing about whether msleep() is possible.

in_atomic() is also not  error free.  I found following comment in
include/linux/hardirq.h.  How do you handle it in non-preemptible
kernel ?

/*
 * Are we running in atomic context?  WARNING: this macro cannot
 * always detect atomic context; in particular, it cannot know about
 * held spinlocks in non-preemptible kernels.  Thus it should not be
 * used in the general case to determine whether sleeping is possible.
 * Do not use in_atomic() in driver code.
 */
#define in_atomic()     ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
That may be, but the fact of the matter is that no one has *ever*
reported an incident where this has failed at this point - and when
it does people will end up with a might_sleep() warning from msleep().

Maybe those who are saying people should not use this should instead
be analysing why people use this, and suggest an alternative solution
to the problem instead of a basic and uninformative "you shouldn't use
this" statement.

As I've said, if we aren't going to use this, then the only solution is
to completely omit the msleep() there and just say "sod you to running
anything else for 20ms while this driver busy-spins."  That's
ultimately the safe thing to do, and at the moment I see no other
alternative there.
Thread (14 messages) 14 messages, 4 authors, last reply 2012-03-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help