platform/x86: thinkpad_acpi: Remove AMT enablement
PATCH 1/1 platform/x86: thinkpad_acpi: Remove AMT enablement
Recently AMT mode was enabled (somewhat unexpectedly) on the Lenovo Z13 platform. The FW is advertising it is available and the driver tries to use it - unfortunately it reports the profile mode incorrectly.
Note, there is also some extra work needed to enable the dynamic aspect of AMT support that I will be following up with; but more testing is needed first. This patch just fixes things so the profiles are reported correctly.
--- drivers/platform/x86/thinkpad_acpi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +17 -6
@@ -10311,9 +10311,11 @@ static DEFINE_MUTEX(dytc_mutex);static int dytc_capabilities;static bool dytc_mmc_get_available; -static int convert_dytc_to_profile (int dytcmode,enum platform_profile_option *profile) +static int convert_dytc_to_profile (int funcmode,int dytcmode, +enum platform_profile_option *profile) { -if (dytc_capabilities &BIT (DYTC_FC_MMC )) { +switch (funcmode) { +case DYTC_FUNCTION_MMC :switch (dytcmode) {case DYTC_MODE_MMC_LOWPOWER : *profile =PLATFORM_PROFILE_LOW_POWER ;
@@ -10329,8 +10331,7 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *preturn -EINVAL ; }return 0 ; - } -if (dytc_capabilities &BIT (DYTC_FC_PSC )) { +case DYTC_FUNCTION_PSC :switch (dytcmode) {case DYTC_MODE_PSC_LOWPOWER : *profile =PLATFORM_PROFILE_LOW_POWER ;
@@ -10344,6 +10345,14 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *pdefault :/* Unknown mode */ return -EINVAL ; } +return 0 ; +case DYTC_FUNCTION_AMT : +/* For now return balanced. It's the closest we have to 'auto' */ + *profile =PLATFORM_PROFILE_BALANCED ; +return 0 ; +default : +/* Unknown function */ +return -EOPNOTSUPP ; }return 0 ; }
@@ -10492,6 +10501,7 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, err =dytc_command (DYTC_SET_COMMAND (DYTC_FUNCTION_PSC , perfmode,1 ), &output);if (err) goto unlock; +/* system supports AMT, activate it when on balanced */ if (dytc_capabilities &BIT (DYTC_FC_AMT ))dytc_control_amt (profile ==PLATFORM_PROFILE_BALANCED );
@@ -10507,7 +10517,7 @@ static void dytc_profile_refresh(void) {enum platform_profile_option profile;int output, err =0 ; -int perfmode; +int perfmode, funcmode;mutex_lock (&dytc_mutex);if (dytc_capabilities &BIT (DYTC_FC_MMC )) {
@@ -10522,8 +10532,9 @@ static void dytc_profile_refresh(void)if (err)return ; + funcmode = (output >>DYTC_GET_FUNCTION_BIT ) &0xF ; perfmode = (output >>DYTC_GET_MODE_BIT ) &0xF ; -convert_dytc_to_profile (perfmode, &profile); +convert_dytc_to_profile (funcmode, perfmode, &profile);if (profile != dytc_current_profile) { dytc_current_profile = profile;platform_profile_notify ();
Signature · 1 line
2.39.0
[Public]
Quoted 9 lines
-----Original Message-----
From: Mark Pearson <[email protected]>
Sent: Thursday, January 12, 2023 14:45
To: [email protected]
Cc: [email protected]; Limonciello, Mario <[email protected]>; [email protected]; platform-driver- [email protected]
Subject: [PATCH] platform/x86:thinkpad_acpi: Remove AMT enablement
This title really isn't accurate is it? AMT is still there, it's really more of a bug fix for reporting the right profiles when AMT is active (which should be balanced).
Quoted 10 lines
Recently AMT mode was enabled (somewhat unexpectedly) on the Lenovo Z13 platform. The FW is advertising it is available and the driver tries to use it - unfortunately it reports the profile mode incorrectly.
Note, there is also some extra work needed to enable the dynamic aspect of AMT support that I will be following up with; but more testing is needed first. This patch just fixes things so the profiles are reported correctly.
Signed-off-by Mark Pearson <[email protected]>
With the title fixed.
Suggest this to Cc to 6.1-stable as well as it's fixing a power profile reporting bug.
Quoted 86 lines
--- drivers/platform/x86/thinkpad_acpi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)drivers/platform/x86/thinkpad_acpi.c +4
-2@@ -10311,9 +10311,11 @@ static DEFINE_MUTEX(dytc_mutex);static int dytc_capabilities;static bool dytc_mmc_get_available; -static int convert_dytc_to_profile (int dytcmode,enum platform_profile_option *profile) +static int convert_dytc_to_profile (int funcmode,int dytcmode, +enum platform_profile_option *profile) { -if (dytc_capabilities &BIT (DYTC_FC_MMC )) { +switch (funcmode) { +case DYTC_FUNCTION_MMC :switch (dytcmode) {case DYTC_MODE_MMC_LOWPOWER :drivers/platform/x86/thinkpad_acpi.c +0
-0*profile =PLATFORM_PROFILE_LOW_POWER ;@@ -10329,8 +10331,7 @@ static int convert_dytc_to_profile(int dytcmode,enum
platform_profile_option*pdrivers/platform/x86/thinkpad_acpi.c +1
-2return -EINVAL ; }return 0 ; - } -if (dytc_capabilities &BIT (DYTC_FC_PSC )) { +case DYTC_FUNCTION_PSC :switch (dytcmode) {case DYTC_MODE_PSC_LOWPOWER : *profile =PLATFORM_PROFILE_LOW_POWER ;@@ -10344,6 +10345,14 @@ static int convert_dytc_to_profile(int dytcmode,enum
platform_profile_option*pdrivers/platform/x86/thinkpad_acpi.c +3
-0default :/* Unknown mode */ return -EINVAL ; } +return 0 ; +case DYTC_FUNCTION_AMT : +/* For now return balanced. It's the closest we have to 'auto' */
drivers/platform/x86/thinkpad_acpi.c +6
-0+ *profile =PLATFORM_PROFILE_BALANCED ; +return 0 ; +default : +/* Unknown function */ +return -EOPNOTSUPP ; }return 0 ; }@@ -10492,6 +10501,7 @@ static int dytc_profile_set(structplatform_profile_handler *pprof, err =dytc_command (DYTC_SET_COMMAND (DYTC_FUNCTION_PSC , perfmode,1 ), &output);if (err) goto unlock; +drivers/platform/x86/thinkpad_acpi.c +0
-0/* system supports AMT, activate it when on balanced */ if (dytc_capabilities &BIT (DYTC_FC_AMT )) dytc_control_amt(profile ==
PLATFORM_PROFILE_BALANCED);drivers/platform/x86/thinkpad_acpi.c +3
-3@@ -10507,7 +10517,7 @@ static void dytc_profile_refresh(void) {enum platform_profile_option profile;int output, err =0 ; -int perfmode; +int perfmode, funcmode;mutex_lock (&dytc_mutex);if (dytc_capabilities &BIT (DYTC_FC_MMC )) {@@ -10522,8 +10532,9 @@ static void dytc_profile_refresh(void)if (err)return ; + funcmode = (output >>DYTC_GET_FUNCTION_BIT ) &0xF ; perfmode = (output >>DYTC_GET_MODE_BIT ) &0xF ; -convert_dytc_to_profile (perfmode, &profile); +convert_dytc_to_profile (funcmode, perfmode, &profile);if (profile != dytc_current_profile) { dytc_current_profile = profile;platform_profile_notify (); --2.39.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · Mark Pearson
Quoted 16 lines · Mario
[Public]
Quoted 2 lines
-----Original Message-----
From: Mark Pearson <[email protected]<mailto:[email protected]>>
Quoted 4 lines
Sent: Thursday, January 12, 2023 14:45
To: [email protected] <mailto:[email protected]>
Cc: [email protected] <mailto:[email protected]>; Limonciello, Mario <[email protected] <mailto:[email protected]>>;[email protected] <mailto:[email protected]>; platform-driver-
Quoted 3 lines
[email protected] <mailto:[email protected]>
Subject: [PATCH] platform/x86:thinkpad_acpi: Remove AMT enablement
Quoted 6 lines
Quoted 2 lines
This title really isn't accurate is it? AMT is still there, it's really more of a bug fix for reporting the right profiles when AMT is active (which should be balanced).
Shoot my bad. I did two versions of the patch - one to remove the feature, and one to fix it.
I did some testing and the results from the fix version were better so I updated my commit message....and missed the title. I'm an idiot.I assume I should resend the patch with the correct title?
Probably best to do.
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Recently AMT mode was enabled (somewhat unexpectedly) on the Lenovo Z13 platform. The FW is advertising it is available and the driver tries to use it - unfortunately it reports the profile mode incorrectly.
Note, there is also some extra work needed to enable the dynamic aspect of AMT support that I will be following up with; but more testing is needed first. This patch just fixes things so the profiles are reported correctly.
Signed-off-by Mark Pearson <[email protected]<mailto:[email protected]>>
Quoted 8 lines
Quoted 5 lines
With the title fixed.
Reviewed-by Mario Limonciello <[email protected] <mailto:[email protected]>>Suggest this to Cc to 6.1-stable as well as it's fixing a power profile reporting bug.
Ah - I was going to propose it to stable once it was reviewed and accepted. Is it normal to do that on the first pass?
Mark
You can do it both ways.
https://www.kernel.org/doc/html/next/process/stable-kernel-rules.html
I was suggesting method 1 since this is a bug fix.
When you submit V2, some other things you should add (besides my tag and fix the title):