From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796302229; b=WjEUHiDaUe5js4hVNZMO2omgmvJAL+4q5i+Du3hYrGcnzuHJvRp5xuu/59CCc5IodxeH 9sWuntgoiHrgaBCdicXiwuCVFVuhT4DxqYYVQ9JUuAqFyGQVDwT/EJ8cjCpo9JGKu5N47 +nXy2GCVjHpDrloTN5frv4w+Bp450+dwZUKZvGI1rI48ScG44U2Piwy75vfauVqL+exOB h8QtpYOYyNpbCxDh+bM7c6fX5osg2UqV6PPE0rlIWsMOGRsEZL97gS1XLTANqV9zw9mv9 c2R6yAcKXFMCJkMWJ7DfYROwJOGlirQ1lxYTiJGOjIS0Rmmr/3ntuqg8TLtux3gwXLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796302229; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=rzpCQG59N5XR8DPAv9OAOqouOLZF7kNF00i2t42dY1U=; b=VPN+l7lIqUS+2lq+C1HqI7WOK/LFpNT9ZtuX8UmQFdnc//AbgPeMkpaDfePY7E47a5Pz dC/zX94YYC16JDHGOhQA5Ux1xB73JJs8f5RE4sXJolrv+wpjXCynu+0gp4KOsMYSuE+ks gOJO5JhBqTgC/sMIFwFxlYW1pnX7RnAUkSQJu1CC915ICm2UYXc0smBLP4ADh6JwPG735 Nlo8zNsal9SUVhajlWM1YgGq/9HyT2dZ97fRZ7BW2lb+2srCCe6LFJ23kZewtqEJzE1mc u1IIuhb2l3FDEwzBKu0/BAB5ELPc78RI780xmkPV4m9cgdhgfM6B+TOo+7r4xuFvkRA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JLrf4MtO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 096D2606A32C for ; Thu, 3 Dec 2026 12:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JLrf4MtO Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA50A1F000C1; Thu, 3 Dec 2026 12:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796302228; bh=rzpCQG59N5XR8DPAv9OAOqouOLZF7kNF00i2t42dY1U=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JLrf4MtOmcuU/TeW9AUiZj3Z7CIq9GQxxp48M1H5ai5QTn8vm/qPBqijIPGNCsZd7 p2xUVnch71bIkQ+BwwSIZCcgDTMRk9u4gJVnTxO67qdIi0iJn1DjcJ1dYkE4aDBYHV VQTgltgM64Q2Res1ZLuoH0h9H06MOnU9DPojA3Shfz6VIS6bJwk4IdNzHJKC7oDz2R I6v7b0DWVctVp/rALoM7rtSbnbIJRRazbdGjTkwZwXGvRh5uDib2tZxK3wQO0thoI4 5PBm6hL7FFatObBxO1Kp6J3Pt4zbsLM4NSk5jxf9PIAd8aoKDO5FIEkYJ5JNThc9o/ Tk3ZuQId7x1ug== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 4/6] platform/x86: thinkpad_acpi: Restore keyboard backlight level ourselves Reply-To: sashiko-reviews@lists.linux.dev To: "Qiling Zhu" Cc: linux-leds@vger.kernel.org, lee@kernel.org In-Reply-To: <20261203120704.41431-5-kmatzkaczor244@gmail.com> References: <20261203120704.41431-1-kmatzkaczor244@gmail.com> <20261203120704.41431-5-kmatzkaczor244@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 12:50:28 +0000 X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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/platfo= rm/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; > } > =20 > -static void kbdlight_suspend(void) > -{ > - struct led_classdev *led_cdev; > - > - if (!tp_features.kbdlight) > - return; > - > - led_cdev =3D &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=3D1, 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; > =20 > - 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 =3D 0 <-- clobbe= rs 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203120704.4143= 1-1-kmatzkaczor244@gmail.com?part=3D4