Commit 3eb906c6b6c123513718e7742a96a4189f900382

Authored by Michael Ellerman
Committed by Benjamin Herrenschmidt
1 parent c610260928

powerpc: Make cpu_to_chip_id() available when SMP=n

Up until now we have only used cpu_to_chip_id() in the topology code,
which is only used on SMP builds. However my recent commit a4da0d5
"Implement arch_get_random_long/int() for powernv" added a usage when
SMP=n, breaking the build.

Move cpu_to_chip_id() into prom.c so it is available for SMP=n builds.

We would move the extern to prom.h, but that breaks the include in
topology.h. Instead we leave it in smp.h, but move it out of the
CONFIG_SMP #ifdef. We also need to include asm/smp.h in rng.c, because
the linux version skips asm/smp.h on UP. What a mess.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Showing 4 changed files with 22 additions and 17 deletions Side-by-side Diff

arch/powerpc/include/asm/smp.h
... ... @@ -33,6 +33,7 @@
33 33 extern int spinning_secondaries;
34 34  
35 35 extern void cpu_die(void);
  36 +extern int cpu_to_chip_id(int cpu);
36 37  
37 38 #ifdef CONFIG_SMP
38 39  
... ... @@ -112,7 +113,6 @@
112 113 }
113 114  
114 115 extern int cpu_to_core_id(int cpu);
115   -extern int cpu_to_chip_id(int cpu);
116 116  
117 117 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
118 118 *
arch/powerpc/kernel/prom.c
... ... @@ -777,6 +777,26 @@
777 777 return -1;
778 778 }
779 779  
  780 +/**
  781 + * cpu_to_chip_id - Return the cpus chip-id
  782 + * @cpu: The logical cpu number.
  783 + *
  784 + * Return the value of the ibm,chip-id property corresponding to the given
  785 + * logical cpu number. If the chip-id can not be found, returns -1.
  786 + */
  787 +int cpu_to_chip_id(int cpu)
  788 +{
  789 + struct device_node *np;
  790 +
  791 + np = of_get_cpu_node(cpu, NULL);
  792 + if (!np)
  793 + return -1;
  794 +
  795 + of_node_put(np);
  796 + return of_get_ibm_chip_id(np);
  797 +}
  798 +EXPORT_SYMBOL(cpu_to_chip_id);
  799 +
780 800 #ifdef CONFIG_PPC_PSERIES
781 801 /*
782 802 * Fix up the uninitialized fields in a new device node:
arch/powerpc/kernel/smp.c
... ... @@ -597,22 +597,6 @@
597 597 return id;
598 598 }
599 599  
600   -/* Return the value of the chip-id property corresponding
601   - * to the given logical cpu.
602   - */
603   -int cpu_to_chip_id(int cpu)
604   -{
605   - struct device_node *np;
606   -
607   - np = of_get_cpu_node(cpu, NULL);
608   - if (!np)
609   - return -1;
610   -
611   - of_node_put(np);
612   - return of_get_ibm_chip_id(np);
613   -}
614   -EXPORT_SYMBOL(cpu_to_chip_id);
615   -
616 600 /* Helper routines for cpu to core mapping */
617 601 int cpu_core_index_of_thread(int cpu)
618 602 {
arch/powerpc/platforms/powernv/rng.c
... ... @@ -19,6 +19,7 @@
19 19 #include <asm/io.h>
20 20 #include <asm/prom.h>
21 21 #include <asm/machdep.h>
  22 +#include <asm/smp.h>
22 23  
23 24  
24 25 struct powernv_rng {