linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Chengfeng Ye <dg573847474@gmail.com>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl, alex@shruggie.ro,
	aboutphysycs@gmail.com, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: timberdale: Fix potential deadlock on &tgpio->lock
Date: Tue, 26 Sep 2023 15:58:09 +0300	[thread overview]
Message-ID: <ZRLVYWDc/3IRJBor@smile.fi.intel.com> (raw)
In-Reply-To: <20230926102914.6145-1-dg573847474@gmail.com>

On Tue, Sep 26, 2023 at 10:29:14AM +0000, Chengfeng Ye wrote:
> As timbgpio_irq_enable()/timbgpio_irq_disable() callback could be
> executed under irq context, it could introduce double locks on
> &tgpio->lock if it preempts other execution units requiring
> the same locks.
> 
> timbgpio_gpio_set()
> --> timbgpio_update_bit()
> --> spin_lock(&tgpio->lock)
> <interrupt>
>    --> timbgpio_irq_disable()
>    --> spin_lock_irqsave(&tgpio->lock)
> 
> This flaw was found by an experimental static analysis tool I am
> developing for irq-related deadlock.
> 
> To prevent the potential deadlock, the patch uses spin_lock_irqsave()
> on &tgpio->lock inside timbgpio_gpio_set() to prevent the possible
> deadlock scenario.

Okay, makes sense.
Reviewed-by: Andy Shevchenko <andy@kernel.org>

Question to the users of this hardware if they ever want to have this IRQ chip
in the RT environment. In that case the locking type needs to be raw.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-09-26 12:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 10:29 [PATCH] gpio: timberdale: Fix potential deadlock on &tgpio->lock Chengfeng Ye
2023-09-26 12:58 ` Andy Shevchenko [this message]
2023-09-27  6:52 ` Bartosz Golaszewski
2023-09-27  6:54   ` Chengfeng Ye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRLVYWDc/3IRJBor@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=aboutphysycs@gmail.com \
    --cc=alex@shruggie.ro \
    --cc=brgl@bgdev.pl \
    --cc=dg573847474@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).