Skip to contentSkip to conversation

lenovo-wmi: Add fixes and enhancement

PATCH In review Derek J. Clark 2 participants 9 messages May 20 – May 28

Subsystems (4)
lore
Share & tools
lore

Derek J. Clark

author maintainer
#0 lore raw

v14 cover lenovo-wmi: Add fixes and enhancement

This series adds many much needed features to the lenovo-wmi* drivers. This version is based off platform-driver-x86/review-ilpo-fixes branch, so patches 1-9 from v12 have been dropped.

Patch 1 adds the remaining CPU attributes that weren't previously exposed.

Patch 2 adds GPU attributes.

Patch 3 renames a name constant in preparation for patch 6.

Patch 4 adds battery charge-types limiting when supported only by WMI, or when a module parameter to skip compatibility checks is set. The MODULE_PARM_DESC macro creates one check and two warnings in checkpatch. I reviewed other examples from the kernel and I am following the same convention, so I left it as is.

Patch 5 adds a module parameter, force_load_psy_ext, to bypass ACPI and BIOS compatibility checks for the power supply extension.

Patch 6 adds a debugfs directory.

Patch 7 adds a debugfs file for dumping capdata.

---
v14:
- Change charge limit -> charge types in dev_dbg.
- Stop casting u32 to int in lwmi_psy_prop_get_supported.
v13: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Rebase off review-ilpo-fixes and drop merged patches 1-9.
- Switch back to charge_types based on feedback from Hans.
- Ensure force_load_psy_ext also makes is_writable and is_supported
checks for lwmi_psy_ext_prop* functions always return true.
- Add helper function for is_writable and is_supported to reduce
duplicated code.
- Move bugged attribute description to the correct paragraph in patch

    4.

v12: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Break out force_load_psy_ext into its own patch.
- Drop fixes tags for formatting only prerequisite patches Cc'd to
stable.
- Fix formatting in various places.
- Use correct type when passing args in new functions. I will revisit
& fix older functions in a new series.
v11: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Reorganize patches in a way that cleans up the churn with
assignment of attribute IDs. This also allowed dropping the
patch that moved the LWMI_FAN_DIV patch as it is now effectively
moved when declaring the updated LWMI_ATTR_ID_FAN_DIV macro. As a
result, some formatting only patches were added to the Cc list for
stable since as they are now prerequisites to some of the fixes.
- Refactor charge control patch to use charge_behavior and charge_control_end_threshold instead of charge_types to be in
accordance with the power supply class documentation.
- Minor additional formatting fixes.
v10: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Fix misnamed attribute in wmi-other.
v9: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Invert ida_alloc fail logic.
- Fix dropped mode arg in current_value_show.
- Fix misnamed attribute in documentation.
v8: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Clean up rebase mixup with re-assinment of wmi_method_args_32 in

    patches 6 and 14 from {} to { 0x00, 0x00 } and back.

- Combine ret_obj declaration and assignment in patch 1.
v7: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Add 3 additional bug fix patches from Rong Zhang reported by
shashiko.dev
- Reorder patches so the fixes are upfront in patches 1-7.
- Fix various typos and rebase mixups from v6.
v6: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Incorporate Rong Zhang's debugfs and decoupling patches into the
series.
- Add a patch to clean up too many cross-references to wmi-gamezone.h
- Make lwmi_attr_id a static inline in wmi-capdata.h
- Added a patch to fix a bug where ares.arg1 is uninitialized when it
is sent to the firmware.
- Add supported checks before adding battery extenstion, and ensure
both the new checks and the is_writable checks are not casting u32
to i32.
- Misc formating changes.
v5: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Remove cv/cd_mode_id references that occured before patch 4.
- Move lwmi_attr_id to capdata.c with a namespace export.
- Fix mixing include.
- Make lwmi_attr_is_supported return bool.
- Use switch instead of if for setting/getting charge type state.
- Various formatting fixes.
v4: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Use loop instead of back gotos for identifying the working attribute

    ID.

