“d4069fe6fc91d496e4d1fe38b1a8b71aeb181c50”上不存在“...net/ethernet/git@gitcode.net:openanolis/cloud-kernel.git”
提交 4468e738 编写于 作者: T Tang Jinyang 提交者: guzitao

sw64: fix get_cpu_freq() bug

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I56QDM

--------------------------------

The cpu_desc.frequency used to be unmodified in the presence of
CPU frequency scaling, and get_cpu_freq() always return initial
value. It has to maintain a constant correlation to the target
frequency.
Signed-off-by: NTang Jinyang <tangjinyang@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 be3d1f1b
...@@ -44,7 +44,7 @@ struct clk { ...@@ -44,7 +44,7 @@ struct clk {
int clk_init(void); int clk_init(void);
int sw64_set_rate(int index, unsigned long rate); void sw64_set_rate(unsigned long rate);
struct clk *sw64_clk_get(struct device *dev, const char *id); struct clk *sw64_clk_get(struct device *dev, const char *id);
......
...@@ -82,6 +82,13 @@ static inline unsigned long get_cpu_freq(void) ...@@ -82,6 +82,13 @@ static inline unsigned long get_cpu_freq(void)
return cpu_desc.frequency; return cpu_desc.frequency;
} }
static inline void update_cpu_freq(unsigned long freq)
{
freq = freq * 1000000;
if (cpu_desc.frequency != freq)
cpu_desc.frequency = freq;
}
#define EMUL_FLAG (0x1UL << 63) #define EMUL_FLAG (0x1UL << 63)
#define MMSIZE_MASK (EMUL_FLAG - 1) #define MMSIZE_MASK (EMUL_FLAG - 1)
......
...@@ -131,15 +131,17 @@ void sw64_store_policy(struct cpufreq_policy *policy) ...@@ -131,15 +131,17 @@ void sw64_store_policy(struct cpufreq_policy *policy)
} }
EXPORT_SYMBOL_GPL(sw64_store_policy); EXPORT_SYMBOL_GPL(sw64_store_policy);
int sw64_set_rate(int index, unsigned long rate) void sw64_set_rate(unsigned long rate)
{ {
unsigned int i, val; unsigned int i, val;
int index = -1;
rate /= 1000000; rate /= 1000000;
for (i = 0; i < sizeof(cpu_freq)/sizeof(int); i++) { for (i = 0; i < sizeof(cpu_freq)/sizeof(int); i++) {
if (rate == cpu_freq[i]) { if (rate == cpu_freq[i]) {
index = i; index = i;
update_cpu_freq(cpu_freq[i]);
break; break;
} }
} }
...@@ -185,7 +187,5 @@ int sw64_set_rate(int index, unsigned long rate) ...@@ -185,7 +187,5 @@ int sw64_set_rate(int index, unsigned long rate)
/* LV1 select PLL0/PLL1 */ /* LV1 select PLL0/PLL1 */
sw64_io_write(0, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT); sw64_io_write(0, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
sw64_io_write(1, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT); sw64_io_write(1, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
return index;
} }
EXPORT_SYMBOL_GPL(sw64_set_rate); EXPORT_SYMBOL_GPL(sw64_set_rate);
...@@ -68,12 +68,12 @@ static int sw64_cpufreq_target(struct cpufreq_policy *policy, ...@@ -68,12 +68,12 @@ static int sw64_cpufreq_target(struct cpufreq_policy *policy,
{ {
unsigned long freq; unsigned long freq;
freq = (get_cpu_freq() / 1000) * index / 48; freq = 50000 * index;
sw64_store_policy(policy); sw64_store_policy(policy);
/* setting the cpu frequency */ /* setting the cpu frequency */
sw64_set_rate(-1, freq * 1000); sw64_set_rate(freq * 1000);
return 0; return 0;
} }
...@@ -98,7 +98,7 @@ static int sw64_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -98,7 +98,7 @@ static int sw64_cpufreq_cpu_init(struct cpufreq_policy *policy)
if (sw64_clockmod_table[i].frequency == 0) if (sw64_clockmod_table[i].frequency == 0)
sw64_clockmod_table[i].frequency = (rate * i) / 48; sw64_clockmod_table[i].frequency = (rate * i) / 48;
sw64_set_rate(-1, rate * 1000); sw64_set_rate(rate * 1000);
policy->clk = cpuclk; policy->clk = cpuclk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册