Skip to content

Commit f50822f

Browse files
committed
Merge tag 'platform-drivers-x86-v7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver updates from Ilpo Järvinen: "Highlights: - amd/pmf: - Avoid overwriting BIOS input values when events occur rapidly - Fix PMF driver issues related to S4 (in part on crypto/ccp side) - Add NPU metrics API (for accel side consumers) - Allow disabling Smart PC function through a module parameter - asus-wmi & HID/asus: - Unification of backlight control (replaces quirks) - Support multiple interfaces for controlling keyboard/RGB brightness - Simplify init sequence - hp-wmi: - Add manual fan control for Victus S models - Add fan mode keep-alive - Fix platform profile values for Omen 16-wf1xxx - Add EC offset to get the thermal profile - intel/pmc: Show substate residencies also for non-primary PMCs - intel/ISST: - Store and restore data for all domains - Write interface improvements - lenovo-wmi: - Support multiple Capability Data - Add HWMON reporting and tuning support - mellanox/mlx-platform: Add HI173 & HI174 support - surface/aggregator_registry: Add Surface Pro 11 (QCOM) - thinkpad_acpi: Add support for HW damage detection capability - uniwill: Implement cTGP setting - wmi: - Introduce marshalling support - Convert a few drivers to use the new buffer-based WMI API - tools/power/x86/intel-speed-select: Allow read operations for non-root - Miscellaneous cleanups / refactoring / improvements" * tag 'platform-drivers-x86-v7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (68 commits) platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile platform: mellanox: mlx-platform: Add support DGX flavor of next-generation 800GB/s ethernet switch. platform: mellanox: mlx-platform: Add support for new Nvidia DGX system based on class VMOD0010 HID: asus: add support for the asus-wmi brightness handler platform/x86: asus-wmi: add keyboard brightness event handler platform/x86: asus-wmi: remove unused keyboard backlight quirk HID: asus: listen to the asus-wmi brightness device instead of creating one platform/x86: asus-wmi: Add support for multiple kbd led handlers HID: asus: early return for ROG devices HID: asus: move vendor initialization to probe HID: asus: fortify keyboard handshake HID: asus: use same report_id in response HID: asus: initialize additional endpoints only for certain devices HID: asus: simplify RGB init sequence platform/wmi: string-kunit: Add missing oversized string test case platform/x86/amd/pmf: Added a module parameter to disable the Smart PC function platform/x86/uniwill: Implement cTGP setting platform/x86: uniwill-laptop: Introduce device descriptor system platform/x86/amd: Use scope-based cleanup for wbrf_record() ...
2 parents 1b49e36 + 5a5203a commit f50822f

61 files changed

Lines changed: 5390 additions & 953 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/admin-guide/laptops/thinkpad-acpi.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ detailed description):
5454
- Setting keyboard language
5555
- WWAN Antenna type
5656
- Auxmac
57+
- Hardware damage detection capability
5758

5859
A compatibility table by model and feature is maintained on the web
5960
site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@@ -1576,6 +1577,42 @@ percentage level, above which charging will stop.
15761577
The exact semantics of the attributes may be found in
15771578
Documentation/ABI/testing/sysfs-class-power.
15781579

1580+
Hardware damage detection capability
1581+
------------------------------------
1582+
1583+
sysfs attributes: hwdd_status, hwdd_detail
1584+
1585+
Thinkpads are adding the ability to detect and report hardware damage.
1586+
Add new sysfs interface to identify the damaged device status.
1587+
Initial support is available for the USB-C replaceable connector.
1588+
1589+
The command to check device damaged status is::
1590+
1591+
cat /sys/devices/platform/thinkpad_acpi/hwdd_status
1592+
1593+
This value displays status of device damaged.
1594+
1595+
- 0 = Not Damaged
1596+
- 1 = Damaged
1597+
1598+
The command to check location of damaged device is::
1599+
1600+
cat /sys/devices/platform/thinkpad_acpi/hwdd_detail
1601+
1602+
This value displays location of damaged device having 1 line per damaged "item".
1603+
For example:
1604+
1605+
if no damage is detected:
1606+
1607+
- No damage detected
1608+
1609+
if damage detected:
1610+
1611+
- TYPE-C: Base, Right side, Center port
1612+
1613+
The property is read-only. If feature is not supported then sysfs
1614+
attribute is not created.
1615+
15791616
Multiple Commands, Module Parameters
15801617
------------------------------------
15811618