- Use function instead of macro to assign attribute_id, preserving
types.
- Removed unused defines and enum values.
- Rename charging defines to clarify thier purpose.
- Fixed various formatting issues from v3.
- Added module param to skip ACPI check when loading the driver for
the power supply extension.
- Don't abort adding power supply extension if the ACPI handle from
ideapad is not present.
- Don't worry about symmetric cleanup when cleaning up attributes in
an error state.
- Reword Patch 8 commit message to be more concise.
- Fix wording in Patch 7 to match the changes.
v3: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Re-add HWMON name const and just rename LWMI_OM_FW_ATTR_BASE_PATH
- Fix linker warnings by moving acpi/battery include to the end of the
list.
- Remove CPU/GPU OC features. These attributes are BOOL type and will
need a new constructor that I'll add later.
v2: https://lore.kernel.org/platform-driver-x86/[email protected]/
- Fix gpu_mode misisng from attributes list.
- Fix prototypes for power suppy patch.
- Reorganize CPU and GPU attributes alphabetically.
- Break out the patch consolidating the driver name cost.
- Move some of the refactoring of attribute_id back to into patch 1
where it belongs.
- Fix some additional typos in function prototypes.
v1: https://lore.kernel.org/platform-driver-x86/[email protected]/

Derek J. Clark (5):
platform/x86: lenovo-wmi-other: Add missing CPU tunable attributes platform/x86: lenovo-wmi-other: Add GPU tunable attributes platform/x86: lenovo-wmi-other: Rename LWMI_OM_FW_ATTR_BASE_PATH platform/x86: lenovo-wmi-other: Add WMI battery charge limiting platform/x86: lenovo-wmi-other: Add force_load_psy_ext module
parameter

Rong Zhang (2):
platform/x86: lenovo-wmi-helpers: Add helper for creating per-device
debugfs dir
platform/x86: lenovo-wmi-capdata: Add debugfs file for dumping capdata

 .../wmi/devices/lenovo-wmi-other.rst          |  19 +
 drivers/platform/x86/lenovo/Kconfig           |   2 +
 drivers/platform/x86/lenovo/wmi-capdata.c     | 120 ++++
 drivers/platform/x86/lenovo/wmi-capdata.h     |  14 +-
 drivers/platform/x86/lenovo/wmi-helpers.c     |  34 +
 drivers/platform/x86/lenovo/wmi-helpers.h     |   2 +
 drivers/platform/x86/lenovo/wmi-other.c       | 617 +++++++++++++++++-
 7 files changed, 797 insertions(+), 11 deletions(-)

base-commit: 2997606dd17729404cef9821ce66dd037b6019eb

Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH v14 1/7 platform/x86: lenovo-wmi-other: Add missing CPU tunable attributes

Use an enum for all device ID's and CPU attribute feature ID's, add missing CPU attributes.

---
v7:
- Fix typo in documentation.
v4:
- Align type ID defines.
- Align CPU feature enum values.
- remove cpu_oc_stat from Documentation.
v3:
- Remove cpu_oc_stat.

---
 .../wmi/devices/lenovo-wmi-other.rst          |  9 ++
 drivers/platform/x86/lenovo/wmi-capdata.h     |  5 +-
 drivers/platform/x86/lenovo/wmi-other.c       | 99 ++++++++++++++++++-
 3 files changed, 107 insertions(+), 6 deletions(-)
Documentation/wmi/devices/lenovo-wmi-other.rst +9 -0
index 01d4711567380..189dd4d31926d 100644
@@ -68,9 +68,18 @@ Each attribute has the following properties:
  - type
 
 The following firmware-attributes are implemented:
+ - cpu_temp: CPU Thermal Load Limit
+ - ppt_cpu_cl: CPU Cross Loading Power Limit
+ - ppt_pl1_apu_spl: Platform Profile Tracking APU Sustained Power Limit
  - ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit
+ - ppt_pl1_spl_cl: Platform Profile Tracking Cross Loading Sustained Power Limit
+ - ppt_pl1_tau: Exceed Duration for Platform Profile Tracking Sustained Power Limit
  - ppt_pl2_sppt: Platform Profile Tracking Slow Package Power Tracking
