Skip to contentSkip to conversation

platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 platform profile values

PATCH Superseded Chris Taraszka 3 participants 9 messages Sep 28 – Oct 19 x86 platform drivers

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 platform profile values

The Xiaomi Book Pro 14 firmware (BIOS XMAPT4B0P0909) implements SystemPerMode with its own values. Its WMAA SET handler only acts on 0x02-0x0a and silently ignores 0 and 1, and GET returns one of 0x02, 0x03, 0x04, 0x09 or 0x0a. With the generic values:

- balanced (0) and balanced-performance (1) are no-ops,
- performance (3) selects the firmware's balanced mode,
- reading the profile fails with -EINVAL whenever the firmware is in 0x04, 0x09 or 0x0a, which it often is after boot. The failed read also makes bitland_mifs_wmi_suspend() abort system suspend.

The values were identified from the WMAA method in the firmware's SSDT and by setting each one through WMAA on AC and reading the resulting sustained package power limit from intel-rapl-mmio:

  0x02  18 W  (quiet)
  0x03  37 W  (balanced)
  0x09  45 W
  0x04  58 W  (performance)
  0x0a  18 W

Map low-power, balanced, balanced-performance and performance to 0x02, 0x03, 0x09 and 0x04 on this model. The driver never sets 0x0a, which is only reached through the firmware's own mode cycling, so report it as low-power.

Cc Armin Wolf <[email protected]>
Cc Mingyou Chen <[email protected]>

---

Notes:
Tested on the Xiaomi Book Pro 14 on AC with bitland-mifs-wmi from pdx86 for-next plus this patch, loaded on v7.3-rc5: all four profiles apply through power-profiles-daemon and the firmware mode and PL1 follow (0x03/37 W, 0x02/25 W, 0x04/56 W). The same mapping on v7.3-rc4/rc5 without the for-next changes was also tested on battery and across s2idle suspend/resume, with the profile restored on resume.

This explains the -EINVAL behind my earlier "platform/x86:
bitland-mifs-wmi: Don't abort suspend when platform profile access fails" (sent 2026-09-11): the profile read failed because of the unknown mode values. That patch is still useful as a safety net.

Note that on for-next each profile change still reports -ENOMSG even though the firmware applies it: this firmware's SET handlers leave the function id in the response at 0, which 23cc56f6dea6 ("platform/x86:
bitland-mifs-wmi: Detect failed function calls") rejects. I'll send a separate fix for that.

 drivers/platform/x86/bitland-mifs-wmi.c | 56 +++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +52 -4
index dd1648b7de77..4a8e5b4e7853 100644
@@ -14,6 +14,7 @@
 #include <linux/dev_printk.h>
 #include <linux/device.h>
 #include <linux/device/devres.h>
+#include <linux/dmi.h>
 #include <linux/err.h>
 #include <linux/hwmon.h>
 #include <linux/init.h>
@@ -79,6 +80,29 @@ enum bitland_mifs_power_profile {
 	WMI_PP_FULL_SPEED	= 3,
 };
 