Documentation/driver-api/wmi.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ which will be bound to compatible WMI devices by the driver core.
1616
.. kernel-doc:: include/linux/wmi.h
1717
:internal:
1818

19+
.. kernel-doc:: drivers/platform/wmi/string.c
20+
:export:
21+
1922
.. kernel-doc:: drivers/platform/wmi/core.c
2023
:export:

Documentation/wmi/acpi-interface.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,71 @@ holding the notification ID of the event. This method should be evaluated every
104104
time an ACPI notification is received, since some ACPI implementations use a
105105
queue to store WMI event data items. This queue will overflow after a couple
106106
of WMI events are received without retrieving the associated WMI event data.
107+
108+
Conversion rules for ACPI data types
109+
------------------------------------
110+
111+
Consumers of the ACPI-WMI interface use binary buffers to exchange data with the WMI driver core,
112+
with the internal structure of the buffer being only know to the consumers. The WMI driver core is
113+
thus responsible for converting the data inside the buffer into an appropriate ACPI data type for
114+
consumption by the ACPI firmware. Additionally, any data returned by the various ACPI methods needs
115+
to be converted back into a binary buffer.
116+
117+
The layout of said buffers is defined by the MOF description of the WMI method or data block in
118+
question [1]_:
119+
120+
=============== ======================================================================= =========
121+
Data Type Layout Alignment
122+
=============== ======================================================================= =========
123+
``string`` Starts with an unsigned 16-bit little endian integer specifying 2 bytes
124+
the length of the string data in bytes, followed by the string data
125+
encoded as UTF-16LE with **optional** NULL termination and padding.
126+
Keep in mind that some firmware implementations might depend on the
127+
terminating NULL character to be present. Also the padding should
128+
always be performed with NULL characters.
129+
``boolean`` Single byte where 0 means ``false`` and nonzero means ``true``. 1 byte
130+
``sint8`` Signed 8-bit integer. 1 byte
131+
``uint8`` Unsigned 8-bit integer. 1 byte
132+
``sint16`` Signed 16-bit little endian integer. 2 bytes
133+
``uint16`` Unsigned 16-bit little endian integer. 2 bytes
134+
``sint32`` Signed 32-bit little endian integer. 4 bytes
135+
``uint32`` Unsigned 32-bit little endian integer. 4 bytes
136+
``sint64`` Signed 64-bit little endian integer. 8 bytes
137+
``uint64`` Unsigned 64-bit little endian integer. 8 bytes
138+
``datetime`` A fixed-length 25-character UTF-16LE string with the format 2 bytes
139+
*yyyymmddhhmmss.mmmmmmsutc* where *yyyy* is the 4-digit year, *mm* is
140+
the 2-digit month, *dd* is the 2-digit day, *hh* is the 2-digit hour
141+
based on a 24-hour clock, *mm* is the 2-digit minute, *ss* is the
142+
2-digit second, *mmmmmm* is the 6-digit microsecond, *s* is a plus or
143+
minus character depending on whether *utc* is a positive or negative
144+
offset from UTC (or a colon if the date is an interval). Unpopulated
145+
fields should be filled with asterisks.
146+
=============== ======================================================================= =========
147+
148+
Arrays should be aligned based on the alignment of their base type, while objects should be
149+
aligned based on the largest alignment of an element inside them.
150+
151+
All buffers returned by the WMI driver core are 8-byte aligned. When converting ACPI data types
152+
into such buffers the following conversion rules apply:
153+
154+
=============== ============================================================
155+
ACPI Data Type Converted into
156+
=============== ============================================================
157+
Buffer Copied as-is.
158+
Integer Converted into a ``uint32``.
159+
String Converted into a ``string`` with a terminating NULL character
160+
to match the behavior the of the Windows driver.
161+
Package Each element inside the package is converted with alignment
162+
of the resulting data types being respected. Nested packages
163+
are not allowed.
164+
=============== ============================================================
165+
166+
The Windows driver does attempt to handle nested packages, but this results in internal data
167+
structures (``_ACPI_METHOD_ARGUMENT_V1``) erroneously being copied into the resulting buffer.
168+
ACPI firmware implementations should thus not return nested packages from ACPI methods
169+
associated with the ACPI-WMI interface.
170+
171+
References
172+
==========
173+
174+
.. [1] https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/driver-defined-wmi-data-items

