milos-linux/drivers/hid
Sangyun Kim 1654e53349 HID: appletb-kbd: run inactivity autodim from workqueues
The autodim code in hid-appletb-kbd takes backlight_device->ops_lock
via backlight_device_set_brightness() -> mutex_lock() from two
different atomic contexts:

 * appletb_inactivity_timer() is a struct timer_list callback, so it
   runs in softirq context.  Every expiry triggers

     BUG: sleeping function called from invalid context at kernel/locking/mutex.c:591
     Call Trace:
      <IRQ>
      __might_resched
      __mutex_lock
      backlight_device_set_brightness
      appletb_inactivity_timer
      call_timer_fn
      run_timer_softirq

 * reset_inactivity_timer() is called from appletb_kbd_hid_event() and
   appletb_kbd_inp_event().  On real USB hardware these run in
   softirq/IRQ context (URB completion and input-event dispatch).
   When the Touch Bar has already been dimmed or turned off, the
   reset path calls backlight_device_set_brightness() directly to
   restore brightness, producing the same warning.

Both call sites hit the same mutex_lock()-from-atomic bug.  Fix them
together by moving the blocking work onto the system workqueue:

 * Convert the inactivity timer from struct timer_list to
   struct delayed_work; the callback (appletb_inactivity_work) now
   runs in process context where mutex_lock() is legal.
 * Add a dedicated struct work_struct restore_brightness_work and have
   reset_inactivity_timer() schedule it instead of calling
   backlight_device_set_brightness() directly.

Cancel both works synchronously during driver tear-down alongside the
existing backlight reference drop.

The semantics are unchanged (same delays, same state transitions on
dim, turn-off and user activity); only the execution context of the
sleeping call changes.  The timer field and callback are renamed to
match their new type; reset_inactivity_timer() keeps its name because
it is invoked from input event paths that read naturally as "reset
the inactivity timer".

