From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Lukas Schmid <lukas.schmid@netcube.li>
Subject: Re: BUG: "scheduling while atomic" with MCP23008 + matrix_keypad IRQ mode on Linux 6.15.5
Date: Thu, 10 Jul 2025 13:55:29 +0200 [thread overview]
Message-ID: <6072675.MhkbZ0Pkbq@steina-w> (raw)
In-Reply-To: <15509576.tv2OnDr8pf@lukas-hpz440workstation>
Am Donnerstag, 10. Juli 2025, 13:44:01 CEST schrieb Lukas Schmid:
> Hi all,
>
> I'm encountering a "BUG: scheduling while atomic" when using the MCP23008 GPIO
> expander with the `matrix_keypad` driver in IRQ mode on Linux v6.15.5
>
> Hardware setup:
> - MCP23008 connected via I2C
> - 4x4 matrix keypad hooked to MCP23008 GPIOs
> - SoC: Allwinner T113-s3 SoC
> - Using devicetree configuration for `microchip,mcp23008` and `gpio-
> matrix-keypad`
>
> When I press buttons on the keypad, after some amount of presses I get the
> following error from the Kernel:
>
> [ 81.921114] BUG: scheduling while atomic: kworker/1:4/383/0x00000002
> [ 81.921155] Modules linked in: esp32_sdio(O) bluetooth ecdh_generic ecc
> cfg80211 rfkill ipv6 af_packet evdev matrix_keypad matrix_keymap
> pinctrl_mcp23s08_i2c pinctrl_mcp23s08 sun8i_ce crypto_engine uio_pdrv_genirq
> uio
> [ 81.921287] CPU: 1 UID: 0 PID: 383 Comm: kworker/1:4 Tainted: G O
> 6.15.4 #1 PREEMPT
> [ 81.921305] Tainted: [O]=OOT_MODULE
> [ 81.921310] Hardware name: Generic DT based system
> [ 81.921317] Workqueue: events matrix_keypad_scan [matrix_keypad]
> [ 81.921343] Call trace:
> [ 81.921353] unwind_backtrace from show_stack+0x18/0x1c
> [ 81.921381] show_stack from dump_stack_lvl+0x68/0x74
> [ 81.921398] dump_stack_lvl from __schedule_bug+0x5c/0x70
> [ 81.921423] __schedule_bug from __schedule+0xb48/0xd24
> [ 81.921451] __schedule from schedule+0x34/0x144
> [ 81.921472] schedule from schedule_preempt_disabled+0x24/0x34
> [ 81.921494] schedule_preempt_disabled from __mutex_lock.constprop.
> 0+0x308/0xaa4
> [ 81.921519] __mutex_lock.constprop.0 from mcp23s08_irq_bus_lock+0x20/0x30
> [pinctrl_mcp23s08]
> [ 81.921553] mcp23s08_irq_bus_lock [pinctrl_mcp23s08] from
> __irq_get_desc_lock+0x84/0xac
> [ 81.921584] __irq_get_desc_lock from enable_irq+0x38/0xa8
> [ 81.921605] enable_irq from matrix_keypad_scan+0x2b8/0x3ac [matrix_keypad]
> [ 81.921626] matrix_keypad_scan [matrix_keypad] from
> process_one_work+0x160/0x410
> [ 81.921649] process_one_work from worker_thread+0x25c/0x408
> [ 81.921668] worker_thread from kthread+0x144/0x264
> [ 81.921685] kthread from ret_from_fork+0x14/0x38
> [ 81.921699] Exception stack(0xc896dfb0 to 0xc896dff8)
> [ 81.921709] dfa0: 00000000 00000000
> 00000000 00000000
> [ 81.921720] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000
> 00000000 00000000
> [ 81.921730] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
>
> Happy to test patches or provide further debugging info.
The culprit is
> scoped_guard(spinlock_irq, &keypad->lock) {
> keypad->scan_pending = false;
> enable_row_irqs(keypad);
> }
Here a spinlock is held, while during enable_irq() call the function
mcp23s08_irq_bus_lock() is called. The latter one tries to lock a mutex
while holding a spinlock. This doesn'twork.
Best regards,
Alexander
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
prev parent reply other threads:[~2025-07-10 11:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 11:44 BUG: "scheduling while atomic" with MCP23008 + matrix_keypad IRQ mode on Linux 6.15.5 Lukas Schmid
2025-07-10 11:55 ` Alexander Stein [this message]
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=6072675.MhkbZ0Pkbq@steina-w \
--to=alexander.stein@ew.tq-group.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.schmid@netcube.li \
/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