Skip to content

Commit 6277311

Browse files
committed
parisc: Switch from GENERIC_CPU_DEVICES to GENERIC_ARCH_TOPOLOGY
Switch away from the own cpu topology code to common code which is used by ARM64 and RISCV. That will allow us to enable CPU hotplug later on. Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 1e93848 commit 6277311

File tree

5 files changed

+24
-88
lines changed

5 files changed

+24
-88
lines changed

arch/parisc/Kconfig

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ config PARISC
3737
select GENERIC_PCI_IOMAP
3838
select ARCH_HAVE_NMI_SAFE_CMPXCHG
3939
select GENERIC_SMP_IDLE_THREAD
40-
select GENERIC_CPU_DEVICES
40+
select GENERIC_ARCH_TOPOLOGY if SMP
4141
select GENERIC_LIB_DEVMEM_IS_ALLOWED
4242
select SYSCTL_ARCH_UNALIGN_ALLOW
4343
select SYSCTL_EXCEPTION_TRACE
@@ -279,16 +279,9 @@ config SMP
279279

280280
If you don't know what to do here, say N.
281281

282-
config PARISC_CPU_TOPOLOGY
283-
bool "Support cpu topology definition"
284-
depends on SMP
285-
default y
286-
help
287-
Support PARISC cpu topology definition.
288-
289282
config SCHED_MC
290283
bool "Multi-core scheduler support"
291-
depends on PARISC_CPU_TOPOLOGY && PA8X00
284+
depends on GENERIC_ARCH_TOPOLOGY && PA8X00
292285
help
293286
Multi-core scheduler support improves the CPU scheduler's decision
294287
making when dealing with multi-core CPU chips at a cost of slightly

arch/parisc/include/asm/topology.h

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
11
#ifndef _ASM_PARISC_TOPOLOGY_H
22
#define _ASM_PARISC_TOPOLOGY_H
33

4-
#ifdef CONFIG_PARISC_CPU_TOPOLOGY
4+
#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
55

66
#include <linux/cpumask.h>
7-
8-
struct cputopo_parisc {
9-
int thread_id;
10-
int core_id;
11-
int socket_id;
12-
cpumask_t thread_sibling;
13-
cpumask_t core_sibling;
14-
};
15-
16-
extern struct cputopo_parisc cpu_topology[NR_CPUS];
17-
18-
#define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id)
19-
#define topology_core_id(cpu) (cpu_topology[cpu].core_id)
20-
#define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling)
21-
#define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling)
22-
23-
void init_cpu_topology(void);
24-
void store_cpu_topology(unsigned int cpuid);
25-
const struct cpumask *cpu_coregroup_mask(int cpu);
7+
#include <linux/arch_topology.h>
268

279
#else
2810

2911
static inline void init_cpu_topology(void) { }
3012
static inline void store_cpu_topology(unsigned int cpuid) { }
13+
static inline void reset_cpu_topology(void) { }
3114

3215
#endif
3316

arch/parisc/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ obj-$(CONFIG_AUDIT) += audit.o
3131
obj64-$(CONFIG_AUDIT) += compat_audit.o
3232
# only supported for PCX-W/U in 64-bit mode at the moment
3333
obj-$(CONFIG_64BIT) += perf.o perf_asm.o $(obj64-y)
34-
obj-$(CONFIG_PARISC_CPU_TOPOLOGY) += topology.o
34+
obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += topology.o
3535
obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o
3636
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
3737
obj-$(CONFIG_JUMP_LABEL) += jump_label.o

arch/parisc/kernel/processor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/random.h>
2020
#include <linux/slab.h>
2121
#include <linux/cpu.h>
22+
#include <asm/topology.h>
2223
#include <asm/param.h>
2324
#include <asm/cache.h>
2425
#include <asm/hardware.h> /* for register_parisc_driver() stuff */
@@ -390,7 +391,7 @@ show_cpuinfo (struct seq_file *m, void *v)
390391
boot_cpu_data.cpu_hz / 1000000,
391392
boot_cpu_data.cpu_hz % 1000000 );
392393

