Re: [PATCH v2] pinctrl: stm32: program the EXTI mux from .alloc instead of .activate
[email protected] Tue, 04 Aug 2026 03:38:23 +0000
| Newsgroups | dev.linux.lists.linux-rt-devel,dev.linux.lists.mfd,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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 a= nd held across a sleepable operation, leading to hardware lock corruption a= nd co-processor lockups. -- --- Patch [1]: [PATCH v2] pinctrl: stm32: program the EXTI mux from .alloc = instead of .activate --- commit e4c0724053fe56b6dc864fd8cb1577c252a8ed5b Author: Ju Nan <[email protected]> pinctrl: stm32: program the EXTI mux from .alloc instead of .activate This commit moves the programming of the EXTI mux and its associated hardwa= re 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@pengutr= onix.de/ > diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm3= 2/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; > =20 > + /* > + * 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 =3D 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=20 sleepable context, regmap_field_write() can sleep on PREEMPT_RT while contending for its lock. If the thread is preempted or sleeps while holding= =20 the hardware spinlock, will co-processors attempting to acquire the lock=20 spin forever and hang? > + > + if (pctl->hwlock) > + hwspin_unlock_in_atomic(pctl->hwlock); --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260804032227.3501= [email protected]?part=3D1