ARM: kernel: update cpuinfo to print all online CPUs features
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 10 Sep 2012 17:55:21 +0000 (18:55 +0100)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 19 Nov 2012 14:51:12 +0000 (14:51 +0000)
Currently, reading /proc/cpuinfo provides userspace with CPU ID of
the CPU carrying out the read from the file. This is fine as long as all
CPUs in the system are the same. With the advent of big.LITTLE and
heterogenous ARM systems this approach provides user space with incorrect
bits of information since CPU ids in the system might differ from the one
provided by the CPU reading the file.

This patch updates the cpuinfo show function so that a read from
/proc/cpuinfo prints HW information for all online CPUs at once, mirroring
 x86 behaviour.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
arch/arm/kernel/setup.c

index da1d1aa20ad957ccd7021815014d12530de4f3a1..a15848f8b0ffc46bde7777ba8200e63b4a0170a6 100644 (file)
@@ -841,12 +841,9 @@ static const char *hwcap_str[] = {
 
 static int c_show(struct seq_file *m, void *v)
 {
-       int i;
-
-       seq_printf(m, "Processor\t: %s rev %d (%s)\n",
-                  cpu_name, read_cpuid_id() & 15, elf_platform);
+       int i, j;
+       u32 cpuid;
 
-#if defined(CONFIG_SMP)
        for_each_online_cpu(i) {
                /*
                 * glibc reads /proc/cpuinfo to determine the number of
@@ -854,45 +851,48 @@ static int c_show(struct seq_file *m, void *v)
                 * "processor".  Give glibc what it expects.
                 */
                seq_printf(m, "processor\t: %d\n", i);
-               seq_printf(m, "BogoMIPS\t: %lu.%02lu\n\n",
+               cpuid = is_smp() ? per_cpu(cpu_data, i).cpuid : read_cpuid_id();
+               seq_printf(m, "model name\t: %s rev %d (%s)\n",
+                          cpu_name, cpuid & 15, elf_platform);
+
+#if defined(CONFIG_SMP)
+               seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
                           per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ),
                           (per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100);
-       }
-#else /* CONFIG_SMP */
-       seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
-                  loops_per_jiffy / (500000/HZ),
-                  (loops_per_jiffy / (5000/HZ)) % 100);
+#else
+               seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
+                          loops_per_jiffy / (500000/HZ),
+                          (loops_per_jiffy / (5000/HZ)) % 100);
 #endif
+               /* dump out the processor features */
+               seq_puts(m, "Features\t: ");
 
-       /* dump out the processor features */
-       seq_puts(m, "Features\t: ");
-
-       for (i = 0; hwcap_str[i]; i++)
-               if (elf_hwcap & (1 << i))
-                       seq_printf(m, "%s ", hwcap_str[i]);
+               for (j = 0; hwcap_str[j]; j++)
+                       if (elf_hwcap & (1 << j))
+                               seq_printf(m, "%s ", hwcap_str[j]);
 
-       seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
-       seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]);
+               seq_printf(m, "\nCPU implementer\t: 0x%02x\n", cpuid >> 24);
+               seq_printf(m, "CPU architecture: %s\n",
+                          proc_arch[cpu_architecture()]);
 
-       if ((read_cpuid_id() & 0x0008f000) == 0x00000000) {
-               /* pre-ARM7 */
-               seq_printf(m, "CPU part\t: %07x\n", read_cpuid_id() >> 4);
-       } else {
-               if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
-                       /* ARM7 */
-                       seq_printf(m, "CPU variant\t: 0x%02x\n",
-                                  (read_cpuid_id() >> 16) & 127);
+               if ((cpuid & 0x0008f000) == 0x00000000) {
+                       /* pre-ARM7 */
+                       seq_printf(m, "CPU part\t: %07x\n", cpuid >> 4);
                } else {
-                       /* post-ARM7 */
-                       seq_printf(m, "CPU variant\t: 0x%x\n",
-                                  (read_cpuid_id() >> 20) & 15);
+                       if ((cpuid & 0x0008f000) == 0x00007000) {
+                               /* ARM7 */
+                               seq_printf(m, "CPU variant\t: 0x%02x\n",
+                                          (cpuid >> 16) & 127);
+                       } else {
+                               /* post-ARM7 */
+                               seq_printf(m, "CPU variant\t: 0x%x\n",
+                                          (cpuid >> 20) & 15);
+                       }
+                       seq_printf(m, "CPU part\t: 0x%03x\n",
+                                  (cpuid >> 4) & 0xfff);
                }
-               seq_printf(m, "CPU part\t: 0x%03x\n",
-                          (read_cpuid_id() >> 4) & 0xfff);
+               seq_printf(m, "CPU revision\t: %d\n\n", cpuid & 15);
        }
-       seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
-
-       seq_puts(m, "\n");
 
        seq_printf(m, "Hardware\t: %s\n", machine_name);
        seq_printf(m, "Revision\t: %04x\n", system_rev);