+ - ppt_pl2_sppt_cl: Platform Profile Tracking Cross Loading Slow Package Tracking
  - ppt_pl3_fppt: Platform Profile Tracking Fast Package Power Tracking
+ - ppt_pl3_fppt_cl: Platform Profile Tracking Cross Loading Fast Package Power Tracking
+ - ppt_pl4_ipl: Platform Profile Tracking Instantaneous Power Limit
+ - ppt_pl4_ipl_cl: Platform Profile Tracking Cross Loading Instantaneous Power Limit
 
 LENOVO_FAN_TEST_DATA
 -------------------------
drivers/platform/x86/lenovo/wmi-capdata.h +4 -1
index c3e760b8c3c3d..c74a0e5294e78 100644
@@ -18,7 +18,10 @@
 #define LWMI_ATTR_MODE_ID_MASK	GENMASK(15, 8)
 #define LWMI_ATTR_TYPE_ID_MASK	GENMASK(7, 0)
 
-#define LWMI_DEVICE_ID_FAN	0x04
+enum lwmi_device_id {
+	LWMI_DEVICE_ID_CPU = 0x01,
+	LWMI_DEVICE_ID_FAN = 0x04,
+};
 
 #define LWMI_TYPE_ID_NONE 0x00
 
drivers/platform/x86/lenovo/wmi-other.c +94 -5

143 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH v14 2/7 platform/x86: lenovo-wmi-other: Add GPU tunable attributes

In reply to Derek J. Clark

Use an enum for all GPU attribute feature ID's and add GPU attributes.

---
v9:
- Rename gpu_didvid -> dgpu_didvid in documentation to match actual attribute name.
v7:
- Fix typo in dgpu_boost_clk attribute string.
v4:
- Align CPU feature enum values.
- Remove gpu_oc_stat from Documentation.
v3:
- Remove gpu_oc_stat.

---
 .../wmi/devices/lenovo-wmi-other.rst          |  10 ++
 drivers/platform/x86/lenovo/wmi-capdata.h     |   1 +
 drivers/platform/x86/lenovo/wmi-other.c       | 105 ++++++++++++++++++
 3 files changed, 116 insertions(+)
Documentation/wmi/devices/lenovo-wmi-other.rst +10 -0
index 189dd4d31926d..011054d64eac5 100644
@@ -69,6 +69,16 @@ Each attribute has the following properties:
 
 The following firmware-attributes are implemented:
  - cpu_temp: CPU Thermal Load Limit
+ - dgpu_boost_clk: Dedicated GPU Boost Clock
+ - dgpu_didvid: Dedicated GPU Device Identifier and Vendor Identifier
+ - dgpu_enable: Dedicated GPU Enabled Status
+ - gpu_mode: GPU Mode by Power Limit
+ - gpu_nv_ac_offset: Nvidia GPU AC Total Processing Power Baseline Offset
+ - gpu_nv_bpl: Nvidia GPU Base Power Limit
+ - gpu_nv_cpu_boost: Nvidia GPU to CPU Dynamic Boost Limit
+ - gpu_nv_ctgp: Nvidia GPU Configurable Total Graphics Power
+ - gpu_nv_ppab: Nvidia GPU Power Performance Aware Boost Limit
+ - gpu_temp: GPU Thermal Load Limit
  - ppt_cpu_cl: CPU Cross Loading Power Limit
  - ppt_pl1_apu_spl: Platform Profile Tracking APU Sustained Power Limit
  - ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit
drivers/platform/x86/lenovo/wmi-capdata.h +1 -0
index c74a0e5294e78..a7cfdeaa58f77 100644
@@ -20,6 +20,7 @@
 
 enum lwmi_device_id {
 	LWMI_DEVICE_ID_CPU = 0x01,
+	LWMI_DEVICE_ID_GPU = 0x02,
 	LWMI_DEVICE_ID_FAN = 0x04,
 };
 
drivers/platform/x86/lenovo/wmi-other.c +105 -0

132 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH v14 3/7 platform/x86: lenovo-wmi-other: Rename LWMI_OM_FW_ATTR_BASE_PATH

In reply to Derek J. Clark