Documentation/wmi/devices/lenovo-wmi-other.rst

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,32 @@ under the following path:
3131

3232
/sys/class/firmware-attributes/lenovo-wmi-other/attributes/<attribute>/
3333

34+
Additionally, this driver also exports attributes to HWMON.
35+
36+
LENOVO_CAPABILITY_DATA_00
37+
-------------------------
38+
39+
WMI GUID ``362A3AFE-3D96-4665-8530-96DAD5BB300E``
40+
41+
The LENOVO_CAPABILITY_DATA_00 interface provides various information that
42+
does not rely on the gamezone thermal mode.
43+
44+
The following HWMON attributes are implemented:
45+
- fanX_div: internal RPM divisor
46+
- fanX_input: current RPM
47+
- fanX_target: target RPM (tunable, 0=auto)
48+
49+
Due to the internal RPM divisor, the current/target RPMs are rounded down to
50+
its nearest multiple. The divisor itself is not necessary to be a power of two.
51+
3452
LENOVO_CAPABILITY_DATA_01
3553
-------------------------
3654

3755
WMI GUID ``7A8F5407-CB67-4D6E-B547-39B3BE018154``
3856

39-
The LENOVO_CAPABILITY_DATA_01 interface provides information on various
40-
power limits of integrated CPU and GPU components.
57+
The LENOVO_CAPABILITY_DATA_01 interface provides various information that
58+
relies on the gamezone thermal mode, including power limits of integrated
59+
CPU and GPU components.
4160

4261
Each attribute has the following properties:
4362
- current_value
@@ -48,11 +67,22 @@ Each attribute has the following properties:
4867
- scalar_increment
4968
- type
5069

51-
The following attributes are implemented:
70+
The following firmware-attributes are implemented:
5271
- ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit
5372
- ppt_pl2_sppt: Platform Profile Tracking Slow Package Power Tracking
5473
- ppt_pl3_fppt: Platform Profile Tracking Fast Package Power Tracking
5574

75+
LENOVO_FAN_TEST_DATA
76+
-------------------------
77+
78+
WMI GUID ``B642801B-3D21-45DE-90AE-6E86F164FB21``
79+
80+
The LENOVO_FAN_TEST_DATA interface provides reference data for self-test of
81+
cooling fans.
82+
83+
The following HWMON attributes are implemented:
84+
- fanX_max: maximum RPM
85+
- fanX_min: minimum RPM
5686

5787
WMI interface description
5888
=========================
@@ -106,3 +136,13 @@ data using the `bmfdec <https://github.com/pali/bmfdec>`_ utility:
106136
[WmiDataId(3), read, Description("Data Size.")] uint32 DataSize;
107137
[WmiDataId(4), read, Description("Default Value"), WmiSizeIs("DataSize")] uint8 DefaultValue[];
108138
};
139+
140+
[WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x409"), Description("Definition of Fan Test Data"), guid("{B642801B-3D21-45DE-90AE-6E86F164FB21}")]
141+
class LENOVO_FAN_TEST_DATA {
142+
[key, read] string InstanceName;
143+
[read] boolean Active;
144+
[WmiDataId(1), read, Description("Mode.")] uint32 NumOfFans;
145+
[WmiDataId(2), read, Description("Fan ID."), WmiSizeIs("NumOfFans")] uint32 FanId[];
146+
[WmiDataId(3), read, Description("Maximum Fan Speed."), WmiSizeIs("NumOfFans")] uint32 FanMaxSpeed[];
147+
[WmiDataId(4), read, Description("Minumum Fan Speed."), WmiSizeIs("NumOfFans")] uint32 FanMinSpeed[];
148+
};

Documentation/wmi/driver-development-guide.rst

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ to matching WMI devices using a struct wmi_device_id table:
7070
.probe = foo_probe,
7171
.remove = foo_remove, /* optional, devres is preferred */
7272
.shutdown = foo_shutdown, /* optional, called during shutdown */
73-
.notify = foo_notify, /* optional, for event handling */
73+
.notify_new = foo_notify, /* optional, for event handling */
7474
.no_notify_data = true, /* optional, enables events containing no additional data */
7575
.no_singleton = true, /* required for new WMI drivers */
7676
};
@@ -90,9 +90,9 @@ the WMI device and put it in a well-known state for the WMI driver to pick up la
9090
or kexec. Most WMI drivers need no special shutdown handling and can thus omit this callback.
9191

