mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rong Zhang <i@rong.moe>
To: "Qiling Zhu" <kmatzkaczor244@gmail.com>,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>
Cc: Andrea Rabbaglietti <rabbagliettiandrea@gmail.com>,
	Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Griffin Kroah-Hartman <griffin@kroah.com>,
	vishnuocv@gmail.com, vsankar@lenovo.com,
	 platform-driver-x86@vger.kernel.org,
	ibm-acpi-devel@lists.sourceforge.net,
	 linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/7] platform/x86: thinkpad_acpi: Add support for auto keyboard backlight
Date: Sun, 15 Nov 2026 15:52:36 +0800	[thread overview]
Message-ID: <230263171c25c322d97fa29439a01922db47f913.camel@rong.moe> (raw)
In-Reply-To: <20261114174814.62153-1-kmatzkaczor244@gmail.com>

Hi Qiling,

Thanks for working on this.

On Sun, 2026-11-15 at 01:48 +0800, Qiling Zhu wrote:
> Hi all,
> 
> Thanks, Rong, for the two rounds of detailed review, Vishnu and Mark
> for the firmware-side answers, and Andrea for the bug report that
> became the first patch. This v3 addresses the feedback in full; the
> series grew from two to seven patches to pick up the suggested
> structure and to make the fixes independently backportable.

The next time when you send a series (i.e., PATCH x/n, n > 1), please do
not reply to the previous thread to keep it tidy.

> 
> The series in short:
> 
>   1/7  Report auto mode as brightness 0 instead of 3          (stable fix)
>   2/7  Extract kbdlight_notify_change() helpers               (refactor)
>   3/7  Sync LED core state on level writes          (write-path sync)
>   4/7  Detect auto-mode capability via MLCG bit 20            (groundwork)
>   5/7  Skip LED suspend/resume on auto-mode machines
>   6/7  Add support for auto keyboard backlight                 (the feature)
>   7/7  Reconcile EC level on resume
> 
> Changes since v2, by comment:
> 
> * The notification path is now split as suggested: a helper that accepts
>   a level and a wrapper that queries the EC (2/7), and the proc write
>   path goes through it (3/7), like commit 07f48f668fac did for the
>   ideapad FnLock LED. The manual check-then-act trigger removal is gone
>   entirely; leaving auto mode through either interface now drops the
>   trigger through the LED core.
> 
> * LED suspend/resume is skipped entirely on machines that support auto
>   mode, keyed on the capability bit rather than the current level (5/7),
>   as suggested. My testing confirms the firmware restores the previous
>   level on its own in all cases except auto mode across hibernation;
>   less state remains in the driver, and the class of races around
>   LED_SUSPENDED disappears.
> 
> * activate() is now a one-liner with no read-back verification (6/7);
>   it only writes the level, using the plain set helper. I did not use
>   the updating wrapper there on purpose: the trigger core is in the
>   middle of its own activation flow at that point, and the 0x1012 event
>   that follows the level change is expected to bring the state back in
>   sync through the regular notify path.
> 
> * Trigger registration is gated on MLCG bit 20 as per Vishnu's
>   confirmation (4/7 + 6/7).
> 
> * Andrea's report is fixed by 1/7, which reports auto mode as 0 to the
>   LED classdev and is marked for stable. It is deliberately minimal -
>   a single check, no further splitting - to keep backporting easy.
> 
> * On the proc attribute deprecation: I support the idea, deferring to
>   the thinkpad_acpi maintainers.
> 
> One addition that was not in v2: testing showed that the firmware does
> not restore auto mode across hibernation
> 

How about s2idle? And what if hw brightness = [0,2] before hibernation?

Meanwhile, could you test s2idle, hibernation and cold boots with
thinkpad_acpi blacklisted to see if hw brightness ([0,2] and 3) is
preserved? We need the raw behavior to determine our strategy.

>  - the EC comes back with the
> backlight off, without an event. Rather than re-attaching the trigger
> from the pre-suspend state, 
> 

"re-attaching"

I am not familiar with hibernation, so I am not sure if the LED core
would detach the trigger before entering hibernation. If not, why did you
say that?

Thanks,
Rong

