[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251122203803.6154-1-W_Armin@gmx.de>
Date: Sat, 22 Nov 2025 21:37:54 +0100
From: Armin Wolf <W_Armin@....de>
To: hansg@...nel.org,
ilpo.jarvinen@...ux.intel.com
Cc: platform-driver-x86@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux@...ssschuh.net,
Dell.Client.Kernel@...l.com,
corbet@....net,
linux-doc@...r.kernel.org
Subject: [PATCH 0/9] platform/wmi: Introduce marshalling support
The Windows WMI-ACPI driver likely uses wmilib [1] to interact with
the WMI service in userspace. Said library uses plain byte buffers
for exchanging data, so the WMI-ACPI driver has to convert between
those byte buffers and ACPI objects returned by the ACPI firmware.
The format of the byte buffer is publicly documented [2], and after
some reverse eingineering of the WMI-ACPI driver using a set of custom
ACPI tables, the following conversion rules have been discovered:
- ACPI integers are always converted into a uint32
- ACPI strings are converted into special WMI strings
- ACPI buffers are copied as-is
- ACPI packages are unpacked
Extending the ACPI-WMI to perform this kind of marshalling for WMI
data blocks, methods and events would give us a number of benefits:
- WMI drivers are not restricted to a fixed set of supported ACPI data
types anymore, see dell-wmi-aio (integer vs buffer) and
hp-wmi-sensors (string vs buffer)
- correct marshalling of WMI strings when data blocks are marked
as requiring ACPI strings instead of ACPI buffers
- development of WMI drivers without having to understand ACPI
This eventually should result in better compatibility with some
ACPI firmware implementations and in simpler WMI drivers.
The first patch extends the WMI driver core to perform said
marshalling as well as a new API not based on ACPI objects. The next
patch adds a KUnit test for testing the marshalling code. The
following two patches then add a set of helper functions for dealing
with WMI string data together with another KUnit test.
The remaining patches then convert some simple WMI drivers to use the
new WMI API and update the driver development guide so that new WMI
drivers stop using the ACPI-based API.
The series has been tested on multiple machines, with the xiaomi-wmi
and intel-wmi-sbl-fw-update being tested using a set of custom ACPI
tables loaded over configFS.
[1] https://learn.microsoft.com/de-de/windows-hardware/drivers/ddi/wmilib/
Armin Wolf (9):
platform/wmi: Introduce marshalling support
platform/wmi: Add kunit test for the marshalling code
platform/wmi: Add helper functions for WMI string conversions
platform/wmi: Add kunit test for the string conversion code
platform/x86: intel-wmi-sbl-fw-update: Use new buffer-based WMI API
platform/x86/intel/wmi: thunderbolt: Use new buffer-based WMI API
platform/x86: xiaomi-wmi: Use new buffer-based WMI API
platform/x86: wmi-bmof: Use new buffer-based WMI API
platform/wmi: Update driver development guide
Documentation/driver-api/wmi.rst | 3 +
Documentation/wmi/acpi-interface.rst | 68 +++
.../wmi/driver-development-guide.rst | 76 ++-
drivers/platform/wmi/Kconfig | 3 +
drivers/platform/wmi/Makefile | 5 +-
drivers/platform/wmi/core.c | 160 ++++++-
drivers/platform/wmi/internal.h | 14 +
drivers/platform/wmi/marshalling.c | 233 +++++++++
drivers/platform/wmi/string.c | 92 ++++
drivers/platform/wmi/tests/Kconfig | 27 ++
drivers/platform/wmi/tests/Makefile | 11 +
.../platform/wmi/tests/marshalling_kunit.c | 448 ++++++++++++++++++
drivers/platform/wmi/tests/string_kunit.c | 277 +++++++++++
.../platform/x86/intel/wmi/sbl-fw-update.c | 43 +-
drivers/platform/x86/intel/wmi/thunderbolt.c | 26 +-
drivers/platform/x86/wmi-bmof.c | 34 +-
drivers/platform/x86/xiaomi-wmi.c | 5 +-
include/linux/wmi.h | 44 +-
18 files changed, 1477 insertions(+), 92 deletions(-)
create mode 100644 drivers/platform/wmi/internal.h
create mode 100644 drivers/platform/wmi/marshalling.c
create mode 100644 drivers/platform/wmi/string.c
create mode 100644 drivers/platform/wmi/tests/Kconfig
create mode 100644 drivers/platform/wmi/tests/Makefile
create mode 100644 drivers/platform/wmi/tests/marshalling_kunit.c
create mode 100644 drivers/platform/wmi/tests/string_kunit.c
--
2.39.5
Powered by blists - more mailing lists