linux-yocto/drivers/input
Fabrice Gasnier 664e5a6f54 Input: gpio-keys - fix a sleep while atomic with PREEMPT_RT
commit f4a8f561d0 upstream.

When enabling PREEMPT_RT, the gpio_keys_irq_timer() callback runs in
hard irq context, but the input_event() takes a spin_lock, which isn't
allowed there as it is converted to a rt_spin_lock().

[ 4054.289999] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
[ 4054.290028] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/0
...
[ 4054.290195]  __might_resched+0x13c/0x1f4
[ 4054.290209]  rt_spin_lock+0x54/0x11c
[ 4054.290219]  input_event+0x48/0x80
[ 4054.290230]  gpio_keys_irq_timer+0x4c/0x78
[ 4054.290243]  __hrtimer_run_queues+0x1a4/0x438
[ 4054.290257]  hrtimer_interrupt+0xe4/0x240
[ 4054.290269]  arch_timer_handler_phys+0x2c/0x44
[ 4054.290283]  handle_percpu_devid_irq+0x8c/0x14c
[ 4054.290297]  handle_irq_desc+0x40/0x58
[ 4054.290307]  generic_handle_domain_irq+0x1c/0x28
[ 4054.290316]  gic_handle_irq+0x44/0xcc

Considering the gpio_keys_irq_isr() can run in any context, e.g. it can
be threaded, it seems there's no point in requesting the timer isr to
run in hard irq context.

Relax the hrtimer not to use the hard context.

Fixes: 019002f20c ("Input: gpio-keys - use hrtimer for release timer")
Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Link: https://lore.kernel.org/r/20250528-gpio_keys_preempt_rt-v2-1-3fc55a9c3619@foss.st.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
[ adjusted context ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 16:24:03 +02:00
..
gameport
joystick Input: xpad - set correct controller type for Acer NGR200 2025-08-28 16:23:59 +02:00
keyboard Input: gpio-keys - fix a sleep while atomic with PREEMPT_RT 2025-08-28 16:24:03 +02:00
misc Input: sparcspkr - avoid unannotated fall-through 2025-06-27 11:05:34 +01:00
mouse Input: synaptics - enable InterTouch on TUXEDO InfinityBook Pro 14 v5 2025-05-18 08:20:36 +02:00
rmi4 Input: synaptics-rmi - fix crash with unsupported versions of F34 2025-06-27 11:05:18 +01:00
serio Input: i8042 - add another board name for TUXEDO Stellaris Gen5 AMD line 2024-10-17 15:11:11 +02:00
tablet
touchscreen Input: goodix - use the new soc_intel_is_byt() helper 2024-10-17 15:11:09 +02:00
apm-power.c
evbug.c
evdev.c
ff-core.c Input: ff-core - prefer struct_size over open coded arithmetic 2024-07-18 13:07:28 +02:00
ff-memless.c
input-compat.c
input-compat.h
input-leds.c
input-mt.c Input: MT - limit max slots 2024-09-04 13:23:37 +02:00
input-poller.c
input-poller.h
input.c Input: try trimming too long modalias strings 2024-07-05 09:14:15 +02:00
joydev.c
Kconfig
Makefile
matrix-keymap.c
mousedev.c
sparse-keymap.c
touchscreen.c