In the next patch a power supply extension is added which requires a name attribute. Instead of creating another const macro with the same information, rename LWMI_OM_FW_ATTR_BASE_PATH to LWMI_OM_SYSFS_NAME.

---
 drivers/platform/x86/lenovo/wmi-other.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/platform/x86/lenovo/wmi-other.c +2 -3
index 9a6183bbcc920..beb92c7cff257 100644
@@ -92,7 +92,7 @@ enum lwmi_feature_id_gpu {
 	lwmi_attr_id(LWMI_DEVICE_ID_FAN, LWMI_FEATURE_ID_FAN_RPM, \
 		     LWMI_GZ_THERMAL_MODE_NONE, LWMI_FAN_ID(x))
 
-#define LWMI_OM_FW_ATTR_BASE_PATH "lenovo-wmi-other"
+#define LWMI_OM_SYSFS_NAME "lenovo-wmi-other"
 #define LWMI_OM_HWMON_NAME "lenovo_wmi_other"
 
 static DEFINE_IDA(lwmi_om_ida);
@@ -1138,8 +1138,7 @@ static void lwmi_om_fw_attr_add(struct lwmi_om_priv *priv)
 
 	priv->fw_attr_dev = device_create(&firmware_attributes_class, NULL,
 					  MKDEV(0, 0), NULL, "%s-%u",
-					  LWMI_OM_FW_ATTR_BASE_PATH,
-					  priv->ida_id);
+					  LWMI_OM_SYSFS_NAME, priv->ida_id);
 	if (IS_ERR(priv->fw_attr_dev)) {
 		err = PTR_ERR(priv->fw_attr_dev);
 		goto err_free_ida;
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH v14 4/7 platform/x86: lenovo-wmi-other: Add WMI battery charge limiting

In reply to Derek J. Clark

Add charge_behaviour and charge_types attributes through a power supply extension for devices that support WMI based charge enable & disable.

Lenovo Legion devices that implement WMI function and capdata ID 0x03010001 in their BIOS are able to enable or disable charging at 80% through the lenovo-wmi-other interface. Add a charge_types attribute for BATX devices to expose this capability with Standard and Long_Life types enabled.

Additionally, devices that support WMI function and capdata ID 0x03020000 are able to force discharge of the battery. Expose this capability with a charge_behaviour attribute in the power supply extension, with the auto and force-discharge behaviors enabled. The GET method for this attribute is bugged. After analyzing the DSDT, and some testing, it appears the method grabs bit(3) instead of bit(4) from the EC register that stores the current status, and will only report if charging has been inhibited or not. To work around this, store and report the last setting written to the attribute.

As some devices only expose one attribute or the other, a bitmask is added with a lookup table and some helper macros to select the correct configuration for the hardware at runtime.

The ideapad_laptop driver provides the charge_types attribute to provide similar functionality. When the WMI method is set this can corrupt the ACPI method return and cause hardware and driver errors. To avoid conflicts between the drivers, we get the acpi_handle and do the same check that ideapad_laptop does when it enables the feature. If the feature is supported in ideapad_laptop, abort adding the extension from lenovo-wmi-other. The ACPI method is more reliable when both are present from my testing, so we can prefer that implementation and do not need to worry about de-conflicting from inside that driver.

---
v14:
- Change charge limit -> charge types in dev_dbg.
- Stop casting u32 to int in lwmi_psy_prop_get_supported.
v13:
- Switch back to charge_types instead of charge_control_end_threshold.
- Add helper function to reduce duplicated code when checking support level for a given attribute.
- Remove setting priv->bh_registered to false during psy init.
v12:
- Move force_load_psy_ext into its own patch after this.
- Use correct type casting for args in new functions.
- Remove extra parenthesis.
v11:
- Refactor to use charge_behaviour and charge_control_end_threshold, per the class documentation. The ideapad_laptop driver will be fixed in a separate patch series.
- Due to the extensive refactoring, I have removed the reviewed-by tags from Rong and Mark to allow them to recertify the code in its current state.
v7:
- Use devm_battery_hook_register, manually unregister during unbind.
v6:
- Check feature flags to determine if the extension should be loaded and if it is writable.
- Zero initialize wmi_method_args_32.
- Fix formatting.
v5:
- Use switch statement instead of if for battery charge state set/get.
- use force_load_psy_ext to skip all ACPI interactions.
- Various formatting fixes.
v4:
- Remove unused defines.
- Disambiguate charging defines by renaming them to be more consistent with the kernel modes they represent.
- Add module parameter to ignore ACPI checks.
- Don't fail if the ACPI handle isn't found, skip the ACPI check instead.

---
 drivers/platform/x86/lenovo/Kconfig       |   1 +
 drivers/platform/x86/lenovo/wmi-capdata.h |   1 +
 drivers/platform/x86/lenovo/wmi-other.c   | 391 ++++++++++++++++++++++
 3 files changed, 393 insertions(+)
drivers/platform/x86/lenovo/Kconfig +1 -0
index 09b1b055d2e01..b9a5d18caa1e3 100644
@@ -262,6 +262,7 @@ config LENOVO_WMI_GAMEZONE
 config LENOVO_WMI_TUNING
 	tristate "Lenovo Other Mode WMI Driver"
 	depends on ACPI_WMI
+	depends on ACPI_BATTERY
 	select HWMON
 	select FW_ATTR_CLASS
 	select LENOVO_WMI_CAPDATA
drivers/platform/x86/lenovo/wmi-capdata.h +1 -0
index a7cfdeaa58f77..a49229cec2451 100644
@@ -21,6 +21,7 @@
 enum lwmi_device_id {
 	LWMI_DEVICE_ID_CPU = 0x01,
 	LWMI_DEVICE_ID_GPU = 0x02,
+	LWMI_DEVICE_ID_PSU = 0x03,
 	LWMI_DEVICE_ID_FAN = 0x04,
 };
 
drivers/platform/x86/lenovo/wmi-other.c +391 -0

443 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#5 lore raw

PATCH v14 5/7 platform/x86: lenovo-wmi-other: Add force_load_psy_ext module parameter

In reply to Derek J. Clark

Some Lenovo BIOS have been shown to have incomplete and/or broken capability data and WMI attribute IDs. In some cases the capability data reports that a feature is not supported when the get/set methods are fully implemented. It is also possible that the ACPI methods from the ideapad_laptop driver we defer to could be bugged while the WMI method is fully working. To aid end users in submitting more complete bug reports in these situations, add an override to skip the ACPI and compatibility checks to force load the power supply extension as if it is fully supported and has no conflicts.

---
v13:
- Ensure is_writable and is_supported always return true when force_load_psy_ext is true.
v12:
- Move the force_load_psy_ext into its own distinct patch.

---
 drivers/platform/x86/lenovo/wmi-other.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/platform/x86/lenovo/wmi-other.c +19 -0
index 8331da864beba..fbb32bf404f24 100644
@@ -185,6 +185,16 @@ MODULE_PARM_DESC(relax_fan_constraint,
 	"Enabling this may results in HWMON attributes being out-of-sync, "
 	"and setting a too low RPM stops the fan. Use with caution.");
 
+/* Visibility of power supply extensions */
+static bool force_load_psy_ext;
+module_param(force_load_psy_ext, bool, 0444);
+MODULE_PARM_DESC(force_load_psy_ext,
+	"This option will skip checking if the ideapad_laptop driver will conflict "
+	"with adding an extension to set the battery charge behavior and battery charge "
+	"control end threshold. It will also skip checking if the BIOS reports that "
+	"those features are fully supported. It is recommended to blacklist the ideapad "
+	"driver before using this option.");
+
 /* ======== HWMON (component: lenovo-wmi-capdata 00 & fan) ======== */
 
 /**
@@ -755,6 +765,9 @@ static bool lwmi_psy_prop_is_supported(struct lwmi_om_priv *priv, enum power_sup
 {
 	int ret;
 
+	if (force_load_psy_ext)
+		return true;
+
 	ret = lwmi_psy_prop_get_supported(priv, prop);
 	if (ret < 0)
 		return false;
@@ -781,6 +794,9 @@ static int lwmi_psy_prop_is_writeable(struct power_supply *ps,
 	struct lwmi_om_priv *priv = ext_data;
 	int ret;
 
+	if (force_load_psy_ext)
+		return true;
+
 	ret = lwmi_psy_prop_get_supported(priv, prop);
 	if (ret < 0)
 		return false;
@@ -909,6 +925,8 @@ static void lwmi_om_psy_ext_init(struct lwmi_om_priv *priv)
 		props |= LWMI_PSY_PROP_TYPES;
 	if (!props)
 		return;
+	if (force_load_psy_ext)
+		goto load_psy_ext;
 
 	/* Deconflict ideapad_laptop driver */
 	ret = acpi_get_devices(ideapad_hid, lwmi_acpi_match, &handle, NULL);
@@ -920,6 +938,7 @@ static void lwmi_om_psy_ext_init(struct lwmi_om_priv *priv)
 		return;
 	}
 
