Skip to content

pinctrl: stm32: fix hwspinlock timeout and EXTI mux locking

Ju Nan linux-arm-kernel linux-gpio linux-rt-devel lkml mfd 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 2 repliesIn review
  2. v21 patch 1 replySuperseded
  3. v11 patch 1 replySuperseded

Changes in v4 from the cover letter

- make the two patches a series to resolve the dependency issue
- reproduce the bug fixed by patch 2 on a modified version of STM32MP157-DK board with kernel version 7.1.13
- check the concurrent-requester case raised by Antonio in v3: the second bank is rejected in .alloc under irqmux_lock (details in patch 2)

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2pinctrl: stm32: Fix the unit of the hwspinlock timeoutdrivers/pinctrl/stm32/pinctrl-stm32.c+8 -80 replies
2/2pinctrl: stm32: program the EXTI mux from .alloc instead of .activatedrivers/pinctrl/stm32/pinctrl-stm32.c+19 -270 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/2] pinctrl: stm32: fix hwspinlock timeout and EXTI mux locking

This series fixes two problems around the hwspinlock-protected EXTI mux and pin configuration accesses in the STM32 pinctrl driver.

Patch 1 fixes the timeout passed to hwspin_lock_timeout_in_atomic(). The value was written as 1000 microseconds, but the argument is in milliseconds, so the driver could busy-wait for up to one second with interrupts disabled instead of the intended one millisecond. It is a standalone fix and can be applied on its own.

Patch 2 moves the EXTI mux programming from the irq domain .activate callback to .alloc. .activate runs under the raw desc->lock, while the mux is written through a syscon regmap protected by a spinlock_t, which lockdep reports as an invalid wait context and which is a real bug on PREEMPT_RT. This was originally reported by Uwe Kleine-König in 2022. .alloc runs in sleepable context and already reserves the mux line, so the write now happens in the same irqmux_lock section as the reservation. While at it, the reservation is released when the hwspinlock cannot be taken.

---
Changes in v4:

- make the two patches a series to resolve the dependency issue
- reproduce the bug fixed by patch 2 on a modified version of STM32MP157-DK board with kernel version 7.1.13
- check the concurrent-requester case raised by Antonio in v3: the second bank is rejected in .alloc under irqmux_lock (details in patch 2)

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Ju Nan (2):
pinctrl: stm32: Fix the unit of the hwspinlock timeout
pinctrl: stm32: program the EXTI mux from .alloc instead of .activate

 drivers/pinctrl/stm32/pinctrl-stm32.c | 60 ++++++++++++---------------
 1 file changed, 26 insertions(+), 34 deletions(-)
Signature · 1 line
2.56.0