9292
Please note that new WMI drivers are required to be able to be instantiated multiple times,
93-
and are forbidden from using any deprecated GUID-based WMI functions. This means that the
94-
WMI driver should be prepared for the scenario that multiple matching WMI devices are present
95-
on a given machine.
93+
and are forbidden from using any deprecated GUID-based or ACPI-based WMI functions. This means
94+
that the WMI driver should be prepared for the scenario that multiple matching WMI devices are
95+
present on a given machine.
9696

9797
Because of this, WMI drivers should use the state container design pattern as described in
9898
Documentation/driver-api/driver-model/design-patterns.rst.
@@ -104,38 +104,37 @@ Documentation/driver-api/driver-model/design-patterns.rst.
104104
WMI method drivers
105105
------------------
106106

107-
WMI drivers can call WMI device methods using wmidev_evaluate_method(), the
108-
structure of the ACPI buffer passed to this function is device-specific and usually
109-
needs some tinkering to get right. Looking at the ACPI tables containing the WMI
110-
device usually helps here. The method id and instance number passed to this function
111-
are also device-specific, looking at the decoded Binary MOF is usually enough to
112-
find the right values.
107+
WMI drivers can call WMI device methods using wmidev_invoke_method(). For each WMI method
108+
invocation the WMI driver needs to provide the instance number and the method ID, as well as
109+
a buffer with the method arguments and optionally a buffer for the results.
113110

114-
The maximum instance number can be retrieved during runtime using wmidev_instance_count().
111+
The layout of said buffers is device-specific and described by the Binary MOF data associated
112+
with a given WMI device. Said Binary MOF data also describes the method ID of a given WMI method
113+
with the ``WmiMethodId`` qualifier. WMI devices exposing WMI methods usually expose only a single
114+
instance (instance number 0), but in theory can expose multiple instances as well. In such a case
115+
the number of instances can be retrieved using wmidev_instance_count().
115116

116-
Take a look at drivers/platform/x86/inspur_platform_profile.c for an example WMI method driver.
117+
Take a look at drivers/platform/x86/intel/wmi/thunderbolt.c for an example WMI method driver.
117118

118119
WMI data block drivers
119120
----------------------
120121

121-
WMI drivers can query WMI device data blocks using wmidev_block_query(), the
122-
structure of the returned ACPI object is again device-specific. Some WMI devices
123-
also allow for setting data blocks using wmidev_block_set().
122+
WMI drivers can query WMI data blocks using wmidev_query_block(), the layout of the returned
123+
buffer is again device-specific and described by the Binary MOF data. Some WMI data blocks are
124+
also writeable and can be set using wmidev_set_block(). The number of data block instances can
125+
again be retrieved using wmidev_instance_count().
124126

125-
The maximum instance number can also be retrieved using wmidev_instance_count().
126-
127-
Take a look at drivers/platform/x86/intel/wmi/sbl-fw-update.c for an example
128-
WMI data block driver.
127+
Take a look at drivers/platform/x86/intel/wmi/sbl-fw-update.c for an example WMI data block driver.
129128

130129
WMI event drivers
131130
-----------------
132131

133-
WMI drivers can receive WMI events via the notify() callback inside the struct wmi_driver.
132+
WMI drivers can receive WMI events via the notify_new() callback inside the struct wmi_driver.
134133
The WMI subsystem will then take care of setting up the WMI event accordingly. Please note that
135-
the structure of the ACPI object passed to this callback is device-specific, and freeing the
136-
ACPI object is being done by the WMI subsystem, not the driver.
134+
the layout of the buffer passed to this callback is device-specific, and freeing of the buffer
135+
is done by the WMI subsystem itself, not the driver.
137136

138-
The WMI driver core will take care that the notify() callback will only be called after
137+
The WMI driver core will take care that the notify_new() callback will only be called after
139138
the probe() callback has been called, and that no events are being received by the driver
140139
right before and after calling its remove() or shutdown() callback.
141140

@@ -147,6 +146,36 @@ the ``no_notify_data`` flag inside struct wmi_driver should be set to ``true``.
147146

148147
Take a look at drivers/platform/x86/xiaomi-wmi.c for an example WMI event driver.
149148

