Commit bae19fe0 authored by Andreas Herrmann's avatar Andreas Herrmann Committed by Linus Torvalds

x86: don't call mce_create_device on CPU_UP_PREPARE

Fix regression introduced with d435d862
("cpu hotplug: mce: fix cpu hotplug error handling").

A CPU which was not brought up during boot (using maxcpus and
additional_cpus parameters) couldn't be onlined anymore.  For such a CPU it
seemed that MCE was not supported during CPU_UP_PREPARE-time which caused
mce_cpu_callback to return NOTIFY_BAD to notifier_call_chain.  To fix this
we:

 - call mce_create_device for CPU_ONLINE event (instead of CPU_UP_PREPARE),
 - avoid mce_remove_device() for the CPU that is not correctly initialized
   by mce_create_device() failure,
 - make mce_cpu_callback always return NOTIFY_OK for CPU_ONLINE event.
   Because CPU_ONLINE callback return value is always ignored.

[akinobu.mita@gmail.com: avoid mce_remove_device() for not initialized device]
[akinobu.mita@gmail.com: make mce_cpu_callback always return NOTIFY_OK]
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndreas Herrmann <andreas.herrmann3@amd.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 77f2878b
...@@ -802,6 +802,8 @@ static struct sysdev_attribute *mce_attributes[] = { ...@@ -802,6 +802,8 @@ static struct sysdev_attribute *mce_attributes[] = {
NULL NULL
}; };
static cpumask_t mce_device_initialized = CPU_MASK_NONE;
/* Per cpu sysdev init. All of the cpus still share the same ctl bank */ /* Per cpu sysdev init. All of the cpus still share the same ctl bank */
static __cpuinit int mce_create_device(unsigned int cpu) static __cpuinit int mce_create_device(unsigned int cpu)
{ {
...@@ -825,6 +827,7 @@ static __cpuinit int mce_create_device(unsigned int cpu) ...@@ -825,6 +827,7 @@ static __cpuinit int mce_create_device(unsigned int cpu)
if (err) if (err)
goto error; goto error;
} }
cpu_set(cpu, mce_device_initialized);
return 0; return 0;
error: error:
...@@ -841,10 +844,14 @@ static void mce_remove_device(unsigned int cpu) ...@@ -841,10 +844,14 @@ static void mce_remove_device(unsigned int cpu)
{ {
int i; int i;
if (!cpu_isset(cpu, mce_device_initialized))
return;
for (i = 0; mce_attributes[i]; i++) for (i = 0; mce_attributes[i]; i++)
sysdev_remove_file(&per_cpu(device_mce,cpu), sysdev_remove_file(&per_cpu(device_mce,cpu),
mce_attributes[i]); mce_attributes[i]);
sysdev_unregister(&per_cpu(device_mce,cpu)); sysdev_unregister(&per_cpu(device_mce,cpu));
cpu_clear(cpu, mce_device_initialized);
} }
/* Get notified when a cpu comes on/off. Be hotplug friendly. */ /* Get notified when a cpu comes on/off. Be hotplug friendly. */
...@@ -852,21 +859,18 @@ static int ...@@ -852,21 +859,18 @@ static int
mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{ {
unsigned int cpu = (unsigned long)hcpu; unsigned int cpu = (unsigned long)hcpu;
int err = 0;
switch (action) { switch (action) {
case CPU_UP_PREPARE: case CPU_ONLINE:
case CPU_UP_PREPARE_FROZEN: case CPU_ONLINE_FROZEN:
err = mce_create_device(cpu); mce_create_device(cpu);
break; break;
case CPU_UP_CANCELED:
case CPU_UP_CANCELED_FROZEN:
case CPU_DEAD: case CPU_DEAD:
case CPU_DEAD_FROZEN: case CPU_DEAD_FROZEN:
mce_remove_device(cpu); mce_remove_device(cpu);
break; break;
} }
return err ? NOTIFY_BAD : NOTIFY_OK; return NOTIFY_OK;
} }
static struct notifier_block mce_cpu_notifier = { static struct notifier_block mce_cpu_notifier = {
......
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