From: sashiko-bot@kernel.org
To: "Rodnei Cilto" <rodnei.cilto@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 2/2] platform/x86: ideapad-laptop: add CapsLock/NumLock LED via EC
Date: Sun, 28 Jun 2026 02:06:09 +0000 [thread overview]
Message-ID: <20260628020609.EAFA51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260628-ideapad-kbd-leds-v1-2-50b421d94927@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Sleeping in atomic context due to improper LED brightness callback assignment.
- [Medium] Unsynchronized read-modify-write on the shared EC keyboard LED register.
- [Medium] Missing default triggers for CapsLock and NumLock LEDs.
--
commit 3bd8490b486c6791548a82ecc890f8f432c92886
Author: Rodnei Cilto <rodnei.cilto@gmail.com>
platform/x86: ideapad-laptop: add CapsLock/NumLock LED via EC
This commit adds support for physical CapsLock and NumLock LEDs on specific
Lenovo IdeaPad laptops (83RR/83SR). It maps the EC's offset 0xA1 bits 5 and
4 to CAPL and NUML and exposes them as led_classdev entries.
> diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
[ ... ]
> +static int ideapad_kbd_led_ec_set(u8 bit, bool on)
> +{
> + u8 val;
> + int err;
> +
> + err = ec_read(IDEAPAD_EC_KBD_LED_OFFSET, &val);
> + if (err)
> + return err;
> + if (on)
> + val |= bit;
> + else
> + val &= ~bit;
> + err = ec_write(IDEAPAD_EC_KBD_LED_OFFSET, val);
[Severity: Medium]
Is this read-modify-write sequence safe against concurrent updates?
Since CapsLock and NumLock are exposed as separate led_classdev devices, the
LED subsystem protects their state with independent locks. If both LEDs are
toggled simultaneously, could two threads concurrently enter
ideapad_kbd_led_ec_set(), read the same initial value, and write it back,
causing one modification to overwrite and lose the other?
> + if (err)
> + return err;
> + acpi_evaluate_object(NULL, IDEAPAD_ACPI_EC0_QDF_PATH, NULL, NULL);
> + return 0;
> +}
[ ... ]
> +static int ideapad_kbd_leds_init(struct ideapad_private *priv)
> +{
> + int err;
> +
> + if (WARN_ON(priv->kbd_leds.initialized))
> + return -EEXIST;
> +
> + priv->kbd_leds.capslock.name = "input::capslock";
> + priv->kbd_leds.capslock.max_brightness = 1;
> + priv->kbd_leds.capslock.brightness_set = ideapad_capslock_led_set;
[Severity: Medium]
Will this LED automatically synchronize with the system's actual keyboard lock
state? Without setting .default_trigger = "kbd-capslock", the LED subsystem
might not automatically link the keyboard input state to this LED, requiring
manual sysfs configuration.
[Severity: High]
Does this risk a scheduling while atomic panic? The LED subsystem often calls
the non-blocking brightness_set callback from atomic contexts, like softirq
for keyboard input triggers.
Since ideapad_capslock_led_set() calls ideapad_kbd_led_ec_set(), which uses
ec_read() and ec_write() that acquire mutexes and sleep, should this use
brightness_set_blocking instead to safely defer execution to a workqueue?
> + priv->kbd_leds.capslock.brightness_get = ideapad_capslock_led_get;
> + priv->kbd_leds.capslock.flags = LED_RETAIN_AT_SHUTDOWN;
> +
> + err = led_classdev_register(&priv->platform_device->dev,
> + &priv->kbd_leds.capslock);
> + if (err)
> + return err;
> +
> + priv->kbd_leds.numlock.name = "input::numlock";
> + priv->kbd_leds.numlock.max_brightness = 1;
> + priv->kbd_leds.numlock.brightness_set = ideapad_numlock_led_set;
[Severity: Medium]
Similarly, should this have .default_trigger = "kbd-numlock" set to ensure
the NumLock LED automatically tracks the physical keyboard state?
[Severity: High]
As with the CapsLock LED, does this need to use brightness_set_blocking to
avoid sleeping in atomic context when the trigger updates the LED?
> + priv->kbd_leds.numlock.brightness_get = ideapad_numlock_led_get;
> + priv->kbd_leds.numlock.flags = LED_RETAIN_AT_SHUTDOWN;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260628-ideapad-kbd-leds-v1-0-50b421d94927@gmail.com?part=2
prev parent reply other threads:[~2026-06-28 2:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 1:57 [PATCH 0/2] Add keyboard LED support for Lenovo IdeaPad 83RR/83SR Rodnei Cilto
2026-06-29 1:57 ` [PATCH 1/2] input: atkbd: add softleds quirk for broken EC PS/2 emulation Rodnei Cilto
2026-06-28 2:09 ` sashiko-bot
2026-06-28 5:20 ` Dmitry Torokhov
2026-06-29 1:57 ` [PATCH 2/2] platform/x86: ideapad-laptop: add CapsLock/NumLock LED via EC Rodnei Cilto
2026-06-28 2:06 ` sashiko-bot [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=20260628020609.EAFA51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=rodnei.cilto@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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