All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@kernel.org>
To: Linus Walleij <linusw@kernel.org>
Cc: Runyu Xiao <runyu.xiao@seu.edu.cn>,
	 Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	 Robert Jarzmik <robert.jarzmik@free.fr>,
	Thierry Reding <thierry.reding@gmail.com>,
	 Jonathan Hunter <jonathanh@nvidia.com>,
	linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org,
	 linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: Question: GPIO direction callbacks calling pinctrl in atomic paths
Date: Mon, 22 Jun 2026 09:04:27 +0200	[thread overview]
Message-ID: <ajjdGVcCNAbIQIfj@orome> (raw)
In-Reply-To: <CAD++jLkL+WV+WYCy7YsQ6n8ZQH27gLHQKf+-CYiV3GU=dbgcUQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]

On Thu, Jun 18, 2026 at 03:25:49PM +0200, Linus Walleij wrote:
> Hi Runyu,
> 
> thanks for your report!
> 
> On Thu, Jun 18, 2026 at 5:11 AM Runyu Xiao <runyu.xiao@seu.edu.cn> wrote:
> 
> > The class of path we looked at is:
> >
> >   gpiod_direction_output_raw_commit()
> >     -> <driver>_gpio_direction_output()
> >        -> pinctrl_gpio_direction_output()
> >        -> pinctrl_get_device_gpio_range()
> >        -> mutex_lock(&pctldev->mutex)
> 
> Again that is mutex_lock(&pinctrldev_list_mutex); is it not?
> 
> If we go with my suggestion in the previous report to just
> replace this mutex with a spinlock, I think this issue will
> also be solved.
> 
> Am I right?

I'm not sure it's that simple to convert this to a spinlock. One one
hand this lock is taken around calls to mutex_lock(&pctldev->mutex), so
those could sleep and a spinlock would be wrong.

There's one other case where in addition to the nested pctldev->mutex,
we call some of the generic cleanup functions under the lock. Luckily it
looks like all of those should be safe to call under a spinlock since
they don't sleep themselves from what I can tell.

Maybe the locking order of pinctrldev_list_mutex vs. pctldev->mutex can
be changed to avoid that first issue?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2026-06-22  7:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18  3:06 Question: GPIO direction callbacks calling pinctrl in atomic paths Runyu Xiao
2026-06-18  6:52 ` Thierry Reding
2026-06-18 13:25 ` Linus Walleij
2026-06-18 15:08   ` Runyu Xiao
2026-06-22  7:04   ` Thierry Reding [this message]

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=ajjdGVcCNAbIQIfj@orome \
    --to=thierry.reding@kernel.org \
    --cc=brgl@kernel.org \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=jonathanh@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robert.jarzmik@free.fr \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=thierry.reding@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.