From: sashiko-bot@kernel.org
To: "Ju Nan" <junan76@163.com>
Cc: linux-gpio@vger.kernel.org, linux-rt-devel@lists.linux.dev,
mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
lee@kernel.org
Subject: Re: [PATCH v4 1/2] pinctrl: stm32: Fix the unit of the hwspinlock timeout
Date: Wed, 14 Oct 2026 16:20:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-171521@kernel.org> (raw)
In-Reply-To: <20261014160917.139241-3-junan76@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pinctrl: stm32: same-CPU starvation with HWLOCK_IN_ATOMIC on PREEMPT_RT
--
commit 635cf6ace8c829d5e8fd3222bc79311f9ac07fc2
Author: Ju Nan <junan76@163.com>
pinctrl: stm32: Fix the unit of the hwspinlock timeout
This commit updates the hardware spinlock timeout parameter passed to
hwspin_lock_timeout_in_atomic(). It modifies the timeout constant name and
changes its value from microseconds to milliseconds across the stm32 pinctrl
driver to match the expected API units.
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
[ ... ]
> @@ -946,7 +946,7 @@ static int stm32_pmx_set_mode(struct stm32_gpio_bank *bank,
>
> if (pctl->hwlock) {
> err = hwspin_lock_timeout_in_atomic(pctl->hwlock,
> - HWSPNLCK_TIMEOUT);
> + HWSPNLCK_TIMEOUT_MS);
[Severity: High]
Does calling hwspin_lock_timeout_in_atomic() here cause a same-CPU starvation
issue on PREEMPT_RT?
Because hwspin_lock_timeout_in_atomic() uses the HWLOCK_IN_ATOMIC mode,
it implements the timeout by busy-waiting via udelay() and assumes preemption
is disabled by the caller.
However, on PREEMPT_RT, spin_lock_irqsave(&bank->lock) acquires an rt_mutex
which leaves preemption enabled.
If thread A acquires pctl->hwlock and is preempted, and thread B on the
same CPU subsequently acquires a different bank's lock and attempts to acquire
this shared pctl->hwlock, thread B will busy-wait.
Since thread B loops in a busy-wait for the entire 1ms timeout, thread A is
starved and cannot run to release the hardware lock, resulting in a guaranteed
spurious -ETIMEDOUT failure for thread B.
> if (err) {
> dev_err(pctl->dev, "Can't get hwspinlock\n");
> goto unlock;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014160917.139241-2-junan76@163.com?part=1
next prev parent reply other threads:[~2026-10-14 16:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 16:09 [PATCH v4 0/2] pinctrl: stm32: fix hwspinlock timeout and EXTI mux locking Ju Nan
2026-10-14 16:09 ` [PATCH v4 1/2] pinctrl: stm32: Fix the unit of the hwspinlock timeout Ju Nan
2026-10-14 16:20 ` sashiko-bot [this message]
2026-10-14 16:09 ` [PATCH v4 2/2] pinctrl: stm32: program the EXTI mux from .alloc instead of .activate Ju Nan
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=sashiko-outbox-171521@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=junan76@163.com \
--cc=lee@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mfd@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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.