+load_psy_ext:
 	/* Add battery hooks */
 	priv->battery_ext = lwmi_psy_exts[props];
 	priv->battery_hook.add_battery = lwmi_add_battery;
Signature · 1 line
2.53.0
author maintainer
#6 lore raw

PATCH v14 6/7 platform/x86: lenovo-wmi-helpers: Add helper for creating per-device debugfs dir

In reply to Derek J. Clark

From: Rong Zhang <[email protected]>

We are about to add debugfs support for lenovo-wmi-capdata. Let's setup a debugfs directory called "lenovo_wmi" for tidiness, so that any lenovo-wmi-* device can put its subdirectory under the directory. Subdirectories will be named after the corresponding WMI devices.

---
v13:
- Fix alphabetical include order.
v7:
- Use subsys_initcall() instead of module_init().

---
 drivers/platform/x86/lenovo/wmi-helpers.c | 34 +++++++++++++++++++++++
 drivers/platform/x86/lenovo/wmi-helpers.h |  2 ++
 2 files changed, 36 insertions(+)
drivers/platform/x86/lenovo/wmi-helpers.c +34 -0
index 7a198259e3933..8f5766c391eb4 100644
@@ -18,6 +18,8 @@
 
 #include <linux/acpi.h>
 #include <linux/cleanup.h>
