diff options
author | Gautham R. Shenoy <ego@linux.vnet.ibm.com> | 2014-03-11 07:31:18 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-04-28 03:36:38 -0400 |
commit | 2299d03a632c7586403ab43a11b418ee1ae47f1a (patch) | |
tree | e2914a88d1b01f92e2428bc548872b581f758b84 /arch | |
parent | 2196c6f1ed66eef23df3b478cfe71661ae83726e (diff) |
powerpc: powernv: Framework to show the correct clock in /proc/cpuinfo
Currently, the code in setup-common.c for powerpc assumes that all
clock rates are same in a smp system. This value is cached in the
variable named ppc_proc_freq and is the value that is reported in
/proc/cpuinfo.
However on the PowerNV platform, the clock rate is same only across
the threads of the same core. Hence the value that is reported in
/proc/cpuinfo is incorrect on PowerNV platforms. We need a better way
to query and report the correct value of the processor clock in
/proc/cpuinfo.
The patch achieves this by creating a machdep_call named
get_proc_freq() which is expected to returns the frequency in Hz. The
code in show_cpuinfo() can invoke this method to display the correct
clock rate on platforms that have implemented this method. On the
other powerpc platforms it can use the value cached in ppc_proc_freq.
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/machdep.h | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/setup-common.c | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index 240b137ce0cf..374abc2e41d7 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h | |||
@@ -113,6 +113,8 @@ struct machdep_calls { | |||
113 | /* Optional, may be NULL. */ | 113 | /* Optional, may be NULL. */ |
114 | void (*show_cpuinfo)(struct seq_file *m); | 114 | void (*show_cpuinfo)(struct seq_file *m); |
115 | void (*show_percpuinfo)(struct seq_file *m, int i); | 115 | void (*show_percpuinfo)(struct seq_file *m, int i); |
116 | /* Returns the current operating frequency of "cpu" in Hz */ | ||
117 | unsigned long (*get_proc_freq)(unsigned int cpu); | ||
116 | 118 | ||
117 | void (*init_IRQ)(void); | 119 | void (*init_IRQ)(void); |
118 | 120 | ||
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 79b7612ac6fa..3cf25c89469d 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -212,6 +212,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
212 | { | 212 | { |
213 | unsigned long cpu_id = (unsigned long)v - 1; | 213 | unsigned long cpu_id = (unsigned long)v - 1; |
214 | unsigned int pvr; | 214 | unsigned int pvr; |
215 | unsigned long proc_freq; | ||
215 | unsigned short maj; | 216 | unsigned short maj; |
216 | unsigned short min; | 217 | unsigned short min; |
217 | 218 | ||
@@ -263,12 +264,19 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
263 | #endif /* CONFIG_TAU */ | 264 | #endif /* CONFIG_TAU */ |
264 | 265 | ||
265 | /* | 266 | /* |
266 | * Assume here that all clock rates are the same in a | 267 | * Platforms that have variable clock rates, should implement |
267 | * smp system. -- Cort | 268 | * the method ppc_md.get_proc_freq() that reports the clock |
269 | * rate of a given cpu. The rest can use ppc_proc_freq to | ||
270 | * report the clock rate that is same across all cpus. | ||
268 | */ | 271 | */ |
269 | if (ppc_proc_freq) | 272 | if (ppc_md.get_proc_freq) |
273 | proc_freq = ppc_md.get_proc_freq(cpu_id); | ||
274 | else | ||
275 | proc_freq = ppc_proc_freq; | ||
276 | |||
277 | if (proc_freq) | ||
270 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", | 278 | seq_printf(m, "clock\t\t: %lu.%06luMHz\n", |
271 | ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); | 279 | proc_freq / 1000000, proc_freq % 1000000); |
272 | 280 | ||
273 | if (ppc_md.show_percpuinfo != NULL) | 281 | if (ppc_md.show_percpuinfo != NULL) |
274 | ppc_md.show_percpuinfo(m, cpu_id); | 282 | ppc_md.show_percpuinfo(m, cpu_id); |