[PATCH v2 0/2] pinctrl: rp1: fix RT sleep and clean up map freeing
From: Xiaolei Wang
Date: Tue Dec 01 2026 - 04:07:53 EST
This series contains two independent changes to the RP1 pinctrl driver:
a fix for a real PREEMPT_RT bug, and a cleanup that removes duplicated
code and a small leak. They do not depend on each other.
Patch 1 makes the gpio regmap use a raw spinlock. The gpio irq_chip
callbacks run in atomic context -- irq_set_type() is called with the irq
descriptor's raw spinlock held, and the driver itself disables
preemption and interrupts while touching the registers. On PREEMPT_RT
the gpio regmap uses the default spinlock_t, which becomes a sleepable
rt_spin_lock, so writing a register field from that context sleeps and
triggers "sleeping function called from invalid context". This is
reachable from ordinary userspace: requesting a GPIO line with an edge
trigger through the GPIO cdev ioctl ends up in irq_set_type(), so any
application using edge-detected GPIO lines hits it. Other pinctrl
drivers have already adopted the same fix, e.g. armada-37xx.
Patch 2 replaces the open-coded dt_free_map callback with the core
pinctrl_utils_free_map() helper. The local copy only frees config
arrays of CONFIGS_PIN maps, but the driver may also produce CONFIGS_GROUP
maps through the generic pinconf DT parser; their config arrays would be
leaked. The core helper handles both types and removes the duplicate
code.
The RT bug was reproduced on a Raspberry Pi 5 with a PREEMPT_RT kernel
by requesting an edge-triggered GPIO line from userspace. A full read
of the pinctrl debugfs "pins" file (all 54 pins) produces no warnings.
This patch was initially drafted with AI assistance and has been
reviewed and modified by me.
Signed-off-by: Xiaolei Wang <wangxiaolei01@xxxxxxxxxxx>
---
Changes in v2:
- Patch 1: unchanged since v1.
- Patch 2: add the missing Fixes tag, which the automated Sashiko
review flagged as a low severity issue:
https://sashiko.dev/#/patchset/20261126035420.1836760-1-wangxiaolei01@xxxxxxxxxxx?part=2
The CONFIGS_GROUP config arrays are allocated by the generic pinconf
DT parser, so the leak dates back to the commit that introduced this
driver's open-coded dt_free_map callback. No other change.
Link to v1: https://lore.kernel.org/all/20261126035420.1836760-1-wangxiaolei01@xxxxxxxxxxx/
Xiaolei Wang (2):
pinctrl: rp1: use raw spinlock for gpio regmap
pinctrl: rp1: use pinctrl_utils_free_map() for map cleanup
drivers/pinctrl/pinctrl-rp1.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
--
2.34.1