From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Antonio Borneo <antonio.borneo@foss.st.com>,
Linus Walleij <linusw@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Ju Nan <junan76@163.com>,
linux-gpio@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 11/12] pinctrl: stm32: Protect irqmux restore with hwspinlock during resume
Date: Wed, 2 Dec 2026 09:30:05 +0000 [thread overview]
Message-ID: <f5e091f326df21947e11a6c41b4f7544a461a16f.1796203691.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796203691.git.lee@kernel.org>
Four IRQ lines share each 32-bit EXTI mux register in SYSCFG, and on
heterogeneous multi-core SoCs (such as STM32MP1) those registers are
shared with a remote coprocessor. While stm32_gpio_domain_alloc()
serialises regmap_field_write(pctl->irqmux[...]) with both
pctl->irqmux_lock and pctl->hwlock, stm32_pinctrl_restore_gpio_regs()
updates pctl->irqmux[offset] during resume without acquiring either
lock, risking a read-modify-write race with the coprocessor.
Acquire pctl->irqmux_lock and pctl->hwlock around the irqmux register
restore in stm32_pinctrl_restore_gpio_regs().
Fixes: e2f3cf18c3e2 ("pinctrl: stm32: add suspend/resume management")
Closes: https://sashiko.dev/#/bug/linux-f428a25e-342d-4e81-bdba-0948cff6c22d
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/stm32/pinctrl-stm32.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 01c8a646d9a0..897da5fafaf4 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -2094,9 +2094,27 @@ static int __maybe_unused stm32_pinctrl_restore_gpio_regs(
return ret;
}
- if (pin_is_irq)
+ if (pin_is_irq) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&pctl->irqmux_lock, flags);
+ if (pctl->hwlock) {
+ ret = hwspin_lock_timeout_in_atomic(pctl->hwlock,
+ HWSPNLCK_TIMEOUT_MS);
+ if (ret) {
+ dev_err(pctl->dev, "Can't get hwspinlock\n");
+ spin_unlock_irqrestore(&pctl->irqmux_lock, flags);
+ return ret;
+ }
+ }
+
regmap_field_write(pctl->irqmux[offset], bank->bank_ioport_nr);
+ if (pctl->hwlock)
+ hwspin_unlock_in_atomic(pctl->hwlock);
+ spin_unlock_irqrestore(&pctl->irqmux_lock, flags);
+ }
+
return 0;
}
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-02 9:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:29 [PATCH 00/12] pinctrl: Fix Critical and High issues reported by Sashiko (batch 3) Lee Jones
2026-12-02 9:29 ` [PATCH 01/12] pinctrl: stm32: Validate npins against STM32_GPIO_PINS_PER_BANK Lee Jones
2026-12-02 9:29 ` [PATCH 02/12] pinctrl: imx: Validate pin_id in imx_pinctrl_parse_pin_mmio() Lee Jones
2026-12-02 9:29 ` [PATCH 03/12] pinctrl: single: Protect group and function updates with pctldev->mutex Lee Jones
2026-12-02 14:08 ` Bartosz Golaszewski
2026-12-02 9:29 ` [PATCH 04/12] pinctrl: imx: Propagate DT parsing errors in imx_pinctrl_probe_dt() Lee Jones
2026-12-02 9:29 ` [PATCH 05/12] pinctrl: tegra: Require at least one register bank in tegra_pinctrl_probe() Lee Jones
2026-12-02 9:30 ` [PATCH 06/12] pinctrl: imx: Serialise MMIO register updates with a spinlock Lee Jones
2026-12-02 9:30 ` [PATCH 07/12] pinctrl: nuvoton: ma35: Avoid double free of shared pin configs Lee Jones
2026-12-02 9:30 ` [PATCH 08/12] pinctrl: keembay: Check src before calling keembay_find_free_slot() Lee Jones
2026-12-02 9:30 ` [PATCH 09/12] pinctrl: ti: iodelay: Protect generic group addition with pctldev->mutex Lee Jones
2026-12-02 9:30 ` [PATCH 10/12] pinctrl: sunxi: Serialise per-bank regulator request and free Lee Jones
2026-12-02 9:30 ` Lee Jones [this message]
2026-12-02 9:30 ` [PATCH 12/12] pinctrl: sx150x: Register threaded IRQ after adding GPIO chip Lee Jones
2026-12-02 9:35 ` Neil Armstrong
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=f5e091f326df21947e11a6c41b4f7544a461a16f.1796203691.git.lee@kernel.org \
--to=lee@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=antonio.borneo@foss.st.com \
--cc=junan76@163.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=stable@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
all inboxes | Powered by JetHome®