[PATCH v2] powerpc: Show current speed in /proc/cpuinfo

Olof Johansson olof at lixom.net
Mon Apr 30 13:53:39 EST 2007


On other architectures, the frequency in /proc/cpuinfo moves with cpufreq
changes. It makes sense to do the same on powerpc to keep users from
getting confused.

Change the format to three decimals, having full Hz granularity is silly
these days. Also specify in output if it's cpufreq or firmware-reported:

clock           : 1250.000MHz (from firmware)
or:
clock           : 2500.000MHz (actual speed)


Signed-off-by: Olof Johansson <olof at lixom.net>


Index: powerpc/arch/powerpc/kernel/setup-common.c
===================================================================
--- powerpc.orig/arch/powerpc/kernel/setup-common.c
+++ powerpc/arch/powerpc/kernel/setup-common.c
@@ -29,6 +29,7 @@
 #include <linux/root_dev.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
+#include <linux/cpufreq.h>
 #include <linux/unistd.h>
 #include <linux/serial.h>
 #include <linux/serial_8250.h>
@@ -160,6 +161,7 @@ static int show_cpuinfo(struct seq_file 
 	unsigned int pvr;
 	unsigned short maj;
 	unsigned short min;
+	unsigned int freq;
 
 	if (cpu_id == NR_CPUS) {
 #if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
@@ -226,13 +228,16 @@ static int show_cpuinfo(struct seq_file 
 	}
 #endif /* CONFIG_TAU */
 
-	/*
-	 * Assume here that all clock rates are the same in a
-	 * smp system.  -- Cort
-	 */
-	if (ppc_proc_freq)
-		seq_printf(m, "clock\t\t: %lu.%06luMHz\n",
-			   ppc_proc_freq / 1000000, ppc_proc_freq % 1000000);
+	/* cpufreq_quick_get() is in kHz */
+	freq = cpufreq_quick_get(cpu_id);
+
+	if (freq)
+		seq_printf(m, "clock\t\t: %u.%03uMHz (actual speed)\n",
+			   freq / 1000, freq % 1000);
+	else if (ppc_proc_freq)
+		seq_printf(m, "clock\t\t: %lu.%03luMHz (from firmware)\n",
+			   ppc_proc_freq / 1000000,
+			   (ppc_proc_freq / 1000) % 1000);
 
 	if (ppc_md.show_percpuinfo != NULL)
 		ppc_md.show_percpuinfo(m, cpu_id);



More information about the Linuxppc-dev mailing list