Re: [PATCH 2/2] pinctrl: ocelot: do not use the chained irqchip behind a sleeping bus

From: Colin Foster

Date: Mon Nov 09 2026 - 12:45:07 EST


On Mon, Nov 09, 2026 at 02:50:42PM +0100, Jens Emil Schulz Østergaard wrote:
> [You don't often get email from jensemil.schulzostergaard@xxxxxxxxxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> 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@xxxxxxxxxxxxx>
> ---

Thanks for the patch! I don't have the hardware setup for test right
now, but for this patch:

Reviewed-by: Colin Foster <colin.foster@xxxxxxxxxxxxxxxx>