Skip to content

Commit fde5f74

Browse files
mrhpearsonjwrdegoede
authored andcommitted
platform/x86: thinkpad_acpi: Fix profile mode display in AMT mode
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. Link: https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/115 Fixes: 46dcbc6 ("platform/x86: thinkpad-acpi: Add support for automatic mode transitions") Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Mark Pearson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent cf5ac2d commit fde5f74

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10311,9 +10311,11 @@ static DEFINE_MUTEX(dytc_mutex);
1031110311
static int dytc_capabilities;
1031210312
static bool dytc_mmc_get_available;
1031310313

10314-
static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *profile)
10314+
static int convert_dytc_to_profile(int funcmode, int dytcmode,
10315+
enum platform_profile_option *profile)
1031510316
{
10316-
if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
10317+
switch (funcmode) {
10318+
case DYTC_FUNCTION_MMC:
1031710319
switch (dytcmode) {
1031810320
case DYTC_MODE_MMC_LOWPOWER:
1031910321
*profile = PLATFORM_PROFILE_LOW_POWER;
@@ -10329,8 +10331,7 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *p
1032910331
return -EINVAL;
1033010332
}
1033110333
return 0;
10332-
}
10333-
if (dytc_capabilities & BIT(DYTC_FC_PSC)) {
10334+
case DYTC_FUNCTION_PSC:
1033410335
switch (dytcmode) {
1033510336
case DYTC_MODE_PSC_LOWPOWER:
1033610337
*profile = PLATFORM_PROFILE_LOW_POWER;
@@ -10344,6 +10345,14 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *p
1034410345
default: /* Unknown mode */
1034510346
return -EINVAL;
1034610347
}
10348+
return 0;
10349+
case DYTC_FUNCTION_AMT:
10350+
/* For now return balanced. It's the closest we have to 'auto' */
10351+
*profile = PLATFORM_PROFILE_BALANCED;
10352+
return 0;
10353+
default:
10354+
/* Unknown function */
10355+
return -EOPNOTSUPP;
1034710356
}
1034810357
return 0;
1034910358
}
@@ -10492,6 +10501,7 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
1049210501
err = dytc_command(DYTC_SET_COMMAND(DYTC_FUNCTION_PSC, perfmode, 1), &output);
1049310502
if (err)
1049410503
goto unlock;
10504+
1049510505
/* system supports AMT, activate it when on balanced */
1049610506
if (dytc_capabilities & BIT(DYTC_FC_AMT))
1049710507
dytc_control_amt(profile == PLATFORM_PROFILE_BALANCED);
@@ -10507,7 +10517,7 @@ static void dytc_profile_refresh(void)
1050710517
{
1050810518
enum platform_profile_option profile;
1050910519
int output, err = 0;
10510-
int perfmode;
10520+
int perfmode, funcmode;
1051110521

1051210522
mutex_lock(&dytc_mutex);
1051310523
if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
@@ -10522,8 +10532,9 @@ static void dytc_profile_refresh(void)
1052210532
if (err)
1052310533
return;
1052410534

10535+
funcmode = (output >> DYTC_GET_FUNCTION_BIT) & 0xF;
1052510536
perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF;
10526-
convert_dytc_to_profile(perfmode, &profile);
10537+
convert_dytc_to_profile(funcmode, perfmode, &profile);
1052710538
if (profile != dytc_current_profile) {
1052810539
dytc_current_profile = profile;
1052910540
platform_profile_notify();

0 commit comments

Comments
 (0)