All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/9] HID: asus: Fix ASUS ROG Laptop's Keyboard backlight handling
@ 2025-10-18 10:17 Antheas Kapenekakis
  2025-10-18 10:17 ` [PATCH v7 1/9] HID: asus: simplify RGB init sequence Antheas Kapenekakis
                   ` (8 more replies)
  0 siblings, 9 replies; 34+ messages in thread
From: Antheas Kapenekakis @ 2025-10-18 10:17 UTC (permalink / raw)
  To: platform-driver-x86, linux-input
  Cc: linux-kernel, Jiri Kosina, Benjamin Tissoires, Corentin Chary,
	Luke D . Jones, Hans de Goede, Ilpo Järvinen, Denis Benato,
	Antheas Kapenekakis

This is a two part series which does the following:
  - Clean-up init sequence
  - Unify backlight handling to happen under asus-wmi so that all Aura
    devices have synced brightness controls and the backlight button works
    properly when it is on a USB laptop keyboard instead of one w/ WMI.

For more context, see cover letter of V1. Since V5, I removed some patches
to make this easier to merge.

---

V6: https://lore.kernel.org/all/20251013201535.6737-1-lkml@antheas.dev/
V5: https://lore.kernel.org/all/20250325184601.10990-1-lkml@antheas.dev/
V4: https://lore.kernel.org/lkml/20250324210151.6042-1-lkml@antheas.dev/
V3: https://lore.kernel.org/lkml/20250322102804.418000-1-lkml@antheas.dev/
V2: https://lore.kernel.org/all/20250320220924.5023-1-lkml@antheas.dev/
V1: https://lore.kernel.org/all/20250319191320.10092-1-lkml@antheas.dev/

Changes since V6:
  - Split initialization refactor into three patches, update commit text
    to be clearer in what it does
  - Replace spinlock accesses with guard and scoped guard in all patches
  - Add missing includes mentioned by Ilpo
  - Reflow, tweak comment in prevent binding to all HID devices on ROG
  - Replace asus_ref.asus with local reference in all patches
  - Add missing kernel doc comments
  - Other minor nits from Ilpo
  - User reported warning due to scheduling work while holding a spinlock.
    Restructure patch for multiple handlers to limit when spinlock is held to
    variable access only. In parallel, setup a workqueue to handle registration
    of led device and setting brightness. This is required as registering the
    led device triggers kbd_led_get which needs to hold the spinlock to
    protect the led_wk value. The workqueue is also required for the hid
    event passthrough to avoid scheduling work while holding the spinlock.
    Apply the workqueue to wmi brightness buttons as well, as that was
    omitted before this series and WMI access was performed.
  - On "HID: asus: prevent binding to all HID devices on ROG", rename
    quirk HANDLE_GENERIC to SKIP_REPORT_FIXUP and only skip report fixup.
    This allows other quirks to apply (applies quirk that fixes keyboard
    being named as a pointer device).

Changes since V5:
  - It's been a long time
  - Remove addition of RGB as that had some comments I need to work on
  - Remove folio patch (already merged)
  - Remove legacy fix patch 11 from V4. There is a small chance that
    without this patch, some old NKEY keyboards might not respond to
    RGB commands according to Luke, but the kernel driver does not do
    RGB currently. The 0x5d init is done by Armoury crate software in
    Windows. If an issue is found, we can re-add it or just remove patches
    1/2 before merging. However, init could use the cleanup.

Changes since V4:
  - Fix KConfig (reported by kernel robot)
  - Fix Ilpo's nits, if I missed anything lmk

Changes since V3:
  - Add initializer for 0x5d for old NKEY keyboards until it is verified
    that it is not needed for their media keys to function.
  - Cover init in asus-wmi with spinlock as per Hans
  - If asus-wmi registers WMI handler with brightness, init the brightness
    in USB Asus keyboards, per Hans.
  - Change hid handler name to asus-UNIQ:rgb:peripheral to match led class
  - Fix oops when unregistering asus-wmi by moving unregister outside of
    the spin lock (but after the asus reference is set to null)

Changes since V2:
  - Check lazy init succeds in asus-wmi before setting register variable
  - make explicit check in asus_hid_register_listener for listener existing
    to avoid re-init
  - rename asus_brt to asus_hid in most places and harmonize everything
  - switch to a spinlock instead of a mutex to avoid kernel ooops
  - fixup hid device quirks to avoid multiple RGB devices while still exposing
    all input vendor devices. This includes moving rgb init to probe
    instead of the input_configured callbacks.
  - Remove fan key (during retest it appears to be 0xae that is already
    supported by hid-asus)
  - Never unregister asus::kbd_backlight while asus-wmi is active, as that
  - removes fds from userspace and breaks backlight functionality. All
  - current mainline drivers do not support backlight hotplugging, so most
    userspace software (e.g., KDE, UPower) is built with that assumption.
    For the Ally, since it disconnects its controller during sleep, this
    caused the backlight slider to not work in KDE.

