Skip to content

Commit 3a0a399

Browse files
committed
[FROM-ML] platform/x86: asus-armoury: gate PPT writes behind active fan curve
On models flagged with requires_fan_curve in the DMI power_data table (30 entries), the BIOS ACPI method SPLX only writes PPT values to the EC when the fan mode is set to Manual (FANM=4). FANM is set to 4 by the DEFC method when a custom fan curve is written. Without an active custom fan curve, the WMI DEVS call returns success but the firmware silently ignores the PPT value, so userspace observes no effect from its write. Gate writes to ASUS_WMI_DEVID_PPT_{PL1_SPL,PL2_SPPT,PL3_FPPT,APU_SPPT, PLAT_SPPT} on a check of asus_wmi_custom_fan_curve_is_enabled(), and return -EBUSY with a pr_warn_once() when no fan curve is active on an affected model. Export the helper from asus-wmi so asus-armoury can call it across module boundaries. Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
1 parent dcad54d commit 3a0a399

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

drivers/platform/x86/asus-armoury.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ struct asus_armoury_priv {
9393

9494
u32 mini_led_dev_id;
9595
u32 gpu_mux_dev_id;
96+
97+
bool requires_fan_curve;
9698
};
9799

98100
static struct asus_armoury_priv asus_armoury = {
@@ -216,6 +218,22 @@ static int armoury_set_devstate(struct kobj_attribute *attr,
216218
u32 result;
217219
int err;
218220

221+
/* On some models, PPT changes require an active fan curve */
222+
if (asus_armoury.requires_fan_curve) {
223+
switch (dev_id) {
224+
case ASUS_WMI_DEVID_PPT_PL1_SPL:
225+
case ASUS_WMI_DEVID_PPT_PL2_SPPT:
226+
case ASUS_WMI_DEVID_PPT_PL3_FPPT:
227+
case ASUS_WMI_DEVID_PPT_APU_SPPT:
228+
case ASUS_WMI_DEVID_PPT_PLAT_SPPT:
229+
if (!asus_wmi_custom_fan_curve_is_enabled()) {
230+
pr_warn_once("PPT change requires an active fan curve on this model. Enable a custom fan curve first.\n");
231+
return -EBUSY;
232+
}
233+
break;
234+
}
235+
}
236+
219237
/*
220238
* Prevent developers from bricking devices or issuing dangerous
221239
* commands that can be difficult or impossible to recover from.
@@ -1002,6 +1020,8 @@ static void init_rog_tunables(void)
10021020
return;
10031021
}
10041022

1023+
asus_armoury.requires_fan_curve = power_data->requires_fan_curve;
1024+
10051025
/* Initialize AC power tunables */
10061026
ac_limits = power_data->ac_data;
10071027
if (ac_limits) {

drivers/platform/x86/asus-wmi.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,6 +3999,30 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
39993999
return 0;
40004000
}
40014001

4002+
/*
4003+
* Returns true if at least one custom fan curve is active
4004+
*
4005+
* Used by asus-armoury to check if PPT writes will be accepted by the BIOS
4006+
* on models that require an active fan curve for TDP changes.
4007+
*/
4008+
bool asus_wmi_custom_fan_curve_is_enabled(void)
4009+
{
4010+
struct fan_curve_data *curves;
4011+
struct asus_wmi *asus;
4012+
4013+
guard(spinlock_irqsave)(&asus_ref.lock);
4014+
asus = asus_ref.asus;
4015+
if (!asus)
4016+
return false;
4017+
4018+
curves = asus->custom_fan_curves;
4019+
4020+
return (asus->cpu_fan_curve_available && curves[FAN_CURVE_DEV_CPU].enabled) ||
4021+
(asus->gpu_fan_curve_available && curves[FAN_CURVE_DEV_GPU].enabled) ||
4022+
(asus->mid_fan_curve_available && curves[FAN_CURVE_DEV_MID].enabled);
4023+
}
4024+
EXPORT_SYMBOL_NS_GPL(asus_wmi_custom_fan_curve_is_enabled, "ASUS_WMI");
4025+
40024026
/* Throttle thermal policy ****************************************************/
40034027
static int throttle_thermal_policy_write(struct asus_wmi *asus)
40044028
{

include/linux/platform_data/x86/asus-wmi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval);
196196
int asus_hid_register_listener(struct asus_hid_listener *cdev);
197197
void asus_hid_unregister_listener(struct asus_hid_listener *cdev);
198198
int asus_hid_event(enum asus_hid_event event);
199+
bool asus_wmi_custom_fan_curve_is_enabled(void);
199200
#else
200201
static inline void set_ally_mcu_hack(enum asus_ally_mcu_hack status)
201202
{
@@ -227,6 +228,10 @@ static inline int asus_hid_event(enum asus_hid_event event)
227228
{
228229
return -ENODEV;
229230
}
231+
static inline bool asus_wmi_custom_fan_curve_is_enabled(void)
232+
{
233+
return false;
234+
}
230235
#endif
231236

232237
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */

0 commit comments

Comments
 (0)