* Deadlock in grgpio_irq_unmap()
@ 2015-08-02 16:15 Alexey Khoroshilov
2015-08-17 8:24 ` Alexandre Courbot
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2015-08-02 16:15 UTC (permalink / raw)
To: Andreas Larsson, Linus Walleij
Cc: Alexey Khoroshilov, Alexandre Courbot, linux-gpio, linux-kernel,
ldv-project
Dear colleagus,
grgpio_irq_unmap() code looks quite suspicious regarding usage of
priv->bgc.lock spinlock.
It locks the spinlock in line 310:
spin_lock_irqsave(&priv->bgc.lock, flags);
and then it can call grgpio_set_imask() in line 317:
grgpio_set_imask(priv, i, 0);
But grgpio_set_imask() unconditionally locks the spinlock by itself.
static void grgpio_set_imask(struct grgpio_priv *priv, unsigned int offset,
int val)
{
struct bgpio_chip *bgc = &priv->bgc;
unsigned long mask = bgc->pin2mask(bgc, offset);
unsigned long flags;
spin_lock_irqsave(&bgc->lock, flags);
if (val)
priv->imask |= mask;
else
priv->imask &= ~mask;
bgc->write_reg(priv->regs + GRGPIO_IMASK, priv->imask);
spin_unlock_irqrestore(&bgc->lock, flags);
}
So, it looks like unavoidable deadlock here.
Found by Linux Driver Verification project (linuxtesting.org).
--
Alexey Khoroshilov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Deadlock in grgpio_irq_unmap()
2015-08-02 16:15 Deadlock in grgpio_irq_unmap() Alexey Khoroshilov
@ 2015-08-17 8:24 ` Alexandre Courbot
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Courbot @ 2015-08-17 8:24 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Andreas Larsson, Linus Walleij, linux-gpio@vger.kernel.org,
Linux Kernel Mailing List, ldv-project
On Mon, Aug 3, 2015 at 1:15 AM, Alexey Khoroshilov
<khoroshilov@ispras.ru> wrote:
> Dear colleagus,
>
> grgpio_irq_unmap() code looks quite suspicious regarding usage of
> priv->bgc.lock spinlock.
>
> It locks the spinlock in line 310:
> spin_lock_irqsave(&priv->bgc.lock, flags);
> and then it can call grgpio_set_imask() in line 317:
> grgpio_set_imask(priv, i, 0);
>
> But grgpio_set_imask() unconditionally locks the spinlock by itself.
Indeed, this looks plain wrong. I have sent a fix that moves the
spinlock acquisition outside of grgpio_set_imask().
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-17 8:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-02 16:15 Deadlock in grgpio_irq_unmap() Alexey Khoroshilov
2015-08-17 8:24 ` Alexandre Courbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).