]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2024 13:34:07 +0000 (15:34 +0200)
[ Upstream commit fc6e0837264a8b2504b6160e63ec92eb012540f3 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpufreq/amd-pstate.c
drivers/cpufreq/amd-pstate.h

index a092b13ffbc2f9030a1ceb2a82c4db7a23b9347e..874ee90b1cf101626279513b0ce161bb3650253e 100644 (file)
@@ -304,10 +304,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];
@@ -1439,7 +1437,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 */