393-
#ifdef CONFIG_PARISC_CPU_TOPOLOGY
394+
#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
394395
seq_printf(m, "physical id\t: %d\n",
395396
topology_physical_package_id(cpu));
396397
seq_printf(m, "siblings\t: %d\n",
@@ -460,5 +461,6 @@ static struct parisc_driver cpu_driver __refdata = {
460461
*/
461462
void __init processor_init(void)
462463
{
464+
reset_cpu_topology();
463465
register_parisc_driver(&cpu_driver);
464466
}

arch/parisc/kernel/topology.c

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,11 @@
1313
#include <linux/percpu.h>
1414
#include <linux/sched.h>
1515
#include <linux/sched/topology.h>
16+
#include <linux/cpu.h>
1617

1718
#include <asm/topology.h>
1819

19-
/*
20-
* cpu topology table
21-
*/
22-
struct cputopo_parisc cpu_topology[NR_CPUS] __read_mostly;
23-
EXPORT_SYMBOL_GPL(cpu_topology);
24-
25-
const struct cpumask *cpu_coregroup_mask(int cpu)
26-
{
27-
return &cpu_topology[cpu].core_sibling;
28-
}
29-
30-
static void update_siblings_masks(unsigned int cpuid)
31-
{
32-
struct cputopo_parisc *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
33-
int cpu;
34-
35-
/* update core and thread sibling masks */
36-
for_each_possible_cpu(cpu) {
37-
cpu_topo = &cpu_topology[cpu];
38-
39-
if (cpuid_topo->socket_id != cpu_topo->socket_id)
40-
continue;
41-
42-
cpumask_set_cpu(cpuid, &cpu_topo->core_sibling);
43-
if (cpu != cpuid)
44-
cpumask_set_cpu(cpu, &cpuid_topo->core_sibling);
45-
46-
if (cpuid_topo->core_id != cpu_topo->core_id)
47-
continue;
48-
49-
cpumask_set_cpu(cpuid, &cpu_topo->thread_sibling);
50-
if (cpu != cpuid)
51-
cpumask_set_cpu(cpu, &cpuid_topo->thread_sibling);
52-
}
53-
smp_wmb();
54-
}
20+
static DEFINE_PER_CPU(struct cpu, cpu_devices);
5521

5622
static int dualcores_found __initdata;
5723

@@ -62,7 +28,7 @@ static int dualcores_found __initdata;
6228
*/
6329
void __init store_cpu_topology(unsigned int cpuid)
6430
{
65-
struct cputopo_parisc *cpuid_topo = &cpu_topology[cpuid];
31+
struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
6632
struct cpuinfo_parisc *p;
6733
int max_socket = -1;
6834
unsigned long cpu;
@@ -71,6 +37,12 @@ void __init store_cpu_topology(unsigned int cpuid)
7137
if (cpuid_topo->core_id != -1)
7238
return;
7339

40+
#ifdef CONFIG_HOTPLUG_CPU
41+
per_cpu(cpu_devices, cpuid).hotpluggable = 1;
42+
#endif
43+
if (register_cpu(&per_cpu(cpu_devices, cpuid), cpuid))
44+
pr_warn("Failed to register CPU%d device", cpuid);
45+
7446
/* create cpu topology mapping */
7547
cpuid_topo->thread_id = -1;
7648
cpuid_topo->core_id = 0;
@@ -86,25 +58,25 @@ void __init store_cpu_topology(unsigned int cpuid)
8658
cpuid_topo->core_id = cpu_topology[cpu].core_id;
8759
if (p->cpu_loc) {
8860
cpuid_topo->core_id++;
89-
cpuid_topo->socket_id = cpu_topology[cpu].socket_id;
61+
cpuid_topo->package_id = cpu_topology[cpu].package_id;
9062
dualcores_found = 1;
9163
continue;
9264
}
9365
}
9466

95-
if (cpuid_topo->socket_id == -1)
96-
max_socket = max(max_socket, cpu_topology[cpu].socket_id);
67+
if (cpuid_topo->package_id == -1)
68+
max_socket = max(max_socket, cpu_topology[cpu].package_id);
9769
}
9870

99-
if (cpuid_topo->socket_id == -1)
100-
cpuid_topo->socket_id = max_socket + 1;
71+
if (cpuid_topo->package_id == -1)
72+
cpuid_topo->package_id = max_socket + 1;
10173

10274
update_siblings_masks(cpuid);
10375

10476
pr_info("CPU%u: cpu core %d of socket %d\n",
10577
cpuid,
10678
cpu_topology[cpuid].core_id,
107-
cpu_topology[cpuid].socket_id);
79+
cpu_topology[cpuid].package_id);
10880
}
10981

11082
static struct sched_domain_topology_level parisc_mc_topology[] = {
@@ -122,20 +94,6 @@ static struct sched_domain_topology_level parisc_mc_topology[] = {
12294
*/
12395
void __init init_cpu_topology(void)
12496
{
125-
unsigned int cpu;
126-
127-
/* init core mask and capacity */
128-
for_each_possible_cpu(cpu) {
129-
struct cputopo_parisc *cpu_topo = &(cpu_topology[cpu]);
130-
131-
cpu_topo->thread_id = -1;
132-
cpu_topo->core_id = -1;
133-
cpu_topo->socket_id = -1;
134-
cpumask_clear(&cpu_topo->core_sibling);
135-
cpumask_clear(&cpu_topo->thread_sibling);
136-
}
137-
smp_wmb();
138-
13997
/* Set scheduler topology descriptor */
14098
if (dualcores_found)
14199
set_sched_topology(parisc_mc_topology);

0 commit comments

Comments
 (0)