> 7/7 simply re-reads the EC level on resume
> and routes it through the regular notification path. If the firmware
> exits auto mode across hibernation, the driver simply reflects the
> resulting EC state rather than restoring the previous mode: it stays
> out of the firmware's way and only synchronizes, which keeps the code
> simple. Happy to hear opinions.
> 
> A few notes on the result:
> 
> * Writing a level through either interface now also emits
>   brightness_hw_changed: both write paths share the same notify helper,
>   which keeps the LED core and userspace listeners consistent with the
>   new level no matter which interface was used. Rewriting the current
>   level emits nothing, matching the firmware's own
>   no-event-on-same-level semantics. Extending the notification to
>   userspace-initiated changes seemed reasonable to me - the OSD then
>   also reflects echo-based changes - but I'm happy to restrict it to
>   hardware-initiated transitions if that is considered the better
>   semantics.
> 
> * All state transitions now run under kbdlight_mutex in single
>   critical sections (query + reconcile, write + reconcile), with the
>   set and notify helpers expecting the caller to hold it. On the
>   ordering with the LED core's trigger_lock, my reasoning is that the
>   trigger callbacks (activate, hw_offloaded) are reached with
>   trigger_lock held and then take kbdlight_mutex, while the
>   notification helper is lock-free (it only queues the worker), so I
>   don't see a reverse nesting. Extra eyes on this are welcome.
> 
> * The cached level is now the raw EC level including auto mode, so the
>   kbdlight_brightness name has drifted a bit from what it holds.
>   Renaming it would touch quite a few places; I left it as is for now
>   and can do the rename as a follow-up if preferred.
> 
> One open question, mainly for Mark and Vishnu: the skip of LED
> suspend/resume assumes the firmware turns the backlight off on suspend
> and restores it on resume on all auto-mode capable machines, which is
> what I observed here for manual levels (suspend and hibernation), auto
> across suspend, and auto across hibernation coming back off. My belief
> is that most machines handle this fine, but more testing on other
> models or a look at the EC documentation from the Lenovo side would be
> needed to be sure; if an exception turns up, a DMI quirk could restore
> the old path for that machine.
> 
> Tested on my ThinkPad X1 Carbon Gen 14 (linux-next next-20261030).
> 
> I'm still learning the ways of upstream; thank you all for your time
> and reviews, and any further comments are most welcome.
> 
> This series was developed with LLM assistance; I reviewed every design
> decision against the framework sources and validated the behavior on
> real hardware myself.
> 
> Regards,
> Qiling Zhu
> 
> Qiling Zhu (7):
>   platform/x86: thinkpad_acpi: Report auto keyboard backlight mode as off
>   platform/x86: thinkpad_acpi: Extract kbdlight_notify_change() helpers
>   platform/x86: thinkpad_acpi: Sync LED core state on level writes
>   platform/x86: thinkpad_acpi: Detect auto-mode capability via MLCG
>   platform/x86: thinkpad_acpi: Skip LED suspend/resume on auto-mode machines
>   platform/x86: thinkpad_acpi: Add support for auto keyboard backlight
>   platform/x86: thinkpad_acpi: Reconcile EC level on resume

      parent reply	other threads:[~2026-11-15  7:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 10:01 [RFC PATCH 0/1] " Qiling Zhu
2026-11-01 10:01 ` [RFC PATCH 1/1] " Qiling Zhu
2026-11-01 18:24   ` Rong Zhang
2026-11-01 17:57 ` [RFC PATCH 0/1] " Rong Zhang
2026-11-04  4:57   ` Vishnu Sankar
2026-11-02 15:10 ` [RFC PATCH v2 0/2] " Qiling Zhu
2026-11-02 15:10   ` [RFC PATCH v2 1/2] platform/x86: thinkpad_acpi: Extract kbdlight_notify_change() helper Qiling Zhu
2026-11-02 15:10   ` [RFC PATCH v2 2/2] platform/x86: thinkpad_acpi: Add support for auto keyboard backlight Qiling Zhu
2026-11-02 18:32     ` Rong Zhang
2026-11-02 18:13   ` [RFC PATCH v2 0/2] " Rong Zhang
2026-11-05 13:18     ` Qiling Zhu
2026-11-14 17:48   ` [PATCH v3 0/7] platform/x86: thinkpad_acpi: " Qiling Zhu
2026-11-14 17:48     ` [PATCH v3 1/7] platform/x86: thinkpad_acpi: Report auto keyboard backlight mode as off Qiling Zhu
2026-11-15  7:53       ` Rong Zhang
2026-11-14 17:48     ` [PATCH v3 2/7] platform/x86: thinkpad_acpi: Extract kbdlight_notify_change() helpers Qiling Zhu
2026-11-15  7:53       ` Rong Zhang
2026-11-14 17:48     ` [PATCH v3 3/7] platform/x86: thinkpad_acpi: Sync LED core state on level writes Qiling Zhu
2026-11-15  8:05       ` Rong Zhang
2026-11-14 17:48     ` [PATCH v3 4/7] platform/x86: thinkpad_acpi: Detect auto-mode capability via MLCG Qiling Zhu
2026-11-15  8:05       ` Rong Zhang
2026-11-14 17:48     ` [PATCH v3 5/7] platform/x86: thinkpad_acpi: Skip LED suspend/resume on auto-mode machines Qiling Zhu
2026-11-14 17:48     ` [PATCH v3 6/7] platform/x86: thinkpad_acpi: Add support for auto keyboard backlight Qiling Zhu
2026-11-15  8:17       ` Rong Zhang
2026-11-14 17:48     ` [PATCH v3 7/7] platform/x86: thinkpad_acpi: Reconcile EC level on resume Qiling Zhu
2026-11-15  8:20       ` Rong Zhang
2026-11-15  7:52     ` Rong Zhang [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=230263171c25c322d97fa29439a01922db47f913.camel@rong.moe \
    --to=i@rong.moe \
    --cc=derekjohn.clark@gmail.com \
    --cc=griffin@kroah.com \
    --cc=hansg@kernel.org \
    --cc=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kmatzkaczor244@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=pavel@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rabbagliettiandrea@gmail.com \
    --cc=vishnuocv@gmail.com \
    --cc=vsankar@lenovo.com \
    /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

all inboxes | Powered by JetHome®