Changes since V1:
  - Add basic RGB support on hid-asus, (Z13/Ally) tested in KDE/Z13
  - Fix ifdef else having an invalid signature (reported by kernel robot)
  - Restore input arguments to init and keyboard function so they can
    be re-used for RGB controls.
  - Remove Z13 delay (it did not work to fix the touchpad) and replace it
    with a HID_GROUP_GENERIC quirk to allow hid-multitouch to load. Squash
    keyboard rename into it.
  - Unregister brightness listener before removing work queue to avoid
    a race condition causing corruption
  - Remove spurious mutex unlock in asus_brt_event
  - Place mutex lock in kbd_led_set after LED_UNREGISTERING check to avoid
    relocking the mutex and causing a deadlock when unregistering leds
  - Add extra check during unregistering to avoid calling unregister when
    no led device is registered.
  - Temporarily HID_QUIRK_INPUT_PER_APP from the ROG endpoint as it causes
    the driver to create 4 RGB handlers per device. I also suspect some
    extra events sneak through (KDE had the @@@@@@).

Antheas Kapenekakis (9):
  HID: asus: simplify RGB init sequence
  HID: asus: use same report_id in response
  HID: asus: fortify keyboard handshake
  HID: asus: prevent binding to all HID devices on ROG
  platform/x86: asus-wmi: Add support for multiple kbd led handlers
  HID: asus: listen to the asus-wmi brightness device instead of
    creating one
  platform/x86: asus-wmi: remove unused keyboard backlight quirk
  platform/x86: asus-wmi: add keyboard brightness event handler
  HID: asus: add support for the asus-wmi brightness handler

 drivers/hid/hid-asus.c                     | 222 ++++++++++-----------
 drivers/platform/x86/asus-wmi.c            | 215 +++++++++++++++++---
 include/linux/platform_data/x86/asus-wmi.h |  70 +++----
 3 files changed, 326 insertions(+), 181 deletions(-)


base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
-- 
2.51.0



^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: [PATCH v7 5/9] platform/x86: asus-wmi: Add support for multiple kbd led handlers
@ 2025-10-26 11:26 kernel test robot
  0 siblings, 0 replies; 34+ messages in thread
From: kernel test robot @ 2025-10-26 11:26 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence static check warning: drivers/platform/x86/asus-wmi.c:1623:22: sparse: sparse: unsigned value that used to be signed checked against zero?"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251018101759.4089-6-lkml@antheas.dev>
References: <20251018101759.4089-6-lkml@antheas.dev>
TO: Antheas Kapenekakis <lkml@antheas.dev>
TO: platform-driver-x86@vger.kernel.org
TO: linux-input@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: Jiri Kosina <jikos@kernel.org>
CC: Benjamin Tissoires <bentiss@kernel.org>
CC: Corentin Chary <corentin.chary@gmail.com>
CC: "Luke D . Jones" <luke@ljones.dev>
CC: Hans de Goede <hdegoede@redhat.com>
CC: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
CC: Denis Benato <benato.denis96@gmail.com>
CC: Antheas Kapenekakis <lkml@antheas.dev>

Hi Antheas,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 3a8660878839faadb4f1a6dd72c3179c1df56787]

