2012-07-31 18:28:16

by Denis Efremov

[permalink] [raw]
Subject: wlcore: might_sleep operation in interrupt handler

Interrupt handler wlcore_irq in wlcore/main.c file
invokes mutex_lock that is might sleep operation.

Found by Linux Driver Verification project (linuxtesting.org)
within my participation in the GSoC 2012 program.

drivers/net/wireless/ti/wlcore/main.c

static irqreturn_t wlcore_irq(int irq, void *cookie)
{
int ret;
unsigned long flags;
struct wl1271 *wl = cookie;

/* TX might be handled here, avoid redundant work */
set_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
cancel_work_sync(&wl->tx_work);

mutex_lock(&wl->mutex);
...
}

int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
{
...
ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wlcore_irq,
irqflags,
pdev->name, wl);
...
}


2012-07-31 20:48:18

by Denis Efremov

[permalink] [raw]
Subject: Re: wlcore: might_sleep operation in interrupt handler

More precise (IRQF_ONESHOT flag may be used):

int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
{
...
if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ)
irqflags = IRQF_TRIGGER_RISING;
else
irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;

ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wlcore_irq,
irqflags,
pdev->name, wl);


2012/8/1 Johannes Berg <[email protected]>:
> On Tue, 2012-07-31 at 22:28 +0400, Denis Yefremov wrote:
>> Interrupt handler wlcore_irq in wlcore/main.c file
>> invokes mutex_lock that is might sleep operation.
>
>> int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
>> {
>> ...
>> ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wlcore_irq,
>> irqflags,
>> pdev->name, wl);
>
> Yes, umm, why do you think they're using a *threaded* IRQ? :-)
>
> johannes
>

2012-07-31 20:15:07

by Johannes Berg

[permalink] [raw]
Subject: Re: wlcore: might_sleep operation in interrupt handler

On Tue, 2012-07-31 at 22:28 +0400, Denis Yefremov wrote:
> Interrupt handler wlcore_irq in wlcore/main.c file
> invokes mutex_lock that is might sleep operation.

> int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
> {
> ...
> ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wlcore_irq,
> irqflags,
> pdev->name, wl);

Yes, umm, why do you think they're using a *threaded* IRQ? :-)

johannes


2012-08-01 10:48:19

by Denis Efremov

[permalink] [raw]
Subject: Re: wlcore: might_sleep operation in interrupt handler

Sorry. My mistake. In this case it seems that sleep functions can
be called from thread_fn, since interrupt line is disabled globally.
And nothing bad will happen if you know that device can be
blocked for relatively long time.