Skip to content

Commit

Permalink
powerpc: Make cpu_to_chip_id() available when SMP=n
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Ellerman authored and Benjamin Herrenschmidt committed Nov 20, 2013
1 parent c610260 commit 3eb906c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern int boot_cpuid;
extern int spinning_secondaries;

extern void cpu_die(void);
extern int cpu_to_chip_id(int cpu);

#ifdef CONFIG_SMP

Expand Down Expand Up @@ -112,7 +113,6 @@ static inline struct cpumask *cpu_core_mask(int cpu)
}

extern int cpu_to_core_id(int cpu);
extern int cpu_to_chip_id(int cpu);

/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
*
Expand Down
20 changes: 20 additions & 0 deletions arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,26 @@ int of_get_ibm_chip_id(struct device_node *np)
return -1;
}

/**
* cpu_to_chip_id - Return the cpus chip-id
* @cpu: The logical cpu number.
*
* Return the value of the ibm,chip-id property corresponding to the given
* logical cpu number. If the chip-id can not be found, returns -1.
*/
int cpu_to_chip_id(int cpu)
{
struct device_node *np;

np = of_get_cpu_node(cpu, NULL);
if (!np)
return -1;

of_node_put(np);
return of_get_ibm_chip_id(np);
}
EXPORT_SYMBOL(cpu_to_chip_id);

#ifdef CONFIG_PPC_PSERIES
/*
* Fix up the uninitialized fields in a new device node:
Expand Down
16 changes: 0 additions & 16 deletions arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,22 +597,6 @@ int cpu_to_core_id(int cpu)
return id;
}

/* Return the value of the chip-id property corresponding
* to the given logical cpu.
*/
int cpu_to_chip_id(int cpu)
{
struct device_node *np;

np = of_get_cpu_node(cpu, NULL);
if (!np)
return -1;

of_node_put(np);
return of_get_ibm_chip_id(np);
}
EXPORT_SYMBOL(cpu_to_chip_id);

/* Helper routines for cpu to core mapping */
int cpu_core_index_of_thread(int cpu)
{
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/platforms/powernv/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <asm/io.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/smp.h>


struct powernv_rng {
Expand Down

0 comments on commit 3eb906c

Please sign in to comment.