From: Armin Wolf <W_Armin@gmx.de>
To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, linux@weissschuh.net,
Dell.Client.Kernel@dell.com, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: [PATCH v2 0/9] platform/wmi: Introduce marshalling support
Date: Sat, 20 Dec 2025 21:46:13 +0100 [thread overview]
Message-ID: <20251220204622.3541-1-W_Armin@gmx.de> (raw)
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/
Changes since v1:
- fix spelling issues inside the documentation
- add Reviewed-by tag for the documentation
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
next reply other threads:[~2025-12-20 20:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-20 20:46 Armin Wolf [this message]
2025-12-20 20:46 ` [PATCH v2 1/9] platform/wmi: Introduce marshalling support Armin Wolf
2026-01-06 15:35 ` Ilpo Järvinen
2026-01-06 15:56 ` Ilpo Järvinen
2025-12-20 20:46 ` [PATCH v2 2/9] platform/wmi: Add kunit test for the marshalling code Armin Wolf
2026-01-06 15:39 ` Ilpo Järvinen
2025-12-20 20:46 ` [PATCH v2 3/9] platform/wmi: Add helper functions for WMI string conversions Armin Wolf
2025-12-20 20:46 ` [PATCH v2 4/9] platform/wmi: Add kunit test for the string conversion code Armin Wolf
2025-12-20 20:46 ` [PATCH v2 5/9] platform/x86: intel-wmi-sbl-fw-update: Use new buffer-based WMI API Armin Wolf
2025-12-20 20:46 ` [PATCH v2 6/9] platform/x86/intel/wmi: thunderbolt: " Armin Wolf
2025-12-20 20:46 ` [PATCH v2 7/9] platform/x86: xiaomi-wmi: " Armin Wolf
2025-12-20 20:46 ` [PATCH v2 8/9] platform/x86: wmi-bmof: " Armin Wolf
2025-12-20 20:46 ` [PATCH v2 9/9] platform/wmi: Update driver development guide Armin Wolf
2026-01-06 15:15 ` [PATCH v2 0/9] platform/wmi: Introduce marshalling support Armin Wolf
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=20251220204622.3541-1-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=Dell.Client.Kernel@dell.com \
--cc=corbet@lwn.net \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=platform-driver-x86@vger.kernel.org \
/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