[PATCH 1/2] pinctrl: ocelot: use a raw spinlock for the GPIO regmap
From: Jens Emil Schulz Østergaard
Date: Mon Nov 09 2026 - 08:52:58 EST
The irq_chip callbacks .irq_mask, .irq_unmask and .irq_ack access the
GPIO regmap. genirq calls them with the raw spinlock irq_desc::lock
held, for example from irq_startup() in __setup_irq(). The regmap is
created with devm_regmap_init_mmio() and guarded by a spinlock_t, which
is a sleeping lock on PREEMPT_RT and must not be taken under a raw
spinlock.
Make the GPIO regmap use a raw spinlock. Its accesses are short MMIO
reads and writes. The other regmaps of the driver are not used from the
irq_chip callbacks and are left unchanged.
The issue was found with CONFIG_PROVE_RAW_LOCK_NESTING on a lan9668
board (pcb8385), when a level low interrupt on one of its GPIOs is
requested, and was seen on lan969x when a PHY interrupt on a GPIO is
requested:
=============================
[ BUG: Invalid wait context ]
-----------------------------
swapper/0/1 is trying to lock:
c3046c10 (pinctrl_ocelot:34:(config)->lock){....}-{3:3}, at: regmap_lock_spinlock+0xc/0x40
other info that might help us debug this:
context-{5:5}
locks held by swapper/0/1: 6, last CPU#0:
...
#4: c3200b5c (request_class){+.+.}-{4:4}, at: __setup_irq+0x140/0x840
#5: c3200a7c (lock_class){....}-{2:2}, at: __setup_irq+0x168/0x840
stack backtrace:
...
_raw_spin_lock_irqsave from regmap_lock_spinlock+0xc/0x40
regmap_lock_spinlock from regmap_read+0x2c/0x80
regmap_read from ocelot_irq_unmask_level+0x6c/0x240
ocelot_irq_unmask_level from irq_enable+0x38/0xc0
irq_enable from __irq_startup+0x70/0xc0
__irq_startup from irq_startup+0xb8/0x180
irq_startup from __setup_irq+0x4d0/0x840
__setup_irq from request_threaded_irq+0xbc/0x180
request_threaded_irq from devm_request_threaded_irq+0x70/0x140
With the fix the report is gone on the lan9668 board.
Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
Signed-off-by: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@xxxxxxxxxxxxx>
---
drivers/pinctrl/pinctrl-ocelot.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index 58d3cde9f964..06dd49782d74 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -2440,6 +2440,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
+ .use_raw_spinlock = true,
};
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
--
2.52.0