Commit a7ce95e1 authored by Anna-Maria Gleixner's avatar Anna-Maria Gleixner Committed by Thomas Gleixner

arm64/cpuinfo: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Signed-off-by: default avatarAnna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: rt@linutronix.de
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/20161126231350.10321-17-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 914fb85f
...@@ -227,7 +227,7 @@ static struct attribute_group cpuregs_attr_group = { ...@@ -227,7 +227,7 @@ static struct attribute_group cpuregs_attr_group = {
.name = "identification" .name = "identification"
}; };
static int cpuid_add_regs(int cpu) static int cpuid_cpu_online(unsigned int cpu)
{ {
int rc; int rc;
struct device *dev; struct device *dev;
...@@ -248,7 +248,7 @@ static int cpuid_add_regs(int cpu) ...@@ -248,7 +248,7 @@ static int cpuid_add_regs(int cpu)
return rc; return rc;
} }
static int cpuid_remove_regs(int cpu) static int cpuid_cpu_offline(unsigned int cpu)
{ {
struct device *dev; struct device *dev;
struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu); struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu);
...@@ -264,41 +264,22 @@ static int cpuid_remove_regs(int cpu) ...@@ -264,41 +264,22 @@ static int cpuid_remove_regs(int cpu)
return 0; return 0;
} }
static int cpuid_callback(struct notifier_block *nb,
unsigned long action, void *hcpu)
{
int rc = 0;
unsigned long cpu = (unsigned long)hcpu;
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
case CPU_DOWN_FAILED:
rc = cpuid_add_regs(cpu);
break;
case CPU_DOWN_PREPARE:
rc = cpuid_remove_regs(cpu);
break;
}
return notifier_from_errno(rc);
}
static int __init cpuinfo_regs_init(void) static int __init cpuinfo_regs_init(void)
{ {
int cpu; int cpu, ret;
cpu_notifier_register_begin();
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu); struct cpuinfo_arm64 *info = &per_cpu(cpu_data, cpu);
kobject_init(&info->kobj, &cpuregs_kobj_type); kobject_init(&info->kobj, &cpuregs_kobj_type);
if (cpu_online(cpu))
cpuid_add_regs(cpu);
} }
__hotcpu_notifier(cpuid_callback, 0);
cpu_notifier_register_done(); ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "arm64/cpuinfo:online",
cpuid_cpu_online, cpuid_cpu_offline);
if (ret < 0) {
pr_err("cpuinfo: failed to register hotplug callbacks.\n");
return ret;
}
return 0; return 0;
} }
static void cpuinfo_detect_icache_policy(struct cpuinfo_arm64 *info) static void cpuinfo_detect_icache_policy(struct cpuinfo_arm64 *info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment