From: Xiaolei Wang <wangxiaolei01@kaihong.com>
To: linusw@kernel.org, florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, daniel@dragonzap.com,
wangxiaolei01@kaihong.com, iivanov@suse.de,
andrea.porta@suse.com, phil@raspberrypi.com
Cc: linux-gpio@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] pinctrl: rp1: fix RT sleep and clean up map freeing
Date: Thu, 26 Nov 2026 03:54:18 +0000 [thread overview]
Message-ID: <20261126035420.1836760-1-wangxiaolei01@kaihong.com> (raw)
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
next reply other threads:[~2026-11-26 3:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 3:54 Xiaolei Wang [this message]
2026-11-26 3:54 ` [PATCH 1/2] pinctrl: rp1: use raw spinlock for gpio regmap Xiaolei Wang
2026-11-26 3:54 ` [PATCH 2/2] pinctrl: rp1: use pinctrl_utils_free_map() for map cleanup Xiaolei Wang
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=20261126035420.1836760-1-wangxiaolei01@kaihong.com \
--to=wangxiaolei01@kaihong.com \
--cc=andrea.porta@suse.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=daniel@dragonzap.com \
--cc=florian.fainelli@broadcom.com \
--cc=iivanov@suse.de \
--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-rpi-kernel@lists.infradead.org \
--cc=phil@raspberrypi.com \
/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®