From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Antheas Kapenekakis <lkml@antheas.dev>
Cc: platform-driver-x86@vger.kernel.org, linux-input@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Corentin Chary <corentin.chary@gmail.com>,
"Luke D . Jones" <luke@ljones.dev>,
Hans de Goede <hdegoede@redhat.com>,
Denis Benato <benato.denis96@gmail.com>
Subject: Re: [PATCH v6 3/7] platform/x86: asus-wmi: Add support for multiple kbd RGB handlers
Date: Thu, 16 Oct 2025 13:38:09 +0300 (EEST) [thread overview]
Message-ID: <75807bcc-2b51-4b34-5173-433f3aedae76@linux.intel.com> (raw)
In-Reply-To: <CAGwozwEo+Mx8fv_ohQQ9Ha6p=bJcJmfj==aRGcgoqQXzXEZmVw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4253 bytes --]
On Thu, 16 Oct 2025, Antheas Kapenekakis wrote:
> On Thu, 16 Oct 2025 at 12:19, Ilpo Järvinen
> <ilpo.jarvinen@linux.intel.com> wrote:
> >
> > On Wed, 15 Oct 2025, Antheas Kapenekakis wrote:
> >
> > > On Wed, 15 Oct 2025 at 13:59, Ilpo Järvinen
> > > <ilpo.jarvinen@linux.intel.com> wrote:
> > > >
> > > > On Mon, 13 Oct 2025, Antheas Kapenekakis wrote:
> > > >
> > > > > Some devices, such as the Z13 have multiple AURA devices connected
> > > > > to them by USB. In addition, they might have a WMI interface for
> > > > > RGB. In Windows, Armoury Crate exposes a unified brightness slider
> > > > > for all of them, with 3 brightness levels.
> > > > >
> > > > > Therefore, to be synergistic in Linux, and support existing tooling
> > > > > such as UPower, allow adding listeners to the RGB device of the WMI
> > > > > interface. If WMI does not exist, lazy initialize the interface.
> > > > >
> > > > > Reviewed-by: Luke D. Jones <luke@ljones.dev>
> > > > > Tested-by: Luke D. Jones <luke@ljones.dev>
> > > > > Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
> > > > > ---
> > > > > drivers/platform/x86/asus-wmi.c | 118 ++++++++++++++++++---
> > > > > include/linux/platform_data/x86/asus-wmi.h | 16 +++
> > > > > 2 files changed, 121 insertions(+), 13 deletions(-)
> > > > >
> > > > > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> > > > > index e72a2b5d158e..a2a7cd61fd59 100644
> > > > > --- a/drivers/platform/x86/asus-wmi.c
> > > > > +++ b/drivers/platform/x86/asus-wmi.c
> > > > > @@ -258,6 +258,8 @@ struct asus_wmi {
> > > > > int tpd_led_wk;
> > > > > struct led_classdev kbd_led;
> > > > > int kbd_led_wk;
> > > > > + bool kbd_led_avail;
> > > > > + bool kbd_led_registered;
> > > > > struct led_classdev lightbar_led;
> > > > > int lightbar_led_wk;
> > > > > struct led_classdev micmute_led;
> > > > > @@ -1530,6 +1532,53 @@ static void asus_wmi_battery_exit(struct asus_wmi *asus)
> > > > >
> > > > > /* LEDs ***********************************************************************/
> > > > >
> > > > > +struct asus_hid_ref {
> > > > > + struct list_head listeners;
> > > > > + struct asus_wmi *asus;
> > > > > + spinlock_t lock;
> > > >
> > > > Please always document what a lock protects.
> > > >
> > > > I started wonder why it needs to be spinlock?
> > > >
> > > > It would seem rwsem is more natural for it as write is only needed at
> > > > probe/remove time (if there's no good reason for using a spinlock).
> > > >
> > > > You're also missing include.
> > >
> > > I went through the comments. Thanks. The reason that it is a spinlock
> > > is that both hid-asus and asus-wmi interact with the primitives to
> > > register and unregister listeners, either of which can prompt the
> > > creation of the led device which has to be atomic. And they do so from
> > > IRQs too.
> >
> > Please note in the changelog how it can happen from IRQs as I tried but
> > couldn't find anything. Admittedly, I didn't try to follow the callchains
> > that deeply. The justification should be clear enough to anyone who
> > looks this commit later so better have it in the changelog.
>
> The initial versions used a mutex, and we found kernel hangs under
> IRQs, so it was converted to a spinlock. I will try to reword.
> Specifically, I think the errors came when holding the lock when
> changing brightness.
>
> I recall one of them was brightness hotkey (second to last patch)
> triggers an IRQ -> event goes to asus-wmi -> calls brightness handler
> -> tries to hold lock -> crashes. Lock needs to be held because
> hid-asus can choose to unregister a listener.
If you're not certain and want an easy way to obtain a stacktrace to
confirm, you can likely do something like:
WARN_ON_ONCE(in_atomic());
...at where you are taking the lock.
--
i.
> > > Perhaps the driver could be refactored to use rwsem, I am not sure.
> >
> > Just leave it spinlock.
> >
> > > The fixed version can be found here[1]. I will give it 1-2 more days
> > > in case someone else wants to chime in and resend.
> >
> >
> >
> > --
> > i.
>
next prev parent reply other threads:[~2025-10-16 10:38 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 20:15 [PATCH v6 0/7] HID: asus: Fix ASUS ROG Laptop's Keyboard backlight handling Antheas Kapenekakis
2025-10-13 20:15 ` [PATCH v6 1/7] HID: asus: refactor init sequence per spec Antheas Kapenekakis
2025-10-15 10:53 ` Ilpo Järvinen
2025-10-15 11:18 ` Antheas Kapenekakis
2025-10-15 11:30 ` Ilpo Järvinen
2025-10-13 20:15 ` [PATCH v6 2/7] HID: asus: prevent binding to all HID devices on ROG Antheas Kapenekakis
2025-10-15 10:59 ` Ilpo Järvinen
2025-10-13 20:15 ` [PATCH v6 3/7] platform/x86: asus-wmi: Add support for multiple kbd RGB handlers Antheas Kapenekakis
2025-10-15 11:59 ` Ilpo Järvinen
2025-10-15 15:45 ` Antheas Kapenekakis
2025-10-16 10:18 ` Ilpo Järvinen
2025-10-16 10:23 ` Antheas Kapenekakis
2025-10-16 10:38 ` Ilpo Järvinen [this message]
2025-10-13 20:15 ` [PATCH v6 4/7] HID: asus: listen to the asus-wmi brightness device instead of creating one Antheas Kapenekakis
2025-10-13 21:44 ` Denis Benato
2025-10-13 21:57 ` Antheas Kapenekakis
2025-10-13 22:06 ` Denis Benato
2025-10-13 22:18 ` Antheas Kapenekakis
2025-10-13 22:50 ` Denis Benato
2025-10-13 20:15 ` [PATCH v6 5/7] platform/x86: asus-wmi: remove unused keyboard backlight quirk Antheas Kapenekakis
2025-10-13 20:15 ` [PATCH v6 6/7] platform/x86: asus-wmi: add keyboard brightness event handler Antheas Kapenekakis
2025-10-15 12:18 ` Ilpo Järvinen
2025-10-15 15:38 ` Antheas Kapenekakis
2025-10-13 20:15 ` [PATCH v6 7/7] HID: asus: add support for the asus-wmi brightness handler Antheas Kapenekakis
2025-10-13 21:37 ` Denis Benato
2025-10-13 21:36 ` [PATCH v6 0/7] HID: asus: Fix ASUS ROG Laptop's Keyboard backlight handling Denis Benato
2025-10-13 21:45 ` Antheas Kapenekakis
2025-10-16 11:57 ` Denis Benato
2025-10-16 12:14 ` Antheas Kapenekakis
2025-10-16 12:19 ` Denis Benato
2025-10-16 12:28 ` Antheas Kapenekakis
2025-10-16 12:46 ` Denis Benato
2025-10-16 12:51 ` Antheas Kapenekakis
2025-10-16 14:32 ` Denis Benato
2025-10-16 14:44 ` Antheas Kapenekakis
2025-10-16 14:44 ` Antheas Kapenekakis
2025-10-16 15:16 ` Denis Benato
2025-10-16 15:08 ` Ilpo Järvinen
2025-10-16 16:16 ` Antheas Kapenekakis
2025-10-17 7:54 ` Antheas Kapenekakis
2025-10-17 11:00 ` Denis Benato
2025-10-17 11:21 ` Antheas Kapenekakis
2025-10-20 17:13 ` Ilpo Järvinen
2025-10-20 18:54 ` Antheas Kapenekakis
2025-10-17 10:36 ` Ilpo Järvinen
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=75807bcc-2b51-4b34-5173-433f3aedae76@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=benato.denis96@gmail.com \
--cc=bentiss@kernel.org \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@antheas.dev \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).