+/*
+ * The Xiaomi Book Pro 14 firmware uses its own SystemPerMode values and
+ * ignores the ones above. Sustained package power limits (PL1) measured
+ * on AC are noted next to each mode.
+ */
+enum bitland_mifs_xiaomi_power_profile {
+	WMI_PP_XIAOMI_QUIET		= 0x02,	/* 18 W */
+	WMI_PP_XIAOMI_BALANCED		= 0x03,	/* 37 W */
+	WMI_PP_XIAOMI_PERFORMANCE	= 0x04,	/* 58 W */
+	WMI_PP_XIAOMI_SMART		= 0x09,	/* 45 W */
+	WMI_PP_XIAOMI_QUIET_ALT		= 0x0a,	/* 18 W */
+};
+
+static const struct dmi_system_id bitland_mifs_xiaomi_pp_dmi_table[] = {
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Xiaomi Book Pro 14"),
+		},
+	},
+	{ }
+};
+
 enum bitland_mifs_event_id {
 	WMI_EVENT_RESERVED_1		= 1,
 	WMI_EVENT_RESERVED_2		= 2,
@@ -161,6 +185,7 @@ struct bitland_mifs_wmi_data {
 	struct device *hwmon_dev;
 	struct device *pp_dev;
 	enum platform_profile_option saved_profile;
+	bool xiaomi_pp;
 };
 
 static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -213,6 +238,27 @@ static int laptop_profile_get(struct device *dev,
 	if (ret)
 		return ret;
 
+	if (data->xiaomi_pp) {
+		switch (result.data[0]) {
+		case WMI_PP_XIAOMI_QUIET:
+		case WMI_PP_XIAOMI_QUIET_ALT:
+			*profile = PLATFORM_PROFILE_LOW_POWER;
+			break;
+		case WMI_PP_XIAOMI_BALANCED:
+			*profile = PLATFORM_PROFILE_BALANCED;
+			break;
+		case WMI_PP_XIAOMI_SMART:
+			*profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE;
+			break;
+		case WMI_PP_XIAOMI_PERFORMANCE:
+			*profile = PLATFORM_PROFILE_PERFORMANCE;
+			break;
+		default:
+			return -EINVAL;
+		}
+		return 0;
+	}
+
 	switch (result.data[0]) {
 	case WMI_PP_BALANCED:
 		*profile = PLATFORM_PROFILE_BALANCED;
@@ -272,22 +318,22 @@ static int laptop_profile_set(struct device *dev,
 
 	switch (profile) {
 	case PLATFORM_PROFILE_LOW_POWER:
-		val = WMI_PP_QUIET;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_QUIET : WMI_PP_QUIET;
 		break;
 	case PLATFORM_PROFILE_BALANCED:
-		val = WMI_PP_BALANCED;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_BALANCED : WMI_PP_BALANCED;
 		break;
 	case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
 		ret = bitland_check_performance_capability(data);
 		if (ret)
 			return ret;
-		val = WMI_PP_PERFORMANCE;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_SMART : WMI_PP_PERFORMANCE;
 		break;
 	case PLATFORM_PROFILE_PERFORMANCE:
 		ret = bitland_check_performance_capability(data);
 		if (ret)
 			return ret;
-		val = WMI_PP_FULL_SPEED;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_PERFORMANCE : WMI_PP_FULL_SPEED;
 		break;
 	default:
 		return -EOPNOTSUPP;
@@ -699,6 +745,8 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context)
 		return input_register_device(drv_data->input_dev);
 	}
 
+	drv_data->xiaomi_pp = dmi_check_system(bitland_mifs_xiaomi_pp_dmi_table);
+
 	/* Register platform profile */
 	drv_data->pp_dev = devm_platform_profile_register(&wdev->dev, DRV_NAME, drv_data,
 							  &laptop_profile_ops);

base-commit: fe5030c8cc7156223f48530e9b49aa87c0305bcd

Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 145 lines · Chris Taraszka

The Xiaomi Book Pro 14 firmware (BIOS XMAPT4B0P0909) implements SystemPerMode with its own values. Its WMAA SET handler only acts on 0x02-0x0a and silently ignores 0 and 1, and GET returns one of 0x02, 0x03, 0x04, 0x09 or 0x0a. With the generic values:

- balanced (0) and balanced-performance (1) are no-ops,
- performance (3) selects the firmware's balanced mode,
- reading the profile fails with -EINVAL whenever the firmware is in 0x04, 0x09 or 0x0a, which it often is after boot. The failed read also makes bitland_mifs_wmi_suspend() abort system suspend.

The values were identified from the WMAA method in the firmware's SSDT and by setting each one through WMAA on AC and reading the resulting sustained package power limit from intel-rapl-mmio:

  0x02  18 W  (quiet)
  0x03  37 W  (balanced)
  0x09  45 W
  0x04  58 W  (performance)
  0x0a  18 W

Map low-power, balanced, balanced-performance and performance to 0x02, 0x03, 0x09 and 0x04 on this model. The driver never sets 0x0a, which is only reached through the firmware's own mode cycling, so report it as low-power.

Cc Armin Wolf <[email protected]>
Cc Mingyou Chen <[email protected]>

---

Notes:
Tested on the Xiaomi Book Pro 14 on AC with bitland-mifs-wmi from pdx86 for-next plus this patch, loaded on v7.3-rc5: all four profiles apply through power-profiles-daemon and the firmware mode and PL1 follow (0x03/37 W, 0x02/25 W, 0x04/56 W). The same mapping on v7.3-rc4/rc5 without the for-next changes was also tested on battery and across s2idle suspend/resume, with the profile restored on resume.

This explains the -EINVAL behind my earlier "platform/x86:
bitland-mifs-wmi: Don't abort suspend when platform profile access fails" (sent 2026-09-11): the profile read failed because of the unknown mode values. That patch is still useful as a safety net.

Note that on for-next each profile change still reports -ENOMSG even though the firmware applies it: this firmware's SET handlers leave the function id in the response at 0, which 23cc56f6dea6 ("platform/x86:
bitland-mifs-wmi: Detect failed function calls") rejects. I'll send a separate fix for that.

 drivers/platform/x86/bitland-mifs-wmi.c | 56 +++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +48 -2
index dd1648b7de77..4a8e5b4e7853 100644
@@ -14,6 +14,7 @@
 #include <linux/dev_printk.h>
 #include <linux/device.h>
 #include <linux/device/devres.h>
+#include <linux/dmi.h>
 #include <linux/err.h>
 #include <linux/hwmon.h>
 #include <linux/init.h>
@@ -79,6 +80,29 @@ enum bitland_mifs_power_profile {
 	WMI_PP_FULL_SPEED	= 3,
 };
 
+/*
+ * The Xiaomi Book Pro 14 firmware uses its own SystemPerMode values and
+ * ignores the ones above. Sustained package power limits (PL1) measured
+ * on AC are noted next to each mode.
+ */
+enum bitland_mifs_xiaomi_power_profile {
+	WMI_PP_XIAOMI_QUIET		= 0x02,	/* 18 W */
+	WMI_PP_XIAOMI_BALANCED		= 0x03,	/* 37 W */
+	WMI_PP_XIAOMI_PERFORMANCE	= 0x04,	/* 58 W */
+	WMI_PP_XIAOMI_SMART		= 0x09,	/* 45 W */
+	WMI_PP_XIAOMI_QUIET_ALT		= 0x0a,	/* 18 W */
+};
+
+static const struct dmi_system_id bitland_mifs_xiaomi_pp_dmi_table[] = {
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Xiaomi Book Pro 14"),
+		},
+	},
+	{ }
+};
+
 enum bitland_mifs_event_id {
 	WMI_EVENT_RESERVED_1		= 1,
 	WMI_EVENT_RESERVED_2		= 2,
@@ -161,6 +185,7 @@ struct bitland_mifs_wmi_data {
 	struct device *hwmon_dev;
 	struct device *pp_dev;
 	enum platform_profile_option saved_profile;
+	bool xiaomi_pp;
 };
 
 static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -213,6 +238,27 @@ static int laptop_profile_get(struct device *dev,
 	if (ret)
 		return ret;
 
+	if (data->xiaomi_pp) {
+		switch (result.data[0]) {
+		case WMI_PP_XIAOMI_QUIET:
+		case WMI_PP_XIAOMI_QUIET_ALT:
+			*profile = PLATFORM_PROFILE_LOW_POWER;
+			break;
+		case WMI_PP_XIAOMI_BALANCED:
+			*profile = PLATFORM_PROFILE_BALANCED;
+			break;
+		case WMI_PP_XIAOMI_SMART:
+			*profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE;
+			break;
+		case WMI_PP_XIAOMI_PERFORMANCE:
+			*profile = PLATFORM_PROFILE_PERFORMANCE;
+			break;
+		default:
+			return -EINVAL;
+		}
+		return 0;
+	}
+
 	switch (result.data[0]) {
 	case WMI_PP_BALANCED:
 		*profile = PLATFORM_PROFILE_BALANCED;
@@ -272,22 +318,22 @@ static int laptop_profile_set(struct device *dev,
 
 	switch (profile) {
 	case PLATFORM_PROFILE_LOW_POWER:
-		val = WMI_PP_QUIET;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_QUIET : WMI_PP_QUIET;
 		break;
 	case PLATFORM_PROFILE_BALANCED:
-		val = WMI_PP_BALANCED;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_BALANCED : WMI_PP_BALANCED;
 		break;
 	case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
 		ret = bitland_check_performance_capability(data);
 		if (ret)

drivers/platform/x86/bitland-mifs-wmi.c static int laptop_profile_set(struct device *dev, · line 336

Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +2 -2
 			return ret;
-		val = WMI_PP_PERFORMANCE;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_SMART : WMI_PP_PERFORMANCE;
 		break;
 	case PLATFORM_PROFILE_PERFORMANCE:
 		ret = bitland_check_performance_capability(data);
 		if (ret)
 			return ret;
-		val = WMI_PP_FULL_SPEED;
+		val = data->xiaomi_pp ? WMI_PP_XIAOMI_PERFORMANCE : WMI_PP_FULL_SPEED;

Hi,

Thanks for the patch but I won't accept device specific conditionals like this done in the code. For a better approach, please see:

bitland-mifs-wmi: Fix TM2107 profile handling

You two could try to coordinate such that transition into the generic approach is not worked by both independently.

It might be best to extract the generalization part to own patch and both then base their respective device specific patches adding new things on top of that.

Signature · 1 line
 i.
#2 lore raw

Thanks, makes sense.

Matias, one thing I ran into when trying your generic part on the Xiaomi Book Pro 14: its values are sparse (0x02, 0x03, 0x04, 0x09, 0x0a) and 0x02 and 0x0a both mean low-power. With a profile array indexed by the firmware value, the unused slots read back as PLATFORM_PROFILE_LOW_POWER (0), and the reverse lookup for low-power finds index 0, which this firmware ignores.

So I'd suggest {value, profile} pairs for the shared part. I have that as a standalone patch on pdx86/for-next, with only the profile table in the quirk struct, so your response layout and AC check handling would go on top in your TM2107 patch. If that works for you I'll send it as v2 together with the Xiaomi entry, and you can base your v3 on it. If you'd rather own the generic patch, that's fine too, I'll rebase the Xiaomi part on yours.

Quoted 177 lines · Ilpo Järvinen
Quoted 145 lines · Chris Taraszka

The Xiaomi Book Pro 14 firmware (BIOS XMAPT4B0P0909) implements SystemPerMode with its own values. Its WMAA SET handler only acts on 0x02-0x0a and silently ignores 0 and 1, and GET returns one of 0x02, 0x03, 0x04, 0x09 or 0x0a. With the generic values:

- balanced (0) and balanced-performance (1) are no-ops,
- performance (3) selects the firmware's balanced mode,
- reading the profile fails with -EINVAL whenever the firmware is in 0x04, 0x09 or 0x0a, which it often is after boot. The failed read also makes bitland_mifs_wmi_suspend() abort system suspend.

The values were identified from the WMAA method in the firmware's SSDT and by setting each one through WMAA on AC and reading the resulting sustained package power limit from intel-rapl-mmio:

  0x02  18 W  (quiet)
  0x03  37 W  (balanced)
  0x09  45 W
  0x04  58 W  (performance)
  0x0a  18 W

Map low-power, balanced, balanced-performance and performance to 0x02, 0x03, 0x09 and 0x04 on this model. The driver never sets 0x0a, which is only reached through the firmware's own mode cycling, so report it as low-power.

Cc Armin Wolf <[email protected]>
Cc Mingyou Chen <[email protected]>

---

Notes:
Tested on the Xiaomi Book Pro 14 on AC with bitland-mifs-wmi from pdx86 for-next plus this patch, loaded on v7.3-rc5: all four profiles apply through power-profiles-daemon and the firmware mode and PL1 follow (0x03/37 W, 0x02/25 W, 0x04/56 W). The same mapping on v7.3-rc4/rc5 without the for-next changes was also tested on battery and across s2idle suspend/resume, with the profile restored on resume.

This explains the -EINVAL behind my earlier "platform/x86:
bitland-mifs-wmi: Don't abort suspend when platform profile access fails" (sent 2026-09-11): the profile read failed because of the unknown mode values. That patch is still useful as a safety net.

Note that on for-next each profile change still reports -ENOMSG even though the firmware applies it: this firmware's SET handlers leave the function id in the response at 0, which 23cc56f6dea6 ("platform/x86:
bitland-mifs-wmi: Detect failed function calls") rejects. I'll send a separate fix for that.

 drivers/platform/x86/bitland-mifs-wmi.c | 56 +++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +48 -2
index dd1648b7de77..4a8e5b4e7853 100644
@@ -14,6 +14,7 @@
 #include <linux/dev_printk.h>
 #include <linux/device.h>
 #include <linux/device/devres.h>
+#include <linux/dmi.h>
 #include <linux/err.h>
 #include <linux/hwmon.h>
 #include <linux/init.h>
@@ -79,6 +80,29 @@ enum bitland_mifs_power_profile {
      WMI_PP_FULL_SPEED       = 3,
 };
 
+/*
+ * The Xiaomi Book Pro 14 firmware uses its own SystemPerMode values and
+ * ignores the ones above. Sustained package power limits (PL1) measured
+ * on AC are noted next to each mode.
+ */
+enum bitland_mifs_xiaomi_power_profile {
+     WMI_PP_XIAOMI_QUIET             = 0x02, /* 18 W */
+     WMI_PP_XIAOMI_BALANCED          = 0x03, /* 37 W */
+     WMI_PP_XIAOMI_PERFORMANCE       = 0x04, /* 58 W */
+     WMI_PP_XIAOMI_SMART             = 0x09, /* 45 W */
+     WMI_PP_XIAOMI_QUIET_ALT         = 0x0a, /* 18 W */
+};
+
+static const struct dmi_system_id bitland_mifs_xiaomi_pp_dmi_table[] = {
+     {
+             .matches = {
+                     DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"),
+                     DMI_MATCH(DMI_PRODUCT_NAME, "Xiaomi Book Pro 14"),
+             },
+     },
+     { }
+};
+
 enum bitland_mifs_event_id {
      WMI_EVENT_RESERVED_1            = 1,
      WMI_EVENT_RESERVED_2            = 2,
@@ -161,6 +185,7 @@ struct bitland_mifs_wmi_data {
      struct device *hwmon_dev;
      struct device *pp_dev;
      enum platform_profile_option saved_profile;
+     bool xiaomi_pp;
 };
 
 static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -213,6 +238,27 @@ static int laptop_profile_get(struct device *dev,
      if (ret)
              return ret;
 
+     if (data->xiaomi_pp) {
+             switch (result.data[0]) {
+             case WMI_PP_XIAOMI_QUIET:
+             case WMI_PP_XIAOMI_QUIET_ALT:
+                     *profile = PLATFORM_PROFILE_LOW_POWER;
+                     break;
+             case WMI_PP_XIAOMI_BALANCED:
+                     *profile = PLATFORM_PROFILE_BALANCED;
+                     break;
+             case WMI_PP_XIAOMI_SMART:
+                     *profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE;
+                     break;
+             case WMI_PP_XIAOMI_PERFORMANCE:
+                     *profile = PLATFORM_PROFILE_PERFORMANCE;
+                     break;
+             default:
+                     return -EINVAL;
+             }
+             return 0;
+     }
+
      switch (result.data[0]) {
      case WMI_PP_BALANCED:
              *profile = PLATFORM_PROFILE_BALANCED;
@@ -272,22 +318,22 @@ static int laptop_profile_set(struct device *dev,
 
      switch (profile) {
      case PLATFORM_PROFILE_LOW_POWER:
-             val = WMI_PP_QUIET;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_QUIET : WMI_PP_QUIET;
              break;
      case PLATFORM_PROFILE_BALANCED:
-             val = WMI_PP_BALANCED;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_BALANCED : WMI_PP_BALANCED;
              break;
      case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
              ret = bitland_check_performance_capability(data);
              if (ret)

drivers/platform/x86/bitland-mifs-wmi.c static int laptop_profile_set(struct device *dev, · line 336

Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +2 -2
                      return ret;
-             val = WMI_PP_PERFORMANCE;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_SMART : WMI_PP_PERFORMANCE;
              break;
      case PLATFORM_PROFILE_PERFORMANCE:
              ret = bitland_check_performance_capability(data);
              if (ret)
                      return ret;
-             val = WMI_PP_FULL_SPEED;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_PERFORMANCE : WMI_PP_FULL_SPEED;

Hi,

Thanks for the patch but I won't accept device specific conditionals like this done in the code. For a better approach, please see:

bitland-mifs-wmi: Fix TM2107 profile handling

You two could try to coordinate such that transition into the generic approach is not worked by both independently.

It might be best to extract the generalization part to own patch and both then base their respective device specific patches adding new things on top of that.

--
i.

#3 lore raw

Hi Chris,

No problem, your proposal works for me. Please CC me when you send the series so I can test the shared changes and base my TM2107 v3 on your generic patch.

Thanks,
Matias

Quoted 17 lines

Thanks, makes sense.

Matias, one thing I ran into when trying your generic part on the Xiaomi Book Pro 14: its values are sparse (0x02, 0x03, 0x04, 0x09, 0x0a) and 0x02 and 0x0a both mean low-power. With a profile array indexed by the firmware value, the unused slots read back as PLATFORM_PROFILE_LOW_POWER (0), and the reverse lookup for low-power finds index 0, which this firmware ignores.

So I'd suggest {value, profile} pairs for the shared part. I have that as a standalone patch on pdx86/for-next, with only the profile table in the quirk struct, so your response layout and AC check handling would go on top in your TM2107 patch. If that works for you I'll send it as v2 together with the Xiaomi entry, and you can base your v3 on it. If you'd rather own the generic patch, that's fine too, I'll rebase the Xiaomi part on yours.

maintainer
#4 lore raw

FYI,

There are a few more of these in the queue:

https://patchwork.kernel.org/project/platform-driver-x86/patch/[email protected]/
https://patchwork.kernel.org/project/platform-driver-x86/patch/[email protected]/

The first one is a bit messy, as it adds some keys as well (which should have been in a separate patch).

And some more in Mingyou's redmi-wmi merge series's last patch:

https://patchwork.kernel.org/project/platform-driver-x86/patch/[email protected]/

The profile mode abstraction in that series seems not general enough though so the generalization work we've discussed is still necessary and should be used as a base for that series.

--
i.

Quoted 27 lines · Matias Civadda

Hi Chris,

No problem, your proposal works for me. Please CC me when you send the series so I can test the shared changes and base my TM2107 v3 on your generic patch.

Thanks,
Matias

Quoted 17 lines

Thanks, makes sense.

Matias, one thing I ran into when trying your generic part on the Xiaomi Book Pro 14: its values are sparse (0x02, 0x03, 0x04, 0x09, 0x0a) and 0x02 and 0x0a both mean low-power. With a profile array indexed by the firmware value, the unused slots read back as PLATFORM_PROFILE_LOW_POWER (0), and the reverse lookup for low-power finds index 0, which this firmware ignores.

So I'd suggest {value, profile} pairs for the shared part. I have that as a standalone patch on pdx86/for-next, with only the profile table in the quirk struct, so your response layout and AC check handling would go on top in your TM2107 patch. If that works for you I'll send it as v2 together with the Xiaomi entry, and you can base your v3 on it. If you'd rather own the generic patch, that's fine too, I'll rebase the Xiaomi part on yours.

Signature · 1 line
 i.
maintainer
#5 lore raw
In reply to Chris Taraszka
Quoted 9 lines · Chris Taraszka

Thanks, makes sense.

Matias, one thing I ran into when trying your generic part on the Xiaomi Book Pro 14: its values are sparse (0x02, 0x03, 0x04, 0x09, 0x0a) and 0x02 and 0x0a both mean low-power. With a profile array indexed by the firmware value, the unused slots read back as PLATFORM_PROFILE_LOW_POWER (0), and the reverse lookup for low-power finds index 0, which this firmware ignores.

Quoted 7 lines

So I'd suggest {value, profile} pairs for the shared part. I have that as a standalone patch on pdx86/for-next, with only the profile table in the quirk struct, so your response layout and AC check handling would go on top in your TM2107 patch. If that works for you I'll send it as v2 together with the Xiaomi entry, and you can base your v3 on it. If you'd rather own the generic patch, that's fine too, I'll rebase the Xiaomi part on yours.

Hi,

I've not seen v2 so far, has there been some progress with this?

(Not having the generalization seems a blocker adding many models.)

--
i.

Quoted 180 lines
Quoted 177 lines · Ilpo Järvinen
Quoted 145 lines · Chris Taraszka

The Xiaomi Book Pro 14 firmware (BIOS XMAPT4B0P0909) implements SystemPerMode with its own values. Its WMAA SET handler only acts on 0x02-0x0a and silently ignores 0 and 1, and GET returns one of 0x02, 0x03, 0x04, 0x09 or 0x0a. With the generic values:

- balanced (0) and balanced-performance (1) are no-ops,
- performance (3) selects the firmware's balanced mode,
- reading the profile fails with -EINVAL whenever the firmware is in 0x04, 0x09 or 0x0a, which it often is after boot. The failed read also makes bitland_mifs_wmi_suspend() abort system suspend.

The values were identified from the WMAA method in the firmware's SSDT and by setting each one through WMAA on AC and reading the resulting sustained package power limit from intel-rapl-mmio:

  0x02  18 W  (quiet)
  0x03  37 W  (balanced)
  0x09  45 W
  0x04  58 W  (performance)
  0x0a  18 W

Map low-power, balanced, balanced-performance and performance to 0x02, 0x03, 0x09 and 0x04 on this model. The driver never sets 0x0a, which is only reached through the firmware's own mode cycling, so report it as low-power.

Cc Armin Wolf <[email protected]>
Cc Mingyou Chen <[email protected]>

---

Notes:
Tested on the Xiaomi Book Pro 14 on AC with bitland-mifs-wmi from pdx86 for-next plus this patch, loaded on v7.3-rc5: all four profiles apply through power-profiles-daemon and the firmware mode and PL1 follow (0x03/37 W, 0x02/25 W, 0x04/56 W). The same mapping on v7.3-rc4/rc5 without the for-next changes was also tested on battery and across s2idle suspend/resume, with the profile restored on resume.

This explains the -EINVAL behind my earlier "platform/x86:
bitland-mifs-wmi: Don't abort suspend when platform profile access fails" (sent 2026-09-11): the profile read failed because of the unknown mode values. That patch is still useful as a safety net.

Note that on for-next each profile change still reports -ENOMSG even though the firmware applies it: this firmware's SET handlers leave the function id in the response at 0, which 23cc56f6dea6 ("platform/x86:
bitland-mifs-wmi: Detect failed function calls") rejects. I'll send a separate fix for that.

 drivers/platform/x86/bitland-mifs-wmi.c | 56 +++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 4 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +48 -2
index dd1648b7de77..4a8e5b4e7853 100644
@@ -14,6 +14,7 @@
 #include <linux/dev_printk.h>
 #include <linux/device.h>
 #include <linux/device/devres.h>
+#include <linux/dmi.h>
 #include <linux/err.h>
 #include <linux/hwmon.h>
 #include <linux/init.h>
@@ -79,6 +80,29 @@ enum bitland_mifs_power_profile {
      WMI_PP_FULL_SPEED       = 3,
 };
 
+/*
+ * The Xiaomi Book Pro 14 firmware uses its own SystemPerMode values and
+ * ignores the ones above. Sustained package power limits (PL1) measured
+ * on AC are noted next to each mode.
+ */
+enum bitland_mifs_xiaomi_power_profile {
+     WMI_PP_XIAOMI_QUIET             = 0x02, /* 18 W */
+     WMI_PP_XIAOMI_BALANCED          = 0x03, /* 37 W */
+     WMI_PP_XIAOMI_PERFORMANCE       = 0x04, /* 58 W */
+     WMI_PP_XIAOMI_SMART             = 0x09, /* 45 W */
+     WMI_PP_XIAOMI_QUIET_ALT         = 0x0a, /* 18 W */
+};
+
+static const struct dmi_system_id bitland_mifs_xiaomi_pp_dmi_table[] = {
+     {
+             .matches = {
+                     DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"),
+                     DMI_MATCH(DMI_PRODUCT_NAME, "Xiaomi Book Pro 14"),
+             },
+     },
+     { }
+};
+
 enum bitland_mifs_event_id {
      WMI_EVENT_RESERVED_1            = 1,
      WMI_EVENT_RESERVED_2            = 2,
@@ -161,6 +185,7 @@ struct bitland_mifs_wmi_data {
      struct device *hwmon_dev;
      struct device *pp_dev;
      enum platform_profile_option saved_profile;
+     bool xiaomi_pp;
 };
 
 static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -213,6 +238,27 @@ static int laptop_profile_get(struct device *dev,
      if (ret)
              return ret;
 
+     if (data->xiaomi_pp) {
+             switch (result.data[0]) {
+             case WMI_PP_XIAOMI_QUIET:
+             case WMI_PP_XIAOMI_QUIET_ALT:
+                     *profile = PLATFORM_PROFILE_LOW_POWER;
+                     break;
+             case WMI_PP_XIAOMI_BALANCED:
+                     *profile = PLATFORM_PROFILE_BALANCED;
+                     break;
+             case WMI_PP_XIAOMI_SMART:
+                     *profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE;
+                     break;
+             case WMI_PP_XIAOMI_PERFORMANCE:
+                     *profile = PLATFORM_PROFILE_PERFORMANCE;
+                     break;
+             default:
+                     return -EINVAL;
+             }
+             return 0;
+     }
+
      switch (result.data[0]) {
      case WMI_PP_BALANCED:
              *profile = PLATFORM_PROFILE_BALANCED;
@@ -272,22 +318,22 @@ static int laptop_profile_set(struct device *dev,
 
      switch (profile) {
      case PLATFORM_PROFILE_LOW_POWER:
-             val = WMI_PP_QUIET;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_QUIET : WMI_PP_QUIET;
              break;
      case PLATFORM_PROFILE_BALANCED:
-             val = WMI_PP_BALANCED;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_BALANCED : WMI_PP_BALANCED;
              break;
      case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
              ret = bitland_check_performance_capability(data);
              if (ret)

drivers/platform/x86/bitland-mifs-wmi.c static int laptop_profile_set(struct device *dev, · line 336

Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +2 -2
                      return ret;
-             val = WMI_PP_PERFORMANCE;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_SMART : WMI_PP_PERFORMANCE;
              break;
      case PLATFORM_PROFILE_PERFORMANCE:
              ret = bitland_check_performance_capability(data);
              if (ret)
                      return ret;
-             val = WMI_PP_FULL_SPEED;
+             val = data->xiaomi_pp ? WMI_PP_XIAOMI_PERFORMANCE : WMI_PP_FULL_SPEED;

Hi,

Thanks for the patch but I won't accept device specific conditionals like this done in the code. For a better approach, please see:

bitland-mifs-wmi: Fix TM2107 profile handling

You two could try to coordinate such that transition into the generic approach is not worked by both independently.

It might be best to extract the generalization part to own patch and both then base their respective device specific patches adding new things on top of that.

--
i.

Signature · 1 line
 i.
#6 lore raw
Quoted 3 lines · Ilpo Järvinen

I've not seen v2 so far, has there been some progress with this?

(Not having the generalization seems a blocker adding many models.)

Hi Ilpo,

Sorry for the silence. Mingyou's v12 5/6 ("platform/x86:
bitland-mifs-wmi: Add quirks table") now has the {value, profile} pair table I described, plus the no_set flag for GET-only values and accept_zero_function for SET replies without a function id. That covers what my v2 generic patch would have done, so I won't post a second one. I'll test v12 on the Xiaomi Book Pro 14 and base the model entry on top of it.

Mingyou, one issue in v12 5/6, in bitland_mifs_wmi_call():

    memcpy(output->data, payload_data, sizeof(*output->data));

data is u8[28], so this copies a single byte. laptop_hwmon_read() reads res.data[0..7] for the fan speeds, which would then come from uninitialized stack. sizeof(output->data) is what you want.

Kento, you're right that the match has to be on board_name TM2424. Since we have the same machine, let's send a single TM2424 entry. If you rebase your v2 onto Mingyou's table, I'm fine with it being yours and I'll test it here on BIOS XMAPT4B0P0909 with accept_zero_function set.

Matias, sorry for the delay. I think your TM2107 v3 can go on top of Mingyou's 5/6 directly.

Thanks,
Chris

#7 lore raw

Hi,

Following up with test results. I tested v12 on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0909), applied on pdx86 for-next and loaded as a module on v7.3-rc5, with a local TM2424 entry: 0x02, 0x0a (no_set), 0x03, 0x09 and 0x04, plus skip_ac_type_check and accept_zero_function. All four profiles apply on AC and PL1 follows, and pm_test=devices suspend/resume is clean on AC and on battery. Without the entry, GET fails with -EINVAL and every SET with -ENOMSG, as expected.

Mingyou, two more things:

1. In 6/6 only -EOPNOTSUPP falls back to balanced. Without the entry above, restoring the profile fails with -ENOMSG and the resume callback returns it:

bitland_mifs_wmi_resume [bitland_mifs_wmi] returns -42
PM: failed to resume: error -42

A failed restore leaves the machine usable, so I think resume should warn and return 0 for any error after trying the fallback. The same goes for suspend: bitland_mifs_wmi_suspend() still returns the laptop_profile_get() error, which aborts system suspend on any model whose firmware reports a value missing from its table. That is what my earlier "Don't abort suspend when platform profile access fails" patch was about, and it could be folded into 6/6.

2. With skip_ac_type_check, bitland_pp_check_capability() still refuses balanced-performance and performance without a power supply. On BIOS 0909 the firmware runs 0x04 on battery (PL1 58 W), so this blocks a mode that works here. Kento reported that BIOS 0707 NACKs 0x04 on battery, which bitland_mifs_wmi_call() already turns into an error. Could skip_ac_type_check skip the power supply check as well and leave the decision to the firmware? Kento, would that be a problem on 0A0A?

Thanks,
Chris

maintainer
#8 lore raw
In reply to Chris Taraszka
Quoted 5 lines · Chris Taraszka
Quoted 3 lines · Ilpo Järvinen

I've not seen v2 so far, has there been some progress with this?

(Not having the generalization seems a blocker adding many models.)

Quoted 8 lines

Hi Ilpo,

Sorry for the silence. Mingyou's v12 5/6 ("platform/x86:
bitland-mifs-wmi: Add quirks table") now has the {value, profile} pair table I described, plus the no_set flag for GET-only values and accept_zero_function for SET replies without a function id. That covers what my v2 generic patch would have done, so I won't post a second one.

Okay, thanks. I'll go with that series then.

Quoted 19 lines

I'll test v12 on the Xiaomi Book Pro 14 and base the model entry on top of it.

Mingyou, one issue in v12 5/6, in bitland_mifs_wmi_call():

    memcpy(output->data, payload_data, sizeof(*output->data));

data is u8[28], so this copies a single byte. laptop_hwmon_read() reads res.data[0..7] for the fan speeds, which would then come from uninitialized stack. sizeof(output->data) is what you want.

Kento, you're right that the match has to be on board_name TM2424. Since we have the same machine, let's send a single TM2424 entry. If you rebase your v2 onto Mingyou's table, I'm fine with it being yours and I'll test it here on BIOS XMAPT4B0P0909 with accept_zero_function set.

Matias, sorry for the delay. I think your TM2107 v3 can go on top of Mingyou's 5/6 directly.

Signature · 1 line
 i.