[PATCH 0/2] pinctrl: rp1: fix RT sleep and clean up map freeing

From: Xiaolei Wang

Date: Wed Nov 25 2026 - 22:54:40 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.

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