From: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
To: Linus Walleij <linusw@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
Colin Foster <colin.foster@in-advantage.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Lee Jones <lee@kernel.org>,
Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev,
"Jens Emil Schulz Østergaard"
<jensemil.schulzostergaard@microchip.com>
Subject: [PATCH 2/2] pinctrl: ocelot: do not use the chained irqchip behind a sleeping bus
Date: Mon, 9 Nov 2026 14:50:42 +0100 [thread overview]
Message-ID: <20261109-ocelot-pinctrl-irqchip-fixes-v1-2-9d2d8fcd58f5@microchip.com> (raw)
In-Reply-To: <20261109-ocelot-pinctrl-irqchip-fixes-v1-0-9d2d8fcd58f5@microchip.com>
Since the driver can use a regmap on a bus that can sleep, as for
VSC7512 attached over SPI, it still registers the gpiochip as not
sleeping and adds the chained irqchip when the node has an interrupt.
The chained handler and the irq_chip callbacks run in atomic context and
access the registers through that regmap, and consumers may use the
lines of a gpiochip that is not marked as sleeping from atomic context.
Mark the gpiochip as sleeping when the regmap can sleep, and do not
register the chained irqchip in that case.
The issue was found by code inspection and reproduced on a lan9668
board (pcb8385) with a lan9645x attached over SPI, whose pinctrl node
has an interrupt, by requesting an edge interrupt on one of its GPIOs
through the GPIO character device:
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:623
in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 420, name: gpiomon
preempt_count: 1, expected: 0
locks held by gpiomon/420: 3, last CPU#0:
#0: 84463cd0 (&gdev->srcu){.+.+}-{0:0}, at: lineinfo_get+0x13f/0x140
#1: 838bbd30 (request_class){+.+.}-{4:4}, at: __setup_irq+0xe8/0x5c0
#2: 838bbc70 (lock_class){-...}-{2:2}, at: __setup_irq+0x104/0x5c0
...
Call trace:
...
mutex_lock_nested from regmap_update_bits_base+0x1c/0x80
regmap_update_bits_base from ocelot_irq_unmask+0x42/0x80
ocelot_irq_unmask from irq_enable+0x1e/0x80
irq_enable from irq_startup+0x64/0xc0
irq_startup from __setup_irq+0x38c/0x5c0
__setup_irq from request_threaded_irq+0x86/0x140
request_threaded_irq from edge_detector_setup+0x1d8/0x240
edge_detector_setup from linereq_create+0x3e2/0x540
linereq_create from gpio_ioctl+0xa4/0x240
With the fix the lan9645x gpiochip is registered as sleeping and
without the chained irqchip, the request fails with -ENXIO instead and
without lockdep reports.
Fixes: 181f604b33cd ("pinctrl: ocelot: add ability to be used in a non-mmio configuration")
Signed-off-by: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
---
drivers/pinctrl/pinctrl-ocelot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index 06dd49782d74..90a1f859db67 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -2367,8 +2367,9 @@ static int ocelot_gpiochip_register(struct platform_device *pdev,
gc->parent = &pdev->dev;
gc->base = -1;
gc->label = "ocelot-gpio";
+ gc->can_sleep = regmap_might_sleep(info->map);
- irq = platform_get_irq_optional(pdev, 0);
+ irq = gc->can_sleep ? 0 : platform_get_irq_optional(pdev, 0);
if (irq > 0) {
girq = &gc->irq;
gpio_irq_chip_set_chip(girq, &ocelot_irqchip);
--
2.52.0
next prev parent reply other threads:[~2026-11-09 13:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 13:50 [PATCH 0/2] pinctrl: ocelot: fix the GPIO irqchip context handling Jens Emil Schulz Østergaard
2026-11-09 13:50 ` [PATCH 1/2] pinctrl: ocelot: use a raw spinlock for the GPIO regmap Jens Emil Schulz Østergaard
2026-11-09 13:50 ` Jens Emil Schulz Østergaard [this message]
2026-11-09 17:43 ` [PATCH 2/2] pinctrl: ocelot: do not use the chained irqchip behind a sleeping bus Colin Foster
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=20261109-ocelot-pinctrl-irqchip-fixes-v1-2-9d2d8fcd58f5@microchip.com \
--to=jensemil.schulzostergaard@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andy.shevchenko@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=colin.foster@in-advantage.com \
--cc=horatiu.vultur@microchip.com \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=rostedt@goodmis.org \
--cc=vladimir.oltean@nxp.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®