From: sashiko-bot@kernel.org
To: "Ju Nan" <junan76@163.com>
Cc: lee@kernel.org, linux-rt-devel@lists.linux.dev,
linux-kernel@vger.kernel.org, mfd@lists.linux.dev
Subject: Re: [PATCH v2] pinctrl: stm32: program the EXTI mux from .alloc instead of .activate
Date: Tue, 04 Aug 2026 03:38:23 +0000 [thread overview]
Message-ID: <20260804033824.3585B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804032227.35017-3-junan76@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hwspin_lock_timeout_in_atomic() is called in a sleepable context and held across a sleepable operation, leading to hardware lock corruption and co-processor lockups.
--
--- Patch [1]: [PATCH v2] pinctrl: stm32: program the EXTI mux from .alloc instead of .activate ---
commit e4c0724053fe56b6dc864fd8cb1577c252a8ed5b
Author: Ju Nan <junan76@163.com>
pinctrl: stm32: program the EXTI mux from .alloc instead of .activate
This commit moves the programming of the EXTI mux and its associated hardware
spinlock from the .activate callback (an atomic context) to the .alloc
callback (a sleepable context) to resolve invalid wait context bugs on
PREEMPT_RT.
Closes: https://lore.kernel.org/all/20220202174430.pf37tt6lua2op3gc@pengutronix.de/
> 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
[ ... ]
> @@ -653,6 +629,27 @@ static int stm32_gpio_domain_alloc(struct irq_domain *d,
> if (ret)
> return ret;
>
> + /*
> + * Now that the line is reserved, point its mux at this bank. Doing it
> + * here rather than from .activate() keeps the access out of the raw
> + * atomic section the irq core runs .activate() in; nothing needs it to
> + * be reprogrammed at startup time, and the resume path rewrites it on
> + * its own.
> + */
> + if (pctl->hwlock) {
> + ret = hwspin_lock_timeout_in_atomic(pctl->hwlock,
> + HWSPNLCK_TIMEOUT);
[Severity: High]
Since stm32_gpio_domain_alloc() runs in a sleepable context, could using the
_in_atomic variant of the hwspinlock lead to lock corruption?
The _in_atomic variant skips local locking, meaning it does not disable
preemption or local IRQs. Without preemption disabled, can two Linux threads
concurrently attempt to acquire the lock and corrupt its state?
> + if (ret) {
> + dev_err(pctl->dev, "Can't get hwspinlock\n");
> + goto err_free_mux;
> + }
> + }
> +
> + regmap_field_write(pctl->irqmux[hwirq], bank->bank_ioport_nr);
[Severity: High]
Can this sequence cause a deadlock with co-processors on PREEMPT_RT systems?
Hardware spinlocks are cross-core resources. Because this is now in a
sleepable context, regmap_field_write() can sleep on PREEMPT_RT while
contending for its lock. If the thread is preempted or sleeps while holding
the hardware spinlock, will co-processors attempting to acquire the lock
spin forever and hang?
> +
> + if (pctl->hwlock)
> + hwspin_unlock_in_atomic(pctl->hwlock);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804032227.35017-3-junan76@163.com?part=1
next prev parent reply other threads:[~2026-08-04 3:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 6:17 [PATCH] pinctrl: stm32: use a raw spinlock regmap to program the EXTI mux Ju Nan
2026-08-03 6:34 ` sashiko-bot
2026-08-04 3:03 ` Ju Nan
2026-08-04 3:22 ` [PATCH v2] pinctrl: stm32: program the EXTI mux from .alloc instead of .activate Ju Nan
2026-08-04 3:38 ` sashiko-bot [this message]
2026-08-04 14:14 ` [PATCH v3] " Ju Nan
2026-08-04 15:12 ` sashiko-bot
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=20260804033824.3585B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=junan76@163.com \
--cc=lee@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.