Fixes: 93a0fc4894 ("HID: hid-appletb-kbd: add support for automatic brightness control while using the touchbar")
Cc: stable@vger.kernel.org
Signed-off-by: Sangyun Kim <sangyun.kim@snu.ac.kr>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
2026-05-12 17:57:35 +02:00
..
amd-sfh-hid Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
bpf bpf: Add fix for Trust Philips SPK6327 (145f:024b) modifier keys 2026-04-08 21:47:02 +02:00
i2c-hid Input updates for v7.0-rc0 2026-02-15 08:24:19 -08:00
intel-ish-hid hid-for-linus-2026030601 2026-03-06 10:00:58 -08:00
intel-thc-hid HID: intel-thc-hid: Intel-quickspi: Fix some error codes 2026-04-28 18:35:29 +02:00
surface-hid
usbhid Merge branch 'for-7.1/pidff' into for-linus 2026-04-16 21:05:37 +02:00
.kunitconfig
hid-a4tech.c
hid-accutouch.c
hid-alps.c HID: alps: fix NULL pointer dereference in alps_raw_event() 2026-04-09 17:37:39 +02:00
hid-apple.c Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
hid-appleir.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
hid-appletb-bl.c
hid-appletb-kbd.c HID: appletb-kbd: run inactivity autodim from workqueues 2026-05-12 17:57:35 +02:00
hid-asus.c Merge branch 'for-7.1/asus' into for-linus 2026-04-16 21:11:19 +02:00
hid-aureal.c
hid-axff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-belkin.c
hid-betopff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-bigbenff.c
hid-cherry.c
hid-chicony.c
hid-cmedia.c hid-for-linus-2026030601 2026-03-06 10:00:58 -08:00
hid-core.c Merge branch 'for-7.1/lenovo-v2' into for-linus 2026-04-16 21:07:13 +02:00
hid-corsair-void.c HID: corsair-void: Use %pe for printing PTR_ERR 2025-11-18 18:03:48 +01:00
hid-corsair.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-cougar.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-cp2112.c HID: cp2112: Add parameter validation to data length 2025-10-14 11:46:49 +02:00
hid-creative-sb0540.c HID: Add HID_CLAIMED_INPUT guards in raw_event callbacks missing them 2026-02-19 18:58:39 +01:00
hid-cypress.c
hid-debug.c Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
hid-dr.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-elan.c HID: elan: Add support for ELAN SB974D touchpad 2026-04-28 18:30:02 +02:00
hid-elecom.c HID: elecom: Add support for ELECOM HUGE Plus M-HT1MRBK 2026-01-23 13:53:25 +01:00
hid-elo.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-emsff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-evision.c HID: evision: Fix Report Descriptor for Evision Wireless Receiver 320f:226f 2025-11-26 17:17:53 +01:00
hid-ezkey.c
hid-ft260.c HID: ft260: validate i2c input report length 2026-04-28 18:24:52 +02:00
hid-gaff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-gembird.c
hid-generic.c drivers: hid: renegotiate resolution multipliers with device after reset 2025-11-26 17:21:48 +01:00
hid-gfrm.c
hid-glorious.c
hid-goodix-spi.c
hid-google-hammer.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
hid-google-stadiaff.c
hid-gt683r.c
hid-gyration.c
hid-haptic.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
hid-haptic.h HID: multitouch: add haptic multitouch support 2025-09-15 14:32:55 +02:00
hid-holtek-kbd.c
hid-holtek-mouse.c
hid-holtekff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-huawei.c HID: huawei: fix CD30 keyboard report descriptor issue 2026-04-09 17:56:46 +02:00
hid-hyperv.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-icade.c
hid-ids.h HID: elan: Add support for ELAN SB974D touchpad 2026-04-28 18:30:02 +02:00
hid-input-test.c HID: input: Introduce struct hid_battery and refactor battery code 2026-03-19 15:52:45 +01:00
hid-input.c Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
hid-ite.c
hid-jabra.c
hid-kensington.c
hid-keytouch.c
hid-kye.c
hid-kysona.c HID: Kysona: Add support for VXE Dragonfly R1 Pro 2026-03-27 15:51:05 +01:00
hid-lcpower.c
hid-led.c
hid-lenovo-go-s.c HID: hid-lenovo-go-s: restore OS_TYPE after resume from s2idle 2026-04-28 18:34:21 +02:00
hid-lenovo-go.c HID: hid-lenovo-go: Remove unneeded semicolon 2026-03-10 17:53:18 +01:00
hid-lenovo.c HID: lenovo: Use pm_ptr instead of #ifdef CONFIG_PM 2026-01-28 19:23:16 +01:00
hid-letsketch.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
hid-lg-g15.c HID: hid-lg-g15: Add hw_brightness_changed support for the G510 keyboard 2025-10-14 11:50:25 +02:00
hid-lg.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-lg.h
hid-lg2ff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-lg3ff.c
hid-lg4ff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-lg4ff.h
hid-lgff.c
hid-logitech-dj.c Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
hid-logitech-hidpp.c Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
hid-macally.c
hid-magicmouse.c HID: magicmouse: Prevent out-of-bounds (OOB) read during DOUBLE_REPORT_ID 2026-05-12 17:49:18 +02:00
hid-maltron.c
hid-mcp2200.c treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
hid-mcp2221.c HID: mcp2221: fix OOB write in mcp2221_raw_event() 2026-05-12 17:48:16 +02:00
hid-megaworld.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-mf.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-microsoft.c
hid-monterey.c
hid-multitouch.c HID: multitouch: Check to ensure report responses match the request 2026-03-17 11:36:16 +01:00
hid-nintendo.c HID: nintendo: Use pm_ptr instead of #ifdef CONFIG_PM 2026-01-28 19:23:16 +01:00
hid-nti.c
hid-ntrig.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-nvidia-shield.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
hid-ortek.c
hid-penmount.c
hid-petalynx.c
hid-picolcd.h
hid-picolcd_backlight.c
hid-picolcd_cir.c media: rc: fix race between unregister and urb/irq callbacks 2026-03-17 14:43:56 +01:00
hid-picolcd_core.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-picolcd_debugfs.c kernel.h: drop hex.h and update all hex.h users 2026-01-20 19:44:19 -08:00
hid-picolcd_fb.c
hid-picolcd_lcd.c
hid-picolcd_leds.c
hid-pl.c HID: pl: eliminate private debug macro 2026-03-12 14:20:57 +01:00
hid-plantronics.c
hid-playstation.c HID: playstation: Clamp num_touch_reports 2026-05-12 17:54:48 +02:00
hid-primax.c
hid-prodikeys.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-pxrc.c
hid-quirks.c HID: quirks: really enable the intended work around for appledisplay 2026-05-12 17:23:59 +02:00
hid-rapoo.c HID: rapoo: Add support for side buttons on RAPOO 0x2015 mouse 2026-01-10 09:52:37 +01:00
hid-razer.c
hid-redragon.c
hid-retrode.c
hid-rmi.c
hid-roccat-arvo.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-arvo.h
hid-roccat-common.c
hid-roccat-common.h sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
hid-roccat-isku.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-isku.h
hid-roccat-kone.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-kone.h
hid-roccat-koneplus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-koneplus.h
hid-roccat-konepure.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-kovaplus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-kovaplus.h
hid-roccat-lua.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-lua.h
hid-roccat-pyra.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-pyra.h
hid-roccat-ryos.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-savu.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-roccat-savu.h
hid-roccat.c Merge branch 'for-7.1/core-v2' into for-linus 2026-04-16 21:01:18 +02:00
hid-saitek.c
hid-samsung.c
hid-semitek.c
hid-sensor-custom.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-sensor-hub.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
hid-sigmamicro.c
hid-sjoy.c HID: hid-sjoy: race between init and usage 2026-05-12 17:23:08 +02:00
hid-sony.c HID: sony: add missing size validation for Rock Band 3 Pro instruments 2026-04-28 18:28:32 +02:00
hid-speedlink.c
hid-steam.c HID: hid-steam: Use new BTN_GRIP* buttons 2025-08-06 10:02:28 -07:00
hid-steelseries.c HID: steelseries: Fix STEELSERIES_SRWS1 handling in steelseries_remove() 2025-09-12 16:27:35 +02:00
hid-sunplus.c
hid-thrustmaster.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-tivo.c
hid-tmff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-topre.c
hid-topseed.c
hid-twinhan.c
hid-u2fzero.c
hid-uclogic-core-test.c
hid-uclogic-core.c HID: uclogic: Fix regression of input name assignment 2026-04-28 18:37:01 +02:00
hid-uclogic-params-test.c
hid-uclogic-params.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-uclogic-params.h HID: uclogic: Add support for the XP-PEN Artist 24 Pro 2025-10-14 12:01:34 +02:00
hid-uclogic-rdesc-test.c
hid-uclogic-rdesc.c HID: uclogic: Add support for the XP-PEN Artist 24 Pro 2025-10-14 12:01:34 +02:00
hid-uclogic-rdesc.h HID: uclogic: Add support for the XP-PEN Artist 24 Pro 2025-10-14 12:01:34 +02:00
hid-udraw-ps3.c
hid-universal-pidff.c HID: universal-pidff: clang-format pass 2025-08-15 15:58:10 +02:00
hid-viewsonic.c
hid-vivaldi-common.c
hid-vivaldi-common.h
hid-vivaldi.c
hid-vrc2.c
hid-waltop.c
hid-wiimote-core.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-wiimote-debug.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-wiimote-modules.c
hid-wiimote.h
hid-winwing.c HID: winwing: Enable rumble effects 2026-04-09 18:09:15 +02:00
hid-xiaomi.c
hid-xinmo.c
hid-zpff.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hid-zydacron.c HID: Add HID_CLAIMED_INPUT guards in raw_event callbacks missing them 2026-02-19 18:58:39 +01:00
hidraw.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Kconfig Merge branch 'for-7.1/lenovo-v2' into for-linus 2026-04-16 21:07:13 +02:00
Makefile Merge branch 'for-7.1/lenovo-v2' into for-linus 2026-04-16 21:07:13 +02:00
uhid.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
wacom.h
wacom_sys.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
wacom_wac.c HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq 2026-03-09 19:34:12 +01:00
wacom_wac.h HID: wacom: Remove static WACOM_PKGLEN_MAX limit 2025-03-04 21:51:04 +01:00