+#include <linux/debugfs.h>
+#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/export.h>
 #include <linux/module.h>
@@ -185,6 +187,38 @@ int lwmi_tm_notifier_call(enum thermal_mode *mode)
 }
 EXPORT_SYMBOL_NS_GPL(lwmi_tm_notifier_call, "LENOVO_WMI_HELPERS");
 
+static struct dentry *lwmi_debugfs_dir;
+
+/**
+ * lwmi_debugfs_create_dir() - Helper function for creating a debugfs directory
+ * for a device.
+ * @wdev: Pointer to the WMI device to be called.
+ *
+ * Caller must remove the directory with debugfs_remove_recursive() on device
+ * removal.
+ *
+ * Return: Pointer to the created directory.
+ */
+struct dentry *lwmi_debugfs_create_dir(struct wmi_device *wdev)
+{
+	return debugfs_create_dir(dev_name(&wdev->dev), lwmi_debugfs_dir);
+}
+EXPORT_SYMBOL_NS_GPL(lwmi_debugfs_create_dir, "LENOVO_WMI_HELPERS");
+
+static int __init lwmi_helpers_init(void)
+{
+	lwmi_debugfs_dir = debugfs_create_dir("lenovo_wmi", NULL);
+
+	return 0;
+}
+subsys_initcall(lwmi_helpers_init)
+
+static void __exit lwmi_helpers_exit(void)
+{
+	debugfs_remove_recursive(lwmi_debugfs_dir);
+}
+module_exit(lwmi_helpers_exit)
+
 MODULE_AUTHOR("Derek J. Clark <[email protected]>");
 MODULE_DESCRIPTION("Lenovo WMI Helpers Driver");
 MODULE_LICENSE("GPL");
drivers/platform/x86/lenovo/wmi-helpers.h +2 -0
index ed7db3ebba6cc..039fe61003ceb 100644
@@ -16,6 +16,8 @@ struct wmi_method_args_32 {
 	u32 arg1;
 };
 
