Skip to content

Commit 24ad4c6

Browse files
Sumit Guptarafaeljw
authored andcommitted
cpufreq: CPPC: Update cached perf_ctrls on sysfs write
Update the cached perf_ctrls values when writing via sysfs to keep them in sync with hardware registers: - store_auto_select(): update perf_ctrls.auto_sel - store_energy_performance_preference_val(): update perf_ctrls.energy_perf This ensures consistent cached values after sysfs writes, which complements the cppc_get_perf() initialization during policy setup. Signed-off-by: Sumit Gupta <sumitg@nvidia.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com> Link: https://patch.msgid.link/20260206142658.72583-5-sumitg@nvidia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 38428a6 commit 24ad4c6

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ static ssize_t show_auto_select(struct cpufreq_policy *policy, char *buf)
855855
static ssize_t store_auto_select(struct cpufreq_policy *policy,
856856
const char *buf, size_t count)
857857
{
858+
struct cppc_cpudata *cpu_data = policy->driver_data;
858859
bool val;
859860
int ret;
860861

@@ -866,6 +867,8 @@ static ssize_t store_auto_select(struct cpufreq_policy *policy,
866867
if (ret)
867868
return ret;
868869

870+
cpu_data->perf_ctrls.auto_sel = val;
871+
869872
return count;
870873
}
871874

@@ -916,8 +919,32 @@ static ssize_t store_##_name(struct cpufreq_policy *policy, \
916919
CPPC_CPUFREQ_ATTR_RW_U64(auto_act_window, cppc_get_auto_act_window,
917920
cppc_set_auto_act_window)
918921

919-
CPPC_CPUFREQ_ATTR_RW_U64(energy_performance_preference_val,
920-
cppc_get_epp_perf, cppc_set_epp)
922+
static ssize_t
923+
show_energy_performance_preference_val(struct cpufreq_policy *policy, char *buf)
924+
{
925+
return cppc_cpufreq_sysfs_show_u64(policy->cpu, cppc_get_epp_perf, buf);
926+
}
927+
928+
static ssize_t
929+
store_energy_performance_preference_val(struct cpufreq_policy *policy,
930+
const char *buf, size_t count)
931+
{
932+
struct cppc_cpudata *cpu_data = policy->driver_data;
933+
u64 val;
934+
int ret;
935+
936+
ret = kstrtou64(buf, 0, &val);
937+
if (ret)
938+
return ret;
939+
940+
ret = cppc_set_epp(policy->cpu, val);
941+
if (ret)
942+
return ret;
943+
944+
cpu_data->perf_ctrls.energy_perf = val;
945+
946+
return count;
947+
}
921948

922949
cpufreq_freq_attr_ro(freqdomain_cpus);
923950
cpufreq_freq_attr_rw(auto_select);

0 commit comments

Comments
 (0)