url:    https://github.com/intel-lab-lkp/linux/commits/Antheas-Kapenekakis/HID-asus-simplify-RGB-init-sequence/20251018-182410
base:   3a8660878839faadb4f1a6dd72c3179c1df56787
patch link:    https://lore.kernel.org/r/20251018101759.4089-6-lkml%40antheas.dev
patch subject: [PATCH v7 5/9] platform/x86: asus-wmi: Add support for multiple kbd led handlers
:::::: branch date: 8 days ago
:::::: commit date: 8 days ago
config: x86_64-randconfig-121-20251026 (https://download.01.org/0day-ci/archive/20251026/202510261909.eTmjHfiY-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251026/202510261909.eTmjHfiY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202510261909.eTmjHfiY-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   drivers/platform/x86/asus-wmi.c:2650:33: sparse: sparse: incorrect type in argument 3 (different base types) @@     expected unsigned int [usertype] val @@     got restricted __le32 [usertype] @@
   drivers/platform/x86/asus-wmi.c:2650:33: sparse:     expected unsigned int [usertype] val
   drivers/platform/x86/asus-wmi.c:2650:33: sparse:     got restricted __le32 [usertype]
   drivers/platform/x86/asus-wmi.c:1573:9: sparse: sparse: context imbalance in 'asus_hid_register_listener' - wrong count at exit
   drivers/platform/x86/asus-wmi.c: note: in included file (through include/linux/resource_ext.h, include/linux/acpi.h):
   include/linux/list.h:237:25: sparse: sparse: context imbalance in 'asus_hid_unregister_listener' - wrong count at exit
>> drivers/platform/x86/asus-wmi.c:1623:22: sparse: sparse: unsigned value that used to be signed checked against zero?
   drivers/platform/x86/asus-wmi.c:1601:25: sparse: signed value source

vim +1623 drivers/platform/x86/asus-wmi.c

6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1589  
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1590  static void kbd_led_update_all(struct work_struct *work)
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1591  {
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1592  	enum led_brightness value;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1593  	struct asus_wmi *asus;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1594  	bool registered, notify;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1595  	int ret;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1596  
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1597  	asus = container_of(work, struct asus_wmi, kbd_led_work);
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1598  
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1599  	scoped_guard(spinlock_irqsave, &asus_ref.lock) {
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1600  		registered = asus->kbd_led_registered;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1601  		value = asus->kbd_led_wk;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1602  		notify = asus->kbd_led_notify;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1603  	}
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1604  
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1605  	if (!registered) {
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1606  		/*
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1607  		 * This workqueue runs under asus-wmi, which means probe has
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1608  		 * completed and asus-wmi will keep running until it finishes.
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1609  		 * Therefore, we can safely register the LED without holding
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1610  		 * a spinlock.
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1611  		 */
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1612  		ret = devm_led_classdev_register(&asus->platform_device->dev,
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1613  					    &asus->kbd_led);
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1614  		if (!ret) {
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1615  			scoped_guard(spinlock_irqsave, &asus_ref.lock)
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1616  				asus->kbd_led_registered = true;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1617  		} else {
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1618  			pr_warn("Failed to register keyboard backlight LED: %d\n", ret);
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1619  			return;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1620  		}
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1621  	}
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1622  
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18 @1623  	if (value >= 0)
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1624  		do_kbd_led_set(&asus->kbd_led, value);
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1625  	if (notify) {
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1626  		scoped_guard(spinlock_irqsave, &asus_ref.lock)
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1627  			asus->kbd_led_notify = false;
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1628  		led_classdev_notify_brightness_hw_changed(&asus->kbd_led, value);
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1629  	}
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1630  }
6aed4b131ba1d1 Antheas Kapenekakis 2025-10-18  1631  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2025-11-03  9:16 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-18 10:17 [PATCH v7 0/9] HID: asus: Fix ASUS ROG Laptop's Keyboard backlight handling Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 1/9] HID: asus: simplify RGB init sequence Antheas Kapenekakis
2025-10-23 17:38   ` Denis Benato
2025-10-23 18:06     ` Antheas Kapenekakis
2025-10-23 20:04       ` Denis Benato
2025-10-23 21:30         ` Antheas Kapenekakis
2025-10-23 22:53           ` Denis Benato
2025-10-23 23:25             ` Antheas Kapenekakis
2025-10-24 16:20               ` Antheas Kapenekakis
2025-10-24 18:53                 ` Denis Benato
2025-10-24 21:20                   ` Antheas Kapenekakis
2025-10-25  1:25                     ` Denis Benato
2025-10-25  7:20                       ` Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 2/9] HID: asus: use same report_id in response Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 3/9] HID: asus: fortify keyboard handshake Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 4/9] HID: asus: prevent binding to all HID devices on ROG Antheas Kapenekakis
2025-10-23 18:23   ` Denis Benato
2025-10-23 18:27     ` Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 5/9] platform/x86: asus-wmi: Add support for multiple kbd led handlers Antheas Kapenekakis
2025-10-22 13:38   ` kernel test robot
2025-10-23  6:56     ` Antheas Kapenekakis
2025-10-31  8:26       ` Jiri Kosina
2025-10-31 12:13         ` Antheas Kapenekakis
2025-11-03  4:28           ` Derek J. Clark
2025-11-03  7:36             ` Antheas Kapenekakis
2025-11-03  8:37               ` luke
2025-11-03  8:48                 ` Antheas Kapenekakis
2025-11-03  9:05                   ` luke
2025-11-03  9:15                     ` Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 6/9] HID: asus: listen to the asus-wmi brightness device instead of creating one Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 7/9] platform/x86: asus-wmi: remove unused keyboard backlight quirk Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 8/9] platform/x86: asus-wmi: add keyboard brightness event handler Antheas Kapenekakis
2025-10-18 10:17 ` [PATCH v7 9/9] HID: asus: add support for the asus-wmi brightness handler Antheas Kapenekakis
  -- strict thread matches above, loose matches on Subject: below --
2025-10-26 11:26 [PATCH v7 5/9] platform/x86: asus-wmi: Add support for multiple kbd led handlers kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.