149+
Exchanging data with the WMI driver core
150+
----------------------------------------
151+
152+
WMI drivers can exchange data with the WMI driver core using struct wmi_buffer. The internal
153+
structure of those buffers is device-specific and only known by the WMI driver. Because of this
154+
the WMI driver itself is responsible for parsing and validating the data received from its
155+
WMI device.
156+
157+
The structure of said buffers is described by the MOF data associated with the WMI device in
158+
question. When such a buffer contains multiple data items it usually makes sense to define a
159+
C structure and use it during parsing. Since the WMI driver core guarantees that all buffers
160+
received from a WMI device are aligned on an 8-byte boundary, WMI drivers can simply perform
161+
a cast between the WMI buffer data and this C structure.
162+
163+
This however should only be done after the size of the buffer was verified to be large enough
164+
to hold the whole C structure. WMI drivers should reject undersized buffers as they are usually
165+
sent by the WMI device to signal an internal error. Oversized buffers however should be accepted
166+
to emulate the behavior of the Windows WMI implementation.
167+
168+
When defining a C structure for parsing WMI buffers the alignment of the data items should be
169+
respected. This is especially important for 64-bit integers as those have different alignments
170+
on 64-bit (8-byte alignment) and 32-bit (4-byte alignment) architectures. It is thus a good idea
171+
to manually specify the alignment of such data items or mark the whole structure as packed when
172+
appropriate. Integer data items in general are little-endian integers and should be marked as
173+
such using ``__le64`` and friends. When parsing WMI string data items the struct wmi_string should
174+
be used as WMI strings have a different layout than C strings.
175+
176+
See Documentation/wmi/acpi-interface.rst for more information regarding the binary format
177+
of WMI data items.
178+
150179
Handling multiple WMI devices at once
151180
-------------------------------------
152181

@@ -171,6 +200,7 @@ Things to avoid
171200
When developing WMI drivers, there are a couple of things which should be avoided:
172201

173202
- usage of the deprecated GUID-based WMI interface which uses GUIDs instead of WMI device structs
203+
- usage of the deprecated ACPI-based WMI interface which uses ACPI objects instead of plain buffers
174204
- bypassing of the WMI subsystem when talking to WMI devices
175205
- WMI drivers which cannot be instantiated multiple times.
176206

drivers/crypto/ccp/psp-dev.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,17 @@ struct psp_device *psp_get_master_device(void)
351351
return sp ? sp->psp_data : NULL;
352352
}
353353

354+
int psp_restore(struct sp_device *sp)
355+
{
356+
struct psp_device *psp = sp->psp_data;
357+
int ret = 0;
358+
359+
if (psp->tee_data)
360+
ret = tee_restore(psp);
361+
362+
return ret;
363+
}
364+
354365
void psp_pci_init(void)
355366
{
356367
psp_master = psp_get_master_device();

drivers/crypto/ccp/sp-dev.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@ int sp_resume(struct sp_device *sp)
230230
return 0;
231231
}
232232

233+
int sp_restore(struct sp_device *sp)
234+
{
235+
if (sp->psp_data) {
236+
int ret = psp_restore(sp);
237+
238+
if (ret)
239+
return ret;
240+
}
241+
242+
return sp_resume(sp);
243+
}
244+
233245
struct sp_device *sp_get_psp_master_device(void)
234246
{
235247
struct sp_device *i, *ret = NULL;

drivers/crypto/ccp/sp-dev.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void sp_destroy(struct sp_device *sp);
141141

142142
int sp_suspend(struct sp_device *sp);
143143
int sp_resume(struct sp_device *sp);
144+
int sp_restore(struct sp_device *sp);
144145
int sp_request_ccp_irq(struct sp_device *sp, irq_handler_t handler,
145146
const char *name, void *data);
146147
void sp_free_ccp_irq(struct sp_device *sp, void *data);
@@ -174,13 +175,15 @@ int psp_dev_init(struct sp_device *sp);
174175
void psp_pci_init(void);
175176
void psp_dev_destroy(struct sp_device *sp);
176177
void psp_pci_exit(void);
178+
int psp_restore(struct sp_device *sp);
177179

178180
#else /* !CONFIG_CRYPTO_DEV_SP_PSP */
179181

180182
static inline int psp_dev_init(struct sp_device *sp) { return 0; }
181183
static inline void psp_pci_init(void) { }
182184
static inline void psp_dev_destroy(struct sp_device *sp) { }
183185
static inline void psp_pci_exit(void) { }
186+
static inline int psp_restore(struct sp_device *sp) { return 0; }
184187

185188
#endif /* CONFIG_CRYPTO_DEV_SP_PSP */
186189

0 commit comments

Comments
 (0)