From: sashiko-bot@kernel.org
To: "Qiling Zhu" <kmatzkaczor244@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v6 4/6] platform/x86: thinkpad_acpi: Restore keyboard backlight level ourselves
Date: Thu, 03 Dec 2026 12:50:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-247789@kernel.org> (raw)
In-Reply-To: <20261203120704.41431-5-kmatzkaczor244@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] platform/x86: thinkpad_acpi: dropping kbdlight_suspend()
leaves backlight on
- [Medium] platform/x86: thinkpad_acpi: kbdlight_resume() writes stale
cached EC level
- [Medium] platform/x86: thinkpad_acpi: unquiesced kbdlight work during
sleep
- [Low] platform/x86: thinkpad_acpi: HKEY notify can clobber
kbdlight_brightness
--
commit 0004fa8e5cc196a98da2ae4e21a488719717aed0
Author: Qiling Zhu <kmatzkaczor244@gmail.com>
platform/x86: thinkpad_acpi: Restore keyboard backlight level ourselves
This commit drops kbdlight_suspend() so firmware handles turning off the
keyboard backlight during sleep, changes kbdlight_brightness to track
raw EC levels (0 to 3), and writes kbdlight_brightness directly back to
the EC in kbdlight_resume().
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 80601ed2cfc16..764b1efa66fa2 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
[ ... ]
> @@ -5343,31 +5351,19 @@ static int kbdlight_write(char *buf)
> return 0;
> }
>
> -static void kbdlight_suspend(void)
> -{
> - struct led_classdev *led_cdev;
> -
> - if (!tp_features.kbdlight)
> - return;
> -
> - led_cdev = &tpacpi_led_kbdlight.led_classdev;
> - led_update_brightness(led_cdev);
> - led_classdev_suspend(led_cdev);
> -}
> -
[Severity: Medium]
Can removing kbdlight_suspend() leave the keyboard backlight powered on
during sleep on non-LPS0 ThinkPads?
tpacpi_led_kbdlight.led_classdev does not set LED_CORE_SUSPENDRESUME, so
thinkpad_acpi now relies entirely on firmware to turn the backlight off.
On older S3-only ThinkPads, dual-mode models set to S3 in BIOS, or
systems with acpi.sleep_no_lps0=1, acpi_s2idle_prepare_late_lps0()
returns early without notifying firmware or the EC during s2idle. The
backlight then stays on and drains the battery for the whole sleep.
Keeping kbdlight_suspend() to save the raw EC level and turn the
backlight off without clobbering the saved level would preserve auto
mode without regressing non-LPS0 s2idle or untested S3 models.
[Severity: Medium]
Does dropping led_classdev_suspend() leave set_brightness_work
unquiesced across suspend and hibernation?
tpacpi_led_kbdlight uses brightness_set_blocking, which runs
set_brightness_work on leds_wq (allocated without WQ_FREEZABLE).
Without LED_SUSPENDED gating and flush_work() from
led_classdev_suspend(), pending writes or LED triggers keep running:
CPU0 kworker (leds_wq)
acpi_pm_freeze()
acpi_ec_block_transactions()
set_brightness_delayed()
kbdlight_sysfs_set()
kbdlight_set_level_and_update()
kbdlight_set_level() <-- -EIO
Because kbdlight_set_level_and_update() returns early on error without
updating kbdlight_brightness, the pre-suspend brightness change is lost
on resume alongside ACPI and LED error logs.
During s2idle, unquiesced work or an active LED trigger running after
acpi_s2idle_prepare_late_lps0() can also turn the backlight back on
after firmware turned it off.
> static void kbdlight_resume(void)
> {
> if (!tp_features.kbdlight)
> return;
>
> - led_classdev_resume(&tpacpi_led_kbdlight.led_classdev);
> + guard(mutex)(&kbdlight_mutex);
> + kbdlight_set_level(kbdlight_brightness);
> }
[Severity: Medium]
Can kbdlight_resume() overwrite the live EC level with a stale
kbdlight_brightness now that kbdlight_suspend() no longer refreshes it?
Previously, led_update_brightness() read the live EC level before sleep.
Without that refresh, kbdlight_brightness can drift: when
TP_ACPI_HKEY_KBD_LIGHT_MASK is set in hotkey_source_mask,
hotkey_notify_hotkey() drops TP_HKEY_EV_KBD_LIGHT events.
kbdlight_resume() then writes the stale cached level back to the EC,
changing the backlight unexpectedly even on s2idle systems where the EC
preserved the real pre-suspend level.
Refreshing kbdlight_brightness from kbdlight_get_level() under
kbdlight_mutex during suspend would keep it accurate for all modes.
[Severity: Low]
Can an ACPI TP_HKEY_EV_KBD_LIGHT notification during sleep entry or
early resume clobber kbdlight_brightness before kbdlight_resume() runs?
Previously, kbdlight_suspend() saved the pre-sleep level in
led_cdev->brightness, while kbdlight_notify_change() only updated
kbdlight_brightness. Now kbdlight_brightness is both the live hotkey
cache and the saved pre-sleep state.
kacpi_notify_wq is not WQ_FREEZABLE, and acpi_pm_finish() re-enables
runtime GPEs and executes _WAK before dpm_resume() runs
tpacpi_resume_handler() (where hotkey_resume() also runs before
kbdlight_resume()):
CPU0 kworker (kacpi_notify_wq)
acpi_pm_finish()
acpi_hw_legacy_wake()
acpi_hw_enable_all_runtime_gpes()
dispatch_acpi_notify()
kbdlight_notify_change()
kbdlight_get_level() -> 0
kbdlight_brightness = 0 <-- clobbers
dpm_resume()
kbdlight_resume()
kbdlight_set_level(0)
If firmware emits TP_HKEY_EV_KBD_LIGHT while the backlight is 0 during
sleep entry or early resume, kbdlight_resume() restores 0 instead of the
pre-sleep level and emits a spurious brightness_hw_changed(0) event.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203120704.41431-1-kmatzkaczor244@gmail.com?part=4
next prev parent reply other threads:[~2026-12-03 12:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:06 [PATCH v6 0/6] platform/x86: thinkpad_acpi: Add a keyboard backlight auto-mode trigger Qiling Zhu
2026-12-03 12:06 ` [PATCH v6 1/6] platform/x86: thinkpad_acpi: Report auto keyboard backlight mode as off Qiling Zhu
2026-12-03 12:07 ` [PATCH v6 2/6] platform/x86: thinkpad_acpi: Extract kbdlight notify helpers Qiling Zhu
2026-12-03 12:07 ` [PATCH v6 3/6] platform/x86: thinkpad_acpi: Don't poke keyboard backlight's LED core brightness Qiling Zhu
2026-12-03 12:07 ` [PATCH v6 4/6] platform/x86: thinkpad_acpi: Restore keyboard backlight level ourselves Qiling Zhu
2026-12-03 12:50 ` sashiko-bot [this message]
2026-12-03 12:07 ` [PATCH v6 5/6] platform/x86: thinkpad_acpi: Detect auto-mode capability via MLCG Qiling Zhu
2026-12-03 12:07 ` [PATCH v6 6/6] platform/x86: thinkpad_acpi: Add a keyboard backlight auto-mode trigger Qiling Zhu
2026-12-03 12:50 ` sashiko-bot
2026-12-03 12:50 ` [PATCH v6 0/6] " sashiko-bot
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=sashiko-outbox-247789@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kmatzkaczor244@gmail.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--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