]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq: amd-pstate: Allow users to write 'default' EPP string
authorMario Limonciello <mario.limonciello@amd.com>
Wed, 12 Jun 2024 14:20:49 +0000 (09:20 -0500)
committerMario Limonciello <mario.limonciello@amd.com>
Fri, 21 Jun 2024 02:52:05 +0000 (21:52 -0500)
The EPP string for 'default' represents what the firmware had configured
as the default EPP value but once a user changes EPP to another string
they can't reset it back to 'default'.

Cache the firmware EPP value and allow the user to write 'default' using
this value.

Reported-by: Artem S. Tashkinov <aros@gmx.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61
Reviewed-by: Perry Yuan <perry.yuan@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
drivers/cpufreq/amd-pstate.c
drivers/cpufreq/amd-pstate.h

index fda8f86c90e01ddb1fbbc73413927bd72267ada2..5bdcdd3ea163bf1d787e811b4d76f1ec48a8fb2c 100644 (file)
@@ -282,10 +282,8 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
        int epp = -EINVAL;
        int ret;
 
-       if (!pref_index) {
-               pr_debug("EPP pref_index is invalid\n");
-               return -EINVAL;
-       }
+       if (!pref_index)
+               epp = cpudata->epp_default;
 
        if (epp == -EINVAL)
                epp = epp_values[pref_index];
@@ -1441,7 +1439,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
 
        policy->driver_data = cpudata;
 
-       cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0);
+       cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata, 0);
 
        policy->min = policy->cpuinfo.min_freq;
        policy->max = policy->cpuinfo.max_freq;
index e6a28e7f4dbf12a5ef4a86e2f966c2b454fc420f..f80b33fa5d43a12f23fd3c83a07dd464c528c3d7 100644 (file)
@@ -99,6 +99,7 @@ struct amd_cpudata {
        u32     policy;
        u64     cppc_cap1_cached;
        bool    suspended;
+       s16     epp_default;
 };
 
 #endif /* _LINUX_AMD_PSTATE_H */