platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support
v2 cover platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support
Two patches on top of Mingyou Chen's v13 "Merge redmi-wmi into bitland-mifs-wmi" [1], which adds the quirks table they build on.
Patch 1 adds the Xiaomi Book Pro 14 (TM2424) entry. Patch 2 stops platform profile save/restore errors from failing system suspend or resume.
Kento proposed a different mapping for the same board [2]: low-power as 0x0a (which also dims the panel and keyboard backlight), balanced as 0x09, performance as 0x04 with 0x03 as fallback, and no balanced-performance. This series keeps the four distinct firmware modes and leaves 0x0a to the firmware's own mode cycling. Kento, if this is a problem on BIOS 0707 or 0A0A, please say so.
Mingyou, on your v13 question: with 7/7, accept_zero_function is not needed here. The entry does not set it and every SET succeeds.
Changes since v1 [3][4]:
- Use the quirks table from v13 instead of a DMI conditional in the code
- Match on board name TM2424 (Kento)
- Suspend fix also covers resume and skips the restore when nothing was saved
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
Chris Taraszka (2):
platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on
profile errors
drivers/platform/x86/bitland-mifs-wmi.c | 43 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-)
base-commit: 9d3475065167197742b0882aff21cf8e78393277
prerequisite-patch-id: 99b10cd2b70d630ab65d8a8bb02c1d4bf89b1a63
prerequisite-patch-id: 27db041f827872b8be142c310a14c79962154bd5
prerequisite-patch-id: 74fc3298fa3dceb2224dfc3d2ae4cc6d4be61c01
prerequisite-patch-id: 2bbb1371b506f5a07a1e6e69d34217195cd5ffcb
prerequisite-patch-id: b88e60d7915ad055b67478359bd9c6c9482d8433
prerequisite-patch-id: 2fe8c043993034f1a2cde98b1b2e299987d5ac7f
prerequisite-patch-id: fbf70405992dfa75ed02026d97aa16e1644fbd42
Signature · 1 line
2.56.0
PATCH v2 1/2 platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk
The Xiaomi Book Pro 14 (board TM2424) implements SystemPerMode with its own values. Its firmware ignores 0x00 and 0x01, and GET returns one of 0x02, 0x03, 0x04, 0x09 or 0x0a, so with the default table balanced and balanced-performance are no-ops and reading the profile fails with -EINVAL whenever the firmware is in 0x04, 0x09 or 0x0a. The failed read also aborts system suspend.
The values were identified from the WMAA method in the firmware's SSDT and by setting each one and reading the sustained package power limit from intel-rapl-mmio on AC:
0x02 18 W 0x03 37 W 0x09 45 W 0x04 58 W 0x0a 18 W
Map low-power, balanced, balanced-performance and performance to 0x02, 0x03, 0x09 and 0x04. 0x0a is only entered through the firmware's own mode cycling, so report it as low-power without offering it for SET.
The machine is USB-C only and WMI_FN_SYSTEM_AC_TYPE is not implemented, so skip the AC type check.
---
Notes:
Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A) with this series on top of v13, backported to v7.3, on AC: all four profiles set and read back, and the firmware mode (EC 0x68) and PL1 follow:
0x02/18 W, 0x03/37 W, 0x09/45 W, 0x04/58 W. These match the values first measured on BIOS XMAPT4B0P0909. s2idle suspend/resume from performance restores 0x04.
On battery, balanced-performance and performance are refused by bitland_pp_check_capability(), although BIOS 0909 applies 0x04 on battery. This patch leaves that check as it is.
drivers/platform/x86/bitland-mifs-wmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/platform/x86/bitland-mifs-wmi.c +21 -0
@@ -116,7 +116,28 @@ static const struct bitland_mifs_quirks default_quirks = { .num_profile_entries = ARRAY_SIZE(default_profile_entries), }; +static const struct bitland_profile_entry tm2424_profile_entries[] = { + {PLATFORM_PROFILE_LOW_POWER ,0x02 }, + {PLATFORM_PROFILE_LOW_POWER ,0x0a , true }, + {PLATFORM_PROFILE_BALANCED ,0x03 }, + {PLATFORM_PROFILE_BALANCED_PERFORMANCE ,0x09 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x04 }, +}; + +static const struct bitland_mifs_quirks tm2424_quirks = { + .profile_entries = tm2424_profile_entries, + .num_profile_entries =ARRAY_SIZE (tm2424_profile_entries), + .skip_ac_type_check = true, +}; +static const struct dmi_system_id bitland_mifs_dmi_table[] = { + { + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"XIAOMI" ), +DMI_EXACT_MATCH (DMI_BOARD_NAME ,"TM2424" ), + }, + .driver_data = (void *)&tm2424_quirks, + }, {} };
Signature · 1 line
2.56.0
Re: [PATCH v2 1/2] platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk
Quoted 65 lines · Chris Taraszka
The Xiaomi Book Pro 14 (board TM2424) implements SystemPerMode with its own values. Its firmware ignores
0x00and0x01, and GET returns one of0x02,0x03,0x04,0x09or0x0a, so with the default table balanced and balanced-performance are no-ops and reading the profile fails with-EINVALwhenever the firmware is in0x04,0x09or0x0a. The failed read also aborts system suspend.The values were identified from the WMAA method in the firmware's SSDT and by setting each one and reading the sustained package power limit from intel-rapl-mmio on AC:
0x02 18 W 0x03 37 W 0x09 45 W 0x04 58 W 0x0a 18 WMap low-power, balanced, balanced-performance and performance to
0x02,0x03,0x09and0x04.0x0ais only entered through the firmware's own mode cycling, so report it as low-power without offering it for SET.The machine is USB-C only and
WMI_FN_SYSTEM_AC_TYPEis not implemented, so skip the AC type check.Signed-off-by Chris Taraszka <[email protected]>---
Notes:
Tested on the Xiaomi Book Pro 14 (TM2424, BIOS XMAPT4B0P0A0A) with this series on top of v13, backported to v7.3, on AC: all four profiles set and read back, and the firmware mode (EC0x68) and PL1 follow:
0x02/18 W, 0x03/37 W, 0x09/45 W, 0x04/58 W. These match the values first measured on BIOS XMAPT4B0P0909. s2idle suspend/resume from performance restores0x04.On battery, balanced-performance and performance are refused by
bitland_pp_check_capability(), although BIOS 0909 applies0x04on battery. This patch leaves that check as it is.drivers/platform/x86/bitland-mifs-wmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/platform/x86/bitland-mifs-wmi.c +14
-0@@ -116,7 +116,28 @@ static const struct bitland_mifs_quirks default_quirks = { .num_profile_entries = ARRAY_SIZE(default_profile_entries), }; +static const struct bitland_profile_entry tm2424_profile_entries[] = { + {PLATFORM_PROFILE_LOW_POWER ,0x02 }, + {PLATFORM_PROFILE_LOW_POWER ,0x0a , true }, + {PLATFORM_PROFILE_BALANCED ,0x03 }, + {PLATFORM_PROFILE_BALANCED_PERFORMANCE ,0x09 }, + {PLATFORM_PROFILE_PERFORMANCE ,0x04 }, +}; + +static const struct bitland_mifs_quirks tm2424_quirks = { + .profile_entries = tm2424_profile_entries, + .num_profile_entries =ARRAY_SIZE (tm2424_profile_entries), + .skip_ac_type_check = true, +}; +static const struct dmi_system_id bitland_mifs_dmi_table[] = {
drivers/platform/x86/bitland-mifs-wmi.c static const struct bitland_mifs_quirks default_quirks = { · line 143
Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +7
-0+ { + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "XIAOMI"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "TM2424"), + }, + .driver_data = (void *)&tm2424_quirks, + }, {} };
PATCH v2 2/2 platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
In reply to Chris Taraszkabitland_mifs_wmi_suspend() returns the laptop_profile_get() error to the PM core, which aborts the whole system suspend. This happens on any machine whose firmware reports a SystemPerMode value that is missing from its profile table, and on such a laptop with the lid closed logind keeps retrying the suspend, so the machine stays awake and drains its battery.
bitland_mifs_wmi_resume() likewise returns any error other than -EOPNOTSUPP from restoring the profile, so the resume is reported as failed although the machine is fully usable.
Saving and restoring the platform profile is best effort. Warn and continue instead of failing the system transition, and skip the restore when nothing was saved, so resume does not write a stale or default profile.
---
Notes:
Tested on the same machine with v13 and this patch, without patch 1, and the firmware in 0x04. v13 alone aborts a pm_test=devices suspend:
bitland_mifs_wmi_suspend [bitland_mifs_wmi] returns -22
PM: failed to suspend: error -22
With this patch the suspend completes, "Failed to save platform
profile: -22" is logged and the firmware is still in 0x04 after resume.
This supersedes "platform/x86: bitland-mifs-wmi: Don't abort suspend when platform profile access fails" [1], reworked on top of v13 6/7.
[1] https://lore.kernel.org/all/[email protected]/
drivers/platform/x86/bitland-mifs-wmi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +15 -7
@@ -237,6 +237,7 @@ struct bitland_mifs_wmi_data {struct device *pp_dev;const struct bitland_mifs_quirks *quirks;enum platform_profile_option saved_profile; +bool profile_saved; }; static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -408,10 +409,15 @@ static int bitland_mifs_wmi_suspend(struct device *dev)return 0 ; ret =laptop_profile_get (data->pp_dev, &profile); -if (ret ==0 ) - data->saved_profile = profile; + data->profile_saved = !ret; +if (ret) { +dev_warn (dev,"Failed to save platform profile: %d\n" , ret); +return 0 ; + } -return ret; + data->saved_profile = profile; + +return 0 ; }static int bitland_mifs_wmi_resume (struct device *dev)
@@ -419,8 +425,8 @@ static int bitland_mifs_wmi_resume(struct device *dev)struct bitland_mifs_wmi_data *data =dev_get_drvdata (dev);int ret; -/* Skip event device */ -if (!data->pp_dev) +/* Skip event device, or nothing was saved on suspend */ +if (!data->pp_dev || !data->profile_saved)return 0 ; ret =laptop_profile_set (dev, data->saved_profile);
@@ -436,8 +442,10 @@ static int bitland_mifs_wmi_resume(struct device *dev) } } -dev_dbg (dev,"Resuming, restoring profile %d\n" , data->saved_profile); -return ret; +if (ret) +dev_warn (dev,"Failed to restore platform profile: %d\n" , ret); + +return 0 ; } static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops,
Signature · 1 line
2.56.0
Re: [PATCH v2 2/2] platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
Quoted 53 lines · Chris Taraszka
bitland_mifs_wmi_suspend()returns thelaptop_profile_get()error to the PM core, which aborts the whole system suspend. This happens on any machine whose firmware reports a SystemPerMode value that is missing from its profile table, and on such a laptop with the lid closed logind keeps retrying the suspend, so the machine stays awake and drains its battery.
bitland_mifs_wmi_resume()likewise returns any error other than-EOPNOTSUPPfrom restoring the profile, so the resume is reported as failed although the machine is fully usable.Saving and restoring the platform profile is best effort. Warn and continue instead of failing the system transition, and skip the restore when nothing was saved, so resume does not write a stale or default profile.
Fixes dc1ec4fa86b2 ("platform/x86: bitland-mifs-wmi: Add new Bitland MIFS WMI driver")Signed-off-by Chris Taraszka <[email protected]>---
Notes:
Tested on the same machine with v13 and this patch, without patch 1, and the firmware in0x04. v13 alone aborts a pm_test=devices suspend:
bitland_mifs_wmi_suspend[bitland_mifs_wmi] returns -22
PM: failed to suspend: error -22With this patch the suspend completes, "Failed to save platform
profile: -22" is logged and the firmware is still in0x04after resume.This supersedes "platform/x86: bitland-mifs-wmi: Don't abort suspend when platform profile access fails" [1], reworked on top of v13 6/7.
[1] https://lore.kernel.org/all/[email protected]/
drivers/platform/x86/bitland-mifs-wmi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)drivers/platform/x86/bitland-mifs-wmi.c +1
-0@@ -237,6 +237,7 @@ struct bitland_mifs_wmi_data {struct device *pp_dev;const struct bitland_mifs_quirks *quirks;enum platform_profile_option saved_profile; +bool profile_saved; }; static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,@@ -408,10 +409,15 @@ static int bitland_mifs_wmi_suspend(struct device *dev)return 0 ;
drivers/platform/x86/bitland-mifs-wmi.c static int bitland_mifs_wmi_suspend(struct device *dev) · line 414
Quoted 10 lines
drivers/platform/x86/bitland-mifs-wmi.c +5
-3ret =laptop_profile_get (data->pp_dev, &profile); -if (ret ==0 ) - data->saved_profile = profile; + data->profile_saved = !ret; +if (ret) { +dev_warn (dev,"Failed to save platform profile: %d\n" , ret); +return 0 ; + } -return ret;
What value does the firmware respond?
This patch fixes the suspend problem, but it hides the real driver problem (unsupported profile entry).
I saw 0x04 in your patch "platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk".
If result.data[0] in laptop_profile_get actually equals 0x04, the function should be succeed, but it doesn't.
Is there another no_set (for read only) profile entry for the performance profile?
Quoted 30 lines
drivers/platform/x86/bitland-mifs-wmi.c +9
-4+ data->saved_profile = profile; + +return 0 ; }static int bitland_mifs_wmi_resume (struct device *dev)@@ -419,8 +425,8 @@ static int bitland_mifs_wmi_resume(struct device *dev)struct bitland_mifs_wmi_data *data =dev_get_drvdata (dev);int ret; -/* Skip event device */ -if (!data->pp_dev) +/* Skip event device, or nothing was saved on suspend */ +if (!data->pp_dev || !data->profile_saved)return 0 ; ret =laptop_profile_set (dev, data->saved_profile);@@ -436,8 +442,10 @@ static int bitland_mifs_wmi_resume(struct device *dev) } } -dev_dbg (dev,"Resuming, restoring profile %d\n" , data->saved_profile); -return ret; +if (ret) +dev_warn (dev,"Failed to restore platform profile: %d\n" , ret); + +return 0 ; } static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops,
Re: [PATCH v2 2/2] platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
Quoted 10 lines · Mingyou Chen
What value does the firmware respond?
This patch fixes the suspend problem, but it hides the real driver problem (unsupported profile entry).
I saw
0x04in your patch "platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk".If result.data[0] in
laptop_profile_getactually equals0x04, the function should be succeed, but it doesn't.
Hi Mingyou,
It does succeed with patch 1. The firmware returns 0x04 (I also read it back from EC 0x68), and with the TM2424 entry laptop_profile_get() maps it to performance. Since then the machine has suspended and resumed several times without the warning.
The test in the notes was run without patch 1 on purpose, on the v13 default table, where 0x04 is not listed. That is the state of every Bitland machine that has no entry yet: the TM2424 before patch 1, the TM2107 before Matias' patch, and whatever model comes next. On those, the aborted suspend is what users hit first. Before I knew the mode values, logind retried the suspend every 15 seconds with the lid closed, and the laptop drained about 40 Wh in one night.
Quoted 2 lines
Is there another
no_set(for read only) profile entry for the performance profile?
No. GET only ever returned 0x02, 0x03, 0x04, 0x09 and 0x0a here, and all five are in the table.
So patch 2 does not hide a problem on this machine. On a machine without an entry it keeps suspend working, and the "Failed to save platform profile" warning still shows that the table needs an entry.
Thanks for the review of patch 1.
Chris
Mingyou Chen
Reviewed-byRe: [PATCH v2 2/2] platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
Quoted 6 lines · Chris Taraszka
Quoted 5 lines · Mingyou Chen
What value does the firmware respond?
This patch fixes the suspend problem, but it hides the real driver problem (unsupported profile entry).
Quoted 8 lines
Quoted 5 lines
I saw
0x04in your patch "platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk".If result.data[0] in
laptop_profile_getactually equals0x04, the function should be succeed, but it doesn't.Hi Mingyou,
It does succeed with patch 1. The firmware returns
0x04(I also read it
Apologies, I misunderstood; I assume the "patch 1" you referred to is the one that adds the MAINTAINERS entries
of my v13.
Quoted 11 lines
back from EC
0x68), and with the TM2424 entrylaptop_profile_get()maps it to performance. Since then the machine has suspended and resumed several times without the warning.The test in the notes was run without patch 1 on purpose, on the v13 default table, where
0x04is not listed. That is the state of every Bitland machine that has no entry yet: the TM2424 before patch 1, the TM2107 before Matias' patch, and whatever model comes next. On those, the aborted suspend is what users hit first. Before I knew the mode values, logind retried the suspend every 15 seconds with the lid closed, and the laptop drained about 40 Wh in one night.
This is a good point, so
Quoted 12 lines
Quoted 2 lines
Is there another
no_set(for read only) profile entry for the performance profile?No. GET only ever returned
0x02,0x03,0x04,0x09and0x0ahere, and all five are in the table.So patch 2 does not hide a problem on this machine. On a machine without an entry it keeps suspend working, and the "Failed to save platform profile" warning still shows that the table needs an entry.
Thanks for the review of patch 1.
Chris
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Kento,
Quoted 2 lines · KentoNion
0x03is Turbo, not balanced. This board has no balanced-performance.0x09is the firmware's normal mode.
You are right, thanks. The DTT tables in the firmware's data vault show the same: on battery 0x03 is Turbo at 50-58 W, and 0x04 has no battery entry. With v2, balanced on battery ran at 54 W.
v3 maps low-power, balanced and performance to 0x02, 0x09 and 0x04, and uses 0x03 for performance on battery:
https://lore.kernel.org/all/[email protected]/
Thanks,
Chris
Quoted 33 lines · KentoNion
Hi Chris,
Quoted 1 line · Chris Taraszka
Kento, if this is a problem on BIOS 0707 or 0A0A, please say so.
Yes. On XMAPT4B0P0707, SET
0x04is rejected on battery. The supply check refuses balanced-performance and performance before the firmware is asked, so0x03is unreachable on battery as well. On XMAPT4B0P0A0A the SET status is success for every write, so that status cannot show a rejected mode. Your 0A0A test on AC shows the following GET is the value that actually stuck. Keep0x04only when that GET returns0x04, and otherwise SET0x03. The supply check is not needed for that.The map we use on TM2424 is:
low-power SET
0x0AGET 0x0A or 0x02 balanced SET 0x09 performance SET 0x04, or 0x03 when the following GET is not 0x04 GET 0x04 or 0x03
0x02and0x0Aare both about 18 W.0x0Aalso dims the panel and the keyboard backlight, so that is the low-power write.0x02is only a read alias.0x03is Turbo, not balanced. This board has no balanced-performance.0x09is the firmware's normal mode.The quirks entry is the right place for this. I am not sending another copy of the patch.
Thanks,
Kento