未验证 提交 f1189855 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!849 drivers/cpufreq: gain accurate CPU frequency from cpufreq/cpuinfo_cur_freq

Merge Pull Request from: @henryze 
 
When users want to get frequency by cpuinfo_cur_freq under cpufreq sysfs,
they often get the invalid result like:

$ cat /sys/devices/system/cpu/cpu6/cpufreq/cpuinfo_cur_freq
4294967295

So this series provides fixes to the concerned issue.

Reference: https://lore.kernel.org/all/20230516133248.712242-3-zengheng4@huawei.com/ 
 
Link:https://gitee.com/openeuler/kernel/pulls/849 

Reviewed-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> 
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> 
......@@ -488,7 +488,7 @@ CONFIG_AS_HAS_CFI_NEGATE_RA_STATE=y
#
# ARMv8.4 architectural features
#
# CONFIG_ARM64_AMU_EXTN is not set
CONFIG_ARM64_AMU_EXTN=y
CONFIG_AS_HAS_ARMV8_4=y
CONFIG_ARM64_TLB_RANGE=y
# end of ARMv8.4 architectural features
......
......@@ -1588,6 +1588,7 @@ bool cpu_has_amu_feat(int cpu)
{
return cpumask_test_cpu(cpu, &amu_cpus);
}
EXPORT_SYMBOL(cpu_has_amu_feat);
int get_cpu_with_amu_feat(void)
{
......
......@@ -350,23 +350,37 @@ static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu,
return cppc_cpufreq_perf_to_khz(cpu, delivered_perf);
}
static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum)
static int cppc_get_perf_ctrs_sample(void *val)
{
struct cppc_perf_fb_ctrs fb_ctrs_t0 = {0}, fb_ctrs_t1 = {0};
struct cppc_cpudata *cpu = all_cpu_data[cpunum];
int cpunum = smp_processor_id();
struct cppc_perf_fb_ctrs *fb_ctrs = val;
int ret;
ret = cppc_get_perf_ctrs(cpunum, &fb_ctrs_t0);
ret = cppc_get_perf_ctrs(cpunum, fb_ctrs);
if (ret)
return ret;
udelay(2); /* 2usec delay between sampling */
ret = cppc_get_perf_ctrs(cpunum, &fb_ctrs_t1);
return cppc_get_perf_ctrs(cpunum, fb_ctrs + 1);
}
static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum)
{
struct cppc_perf_fb_ctrs fb_ctrs[2] = {0};
struct cppc_cpudata *cpu = all_cpu_data[cpunum];
int ret;
if (cpu_has_amu_feat(cpunum))
ret = smp_call_on_cpu(cpunum, cppc_get_perf_ctrs_sample,
fb_ctrs, false);
else
ret = cppc_get_perf_ctrs_sample(fb_ctrs);
if (ret)
return ret;
return cppc_get_rate_from_fbctrs(cpu, fb_ctrs_t0, fb_ctrs_t1);
return cppc_get_rate_from_fbctrs(cpu, fb_ctrs[0], fb_ctrs[1]);
}
static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册