+struct dentry *lwmi_debugfs_create_dir(struct wmi_device *wdev);
+
 enum lwmi_event_type {
 	LWMI_GZ_GET_THERMAL_MODE = 0x01,
 };
Signature · 1 line
2.53.0
author maintainer
#7 lore raw

PATCH v14 7/7 platform/x86: lenovo-wmi-capdata: Add debugfs file for dumping capdata

In reply to Derek J. Clark

From: Rong Zhang <[email protected]>

The Lenovo GameZone/Other interfaces have some delicate divergences among different devices. When making a bug report or adding support for new devices/interfaces, capdata is the most important information to cross-check with.

Add a debugfs file (lenovo_wmi/<device_name>/capdata), so that users can dump capdata and include it in their reports.

Since struct capdata01' is just an extension to struct capdata00', also convert the former to include the latter anonymously (-fms-extensions, since v6.19). This is declared as a union in the capdata01 struct, with both the anonymous declaration and as a named member to avoid type casting when passing just the capdata00 struct pointer.

---
v12:
- Make capdata00 a union of an anonymous member and a named member of capdata01 to avoid casting when capdata00 is accessed directly.

---
 drivers/platform/x86/lenovo/Kconfig       |   1 +
 drivers/platform/x86/lenovo/wmi-capdata.c | 120 ++++++++++++++++++++++
 drivers/platform/x86/lenovo/wmi-capdata.h |   7 +-
 3 files changed, 125 insertions(+), 3 deletions(-)
drivers/platform/x86/lenovo/Kconfig +1 -0
index b9a5d18caa1e3..4443f40ef8aa7 100644
@@ -236,6 +236,7 @@ config YT2_1380
 config LENOVO_WMI_CAPDATA
 	tristate
 	depends on ACPI_WMI
+	depends on LENOVO_WMI_HELPERS
 
 config LENOVO_WMI_EVENTS
 	tristate
drivers/platform/x86/lenovo/wmi-capdata.c +120 -0

168 lines not on this page · raw message

drivers/platform/x86/lenovo/wmi-capdata.h +4 -3
index a49229cec2451..92098aeeee84a 100644
@@ -38,9 +38,10 @@ struct capdata00 {
 };
 
 struct capdata01 {
-	u32 id;
-	u32 supported;
-	u32 default_value;
+	union {
+		struct capdata00;
+		struct capdata00 cd00;
+	};
 	u32 step;
 	u32 min_value;
 	u32 max_value;
Signature · 1 line
2.53.0
maintainer
#8 lore raw
In reply to Derek J. Clark
Quoted 8 lines · Derek J. Clark

This series adds many much needed features to the lenovo-wmi* drivers. This version is based off platform-driver-x86/review-ilpo-fixes branch, so patches 1-9 from v12 have been dropped.

Patch 1 adds the remaining CPU attributes that weren't previously exposed.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/7] platform/x86: lenovo-wmi-other: Add missing CPU tunable attributes

      commit: a2a893d5757a0d43c0a2ed351eb1e34ab718f2fe
[2/7] platform/x86: lenovo-wmi-other: Add GPU tunable attributes
      commit: b51fa3b00e0339bebeac7d0c1beb13f494f6fe41
[3/7] platform/x86: lenovo-wmi-other: Rename LWMI_OM_FW_ATTR_BASE_PATH
      commit: 891d43749445fed6725acf9ee1c37e052dba8288
[4/7] platform/x86: lenovo-wmi-other: Add WMI battery charge limiting
      commit: 9ca8fc065b88b327acbfdc33454efea391639716
[5/7] platform/x86: lenovo-wmi-other: Add force_load_psy_ext module parameter
      commit: fb8e9629efbab67135f801f5ec5e91307e7693c2
[6/7] platform/x86: lenovo-wmi-helpers: Add helper for creating per-device debugfs dir
      commit: 229e575451e4e65db47bb1873be0ccab764d9f3d
[7/7] platform/x86: lenovo-wmi-capdata: Add debugfs file for dumping capdata
      commit: 18a166d29aa12d361907a3aa724c8892d834592b

--
i.