* [RFC PATCH v3 0/5] platform/x86: huawei-wmi: expose native firmware power profiles
@ 2026-11-24 17:25 Fuwei Xie
2026-11-25 1:50 ` Zheng Shuyang
0 siblings, 1 reply; 2+ messages in thread
From: Fuwei Xie @ 2026-11-24 17:25 UTC (permalink / raw)
To: Ilpo Järvinen, Hans de Goede
Cc: Fuwei Xie, platform-driver-x86, linux-kernel, Eren Özen,
Zheng Shuyang
Hi Ilpo, Hans, Eren and Zheng,
This is RFC v3. Thank you for the review of v2 and for the tests from
Eren and Zheng.
1. What this series does
Huawei firmware on some MateBook and HONOR machines provides a
balanced/performance mode through the WMI methods \GTUB (read) and
\STUB (write). This series exposes that mode through platform_profile,
so the desktop power mode control can switch it.
The driver only maps the firmware state and reports changes. It does
not write RAPL limits, does not force a fixed wattage, and does not
add a background daemon. Probe checks that both methods exist and
samples the current mode once; it never changes the mode to probe.
Profile reads use the cached mode. A userspace write sends STUB and
returns its status. Fn+P events carry the new mode; on 0x2a6 and
0x2a5 the driver re-reads the firmware mode.
2. What changed since v2
2.1 Reply ownership and the two-call handshake.
A preparatory patch moves each ACPI reply into a __free(kfree)
scope, so the first reply is released before a retry. The method
mutex is held across both attempts.
2.2 The sized WMI interface.
Following the review, normal commands use wmidev_invoke_method()
with its min_size argument. Both firmware layouts have a
four-byte prefix followed by the status byte; the WMI core
unmarshals them and the driver checks the fields each getter
needs. On the NbF-XX, WMAA returns status 1 in a full-sized reply
on the first call and dispatches the command on the second.
2.3 Binding the WMI devices.
The method GUID is bound through the WMI bus, and the hotkey and
legacy key data GUIDs are bound by two more WMI drivers. The
existing platform device and its sysfs paths are kept as the
parent of the userspace interfaces. Event-only machines keep
working without the method device.
2.4 0x2a6 and 0x2a5.
A STUB write can return success while the EC still reverts the
mode a few tens of milliseconds later. The driver therefore
refreshes the reported mode on 0x2a6 instead of trusting an
immediate readback. Zheng measured the revert at about 51.8 ms
on FMB-P; that firmware also emits 0x2a5 for TBF2-restricted
transitions, and v3 refreshes on 0x2a5 as well.
3. What the five patches do
Patch 1 scopes each ACPI reply and releases it with __free(kfree)
before a retry.
Patch 2 binds the method GUID and gives the platform device the
bound wmi_device, keeping the existing sysfs location and the
event-only path.
Patch 3 moves normal commands to wmidev_invoke_method() with
min_size, holds the mutex across both attempts, and validates the
data each getter needs.
Patch 4 registers platform_profile, samples the firmware once, reads
from the cache, writes STUB, and refreshes on the WMI mode events.
Patch 5 binds the hotkey and legacy key data devices on the WMI bus,
keeps the existing input and sysfs paths, and displays the marshalled
WMI reply bytes in debugfs.
4. What I tested
4.1 Hardware.
Capability detection, platform_profile registration and
switching work without a DMI entry on:
- NbF-XX, Intel i5-1240P, BIOS 3.07, Ubuntu 7.3.0-10
- MateBook 16 CREM-WXX9, Ryzen 7 5800H, BIOS 2.32
- HONOR MagicBook Pro 14 FMB-P, Core Ultra 5 225H, BIOS 1.16
On NbF-XX the final series was hot-loaded; platform_profile
reads balanced, Fn Lock reads 0 and the charge thresholds read
75/80. Eren covered Fn+P and AC unplug on CREM-WXX9; Zheng
covered those plus s2idle, battery thresholds, Fn Lock, the
micmute LED and module reload on FMB-P. Physical Fn+P and unplug
on NbF-XX with the current revision are still pending.
4.2 0x2a6 timing.
Zheng measured a refused STUB returning success in 0.8 ms while
GTUB still read 1 at 0.9 ms; the EC reverted CRWM at 51.8 ms and
emitted 0x2a6. The driver therefore refreshes on the event
instead of reading back immediately.
4.3 Build and host tests.
The five patches apply to c339f4010dea and build as modules with
W=1 for the development tree and Ubuntu 7.3.0-10-generic; the
final revision was built by DKMS and hot-loaded. QEMU covered
modern and event-only firmware, duplicate GUIDs, and
unbind/rebind; the transport and profile harnesses passed 54 and
19 cases with ASan and UBSan.
4.4 thermald.
Ubuntu's default thermald 2.5.12-1 caps PL1 below the firmware
ceiling (25.2 W instead of 28 W on NbF-XX); thermald_next
(8eeddcff786b, including f9411e884698) returns the full 28 W.
That ceiling is set outside this driver.
4.5 Firmware quirk on NbF-XX (BIOS 3.07).
Fn+P enables Turbo at about 20% displayed charge, while STUB
enables Turbo at about 20% battery health. The driver reports
the firmware state and does not paper over the difference; the
21% boundary is not tested.
5. What I did not test
- other models, BIOS versions or firmware revisions
- long runs, repeated suspend cycles, or concurrent stress
- 0x2a5 semantics beyond Zheng's FMB-P observation
- fan RPM; this machine exposes no fan sensor
6. Userspace counterparts
6.1 ppd reads a firmware notification after about two seconds.
sysfs_notify() generates a modification event without a
close-write event. power-profiles-daemon 0.30's platform-profile
driver only acts on G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, so a
Fn+P change reaches D-Bus about 2 s later. Handling
G_FILE_MONITOR_EVENT_CHANGED as well, watching the inode with
G_FILE_MONITOR_WATCH_HARD_LINKS, and setting the monitor rate
limit to zero brings the observed Fn+P-to-D-Bus latency to
11.6 ms going to performance and 6.8 ms going back to balanced
with the same kernel. That change belongs to ppd and will be sent
to the ppd project separately.
6.2 tuned-ppd needs sysfs_acpi_monitor for firmware-initiated changes.
Stock power-profiles-daemon 0.30 follows the notification
immediately. Fedora's tuned-ppd only follows external
platform_profile changes while its sysfs_acpi_monitor option is
enabled (off by default before tuned commit bd5f2850, which
enables it); see
https://github.com/redhat-performance/tuned/issues/710. Enabling
the option in ppd.conf or upgrading tuned makes the menu follow
Fn+P.
7. Related change: Eren's charge-mode patch
Eren's \SBCM patch also touches huawei_wmi_battery_get(), so the two
series conflict in a few lines. v3 changes the helper signatures and
the reply offsets; after his patch lands I will rebase on top of it.
The combined tree builds cleanly; a hardware retest is pending.
8. Questions
1. Is keeping the platform device for the existing sysfs ABI while
binding the method, event and data devices on the WMI bus the
right shape?
2. Is treating 0x2a5 like 0x2a6 (re-read the mode, notify only on a
change) acceptable, or would you prefer to leave 0x2a5 unhandled
until its meaning is confirmed?
3. Would you like the series split differently, for example the
transport and __free changes sent separately first?
9. AI assistance
OpenAI Codex assisted with code, test tooling and drafting this RFC.
I set the scope, reviewed the changes and ran the hardware tests; the
observations above are mine.
Thanks,
Fuwei
Fuwei Xie (5):
platform/x86: huawei-wmi: scope method responses to each call
platform/x86: huawei-wmi: bind the Huawei method device
platform/x86: huawei-wmi: use the sized WMI method interface
platform/x86: huawei-wmi: expose native firmware power profiles
platform/x86: huawei-wmi: bind hotkeys and key data on the WMI bus
drivers/platform/x86/Kconfig | 1 +
drivers/platform/x86/huawei-wmi.c | 778 +++++++++++++++++++++++---------------
2 files changed, 468 insertions(+), 311 deletions(-)
base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC PATCH v3 0/5] platform/x86: huawei-wmi: expose native firmware power profiles
2026-11-24 17:25 [RFC PATCH v3 0/5] platform/x86: huawei-wmi: expose native firmware power profiles Fuwei Xie
@ 2026-11-25 1:50 ` Zheng Shuyang
0 siblings, 0 replies; 2+ messages in thread
From: Zheng Shuyang @ 2026-11-25 1:50 UTC (permalink / raw)
To: Fuwei Xie
Cc: Ilpo Järvinen, Hans de Goede, Eren Özen,
platform-driver-x86, linux-kernel
Hi Fuwei,
I retested RFC v3 (all 5 patches) on the same HONOR MagicBook Pro 14
(2025, Mainland China SKU C233, DMI: HONOR / FMB-P, Core Ultra 5 225H,
BIOS 1.16, Arch Linux 7.3.5-arch1-1, power-profiles-daemon 0.30). All
five patches applied cleanly to v7.3's drivers/platform/x86/huawei-wmi.c
and built with W=1 without warnings.
Results:
- WMI bus binding: huawei-wmi-method bound ABBC0F5B-...-5 and
huawei-wmi-events bound ABBC0F5C-...-6 while keeping
/sys/devices/platform/huawei-wmi intact.
- Capability probe found \GTUB/\STUB and registered platform_profile
("balanced performance") without changing the active mode (stayed
performance / GTUB=1).
- Sysfs writes, powerprofilesctl (performance, balanced, power-saver),
and Fn+P updated platform_profile, ppd 0.30, GTUB, and INTC1042:00
odvp1/odvp2 cleanly, with no "Unknown key pressed" logs for
0x02a0/0x02a1/0x02a6.
- Pure AC unplug from performance (without pressing Fn+P afterward)
updated the cached platform_profile, ppd, GTUB, and ODVP to balanced,
so FMB-P emits 0x2a0 on unplug and the cache does not go stale here.
- Writing "performance" on battery returned 0 in 0.4 ms (cached
performance, GTUB=1), and by 51.0 ms 0x2a6 triggered the sync back
to balanced (GTUB=0), with ppd following within 0.5 s and no warnings.
- Existing features (battery thresholds 70/90, fn_lock_state, micmute
LED, debugfs call) and module unload/reload were clean.
Note: Gemini helped with the test scripts and
drafting this report; I performed the physical steps on the machine and
verified the results.
Tested-by: Zheng Shuyang <yhshzh0@gmail.com> # HONOR MagicBook Pro 14 (FMB-P), BIOS 1.16
Thanks,
Zheng Shuyang
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 1:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 17:25 [RFC PATCH v3 0/5] platform/x86: huawei-wmi: expose native firmware power profiles Fuwei Xie
2026-11-25 1:50 ` Zheng Shuyang
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®