Skip to content

Commit 1c00bb7

Browse files
Wer-Wolfgregkh
authored andcommitted
platform/x86: asus-wmi: Fix inconsistent use of thermal policies
[ Upstream commit 895085e ] When changing the thermal policy using the platform profile API, a Vivobook thermal policy is stored in throttle_thermal_policy_mode. However everywhere else a normal thermal policy is stored inside this variable, potentially confusing the platform profile. Fix this by always storing normal thermal policy values inside throttle_thermal_policy_mode and only do the conversion when writing the thermal policy to hardware. This also fixes the order in which throttle_thermal_policy_switch_next() steps through the thermal modes on Vivobook machines. Tested-by: Casey G Bowman <[email protected]> Fixes: bcbfceb ("platform/x86: asus-wmi: add support for vivobook fan profiles") Signed-off-by: Armin Wolf <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3d48d0f commit 1c00bb7

File tree

1 file changed

+21
-43
lines changed

1 file changed

+21
-43
lines changed

drivers/platform/x86/asus-wmi.c

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,10 +3696,28 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
36963696
/* Throttle thermal policy ****************************************************/
36973697
static int throttle_thermal_policy_write(struct asus_wmi *asus)
36983698
{
3699-
u8 value = asus->throttle_thermal_policy_mode;
37003699
u32 retval;
3700+
u8 value;
37013701
int err;
37023702

3703+
if (asus->throttle_thermal_policy_dev == ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO) {
3704+
switch (asus->throttle_thermal_policy_mode) {
3705+
case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
3706+
value = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT_VIVO;
3707+
break;
3708+
case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST:
3709+
value = ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST_VIVO;
3710+
break;
3711+
case ASUS_THROTTLE_THERMAL_POLICY_SILENT:
3712+
value = ASUS_THROTTLE_THERMAL_POLICY_SILENT_VIVO;
3713+
break;
3714+
default:
3715+
return -EINVAL;
3716+
}
3717+
} else {
3718+
value = asus->throttle_thermal_policy_mode;
3719+
}
3720+
37033721
err = asus_wmi_set_devstate(asus->throttle_thermal_policy_dev,
37043722
value, &retval);
37053723

@@ -3804,46 +3822,6 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
38043822
static DEVICE_ATTR_RW(throttle_thermal_policy);
38053823

38063824
/* Platform profile ***********************************************************/
3807-
static int asus_wmi_platform_profile_to_vivo(struct asus_wmi *asus, int mode)
3808-
{
3809-
bool vivo;
3810-
3811-
vivo = asus->throttle_thermal_policy_dev == ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO;
3812-
3813-
if (vivo) {
3814-
switch (mode) {
3815-
case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
3816-
return ASUS_THROTTLE_THERMAL_POLICY_DEFAULT_VIVO;
3817-
case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST:
3818-
return ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST_VIVO;
3819-
case ASUS_THROTTLE_THERMAL_POLICY_SILENT:
3820-
return ASUS_THROTTLE_THERMAL_POLICY_SILENT_VIVO;
3821-
}
3822-
}
3823-
3824-
return mode;
3825-
}
3826-
3827-
static int asus_wmi_platform_profile_mode_from_vivo(struct asus_wmi *asus, int mode)
3828-
{
3829-
bool vivo;
3830-
3831-
vivo = asus->throttle_thermal_policy_dev == ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO;
3832-
3833-
if (vivo) {
3834-
switch (mode) {
3835-
case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT_VIVO:
3836-
return ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
3837-
case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST_VIVO:
3838-
return ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST;
3839-
case ASUS_THROTTLE_THERMAL_POLICY_SILENT_VIVO:
3840-
return ASUS_THROTTLE_THERMAL_POLICY_SILENT;
3841-
}
3842-
}
3843-
3844-
return mode;
3845-
}
3846-
38473825
static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof,
38483826
enum platform_profile_option *profile)
38493827
{
@@ -3853,7 +3831,7 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof,
38533831
asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
38543832
tp = asus->throttle_thermal_policy_mode;
38553833

3856-
switch (asus_wmi_platform_profile_mode_from_vivo(asus, tp)) {
3834+
switch (tp) {
38573835
case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
38583836
*profile = PLATFORM_PROFILE_BALANCED;
38593837
break;
@@ -3892,7 +3870,7 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof,
38923870
return -EOPNOTSUPP;
38933871
}
38943872

3895-
asus->throttle_thermal_policy_mode = asus_wmi_platform_profile_to_vivo(asus, tp);
3873+
asus->throttle_thermal_policy_mode = tp;
38963874
return throttle_thermal_policy_write(asus);
38973875
}
38983876

0 commit comments

Comments
 (0)