Commit 12223144 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

ia64/err-inject: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

The removal of the files happens now in the prepare down stage as there is
no reason to keep them around until the cpu has actually died.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20161103145021.28528-15-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 38643a0e
...@@ -224,85 +224,45 @@ static struct attribute_group err_inject_attr_group = { ...@@ -224,85 +224,45 @@ static struct attribute_group err_inject_attr_group = {
.name = "err_inject" .name = "err_inject"
}; };
/* Add/Remove err_inject interface for CPU device */ /* Add/Remove err_inject interface for CPU device */
static int err_inject_add_dev(struct device *sys_dev) static int err_inject_add_dev(unsigned int cpu)
{ {
struct device *sys_dev = get_cpu_device(cpu);
return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group); return sysfs_create_group(&sys_dev->kobj, &err_inject_attr_group);
} }
static int err_inject_remove_dev(struct device *sys_dev) static int err_inject_remove_dev(unsigned int cpu)
{ {
struct device *sys_dev = get_cpu_device(cpu);
sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group); sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
return 0; return 0;
} }
static int err_inject_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;
struct device *sys_dev;
sys_dev = get_cpu_device(cpu);
switch (action) {
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
err_inject_add_dev(sys_dev);
break;
case CPU_DEAD:
case CPU_DEAD_FROZEN:
err_inject_remove_dev(sys_dev);
break;
}
return NOTIFY_OK;
}
static struct notifier_block err_inject_cpu_notifier = static enum cpuhp_state hp_online;
{
.notifier_call = err_inject_cpu_callback,
};
static int __init static int __init err_inject_init(void)
err_inject_init(void)
{ {
int i; int ret;
#ifdef ERR_INJ_DEBUG #ifdef ERR_INJ_DEBUG
printk(KERN_INFO "Enter error injection driver.\n"); printk(KERN_INFO "Enter error injection driver.\n");
#endif #endif
cpu_notifier_register_begin(); ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/err_inj:online",
err_inject_add_dev, err_inject_remove_dev);
for_each_online_cpu(i) { if (ret >= 0) {
err_inject_cpu_callback(&err_inject_cpu_notifier, CPU_ONLINE, hp_online = ret;
(void *)(long)i); ret = 0;
} }
return ret;
__register_hotcpu_notifier(&err_inject_cpu_notifier);
cpu_notifier_register_done();
return 0;
} }
static void __exit static void __exit err_inject_exit(void)
err_inject_exit(void)
{ {
int i;
struct device *sys_dev;
#ifdef ERR_INJ_DEBUG #ifdef ERR_INJ_DEBUG
printk(KERN_INFO "Exit error injection driver.\n"); printk(KERN_INFO "Exit error injection driver.\n");
#endif #endif
cpuhp_remove_state(hp_online);
cpu_notifier_register_begin();
for_each_online_cpu(i) {
sys_dev = get_cpu_device(i);
sysfs_remove_group(&sys_dev->kobj, &err_inject_attr_group);
}
__unregister_hotcpu_notifier(&err_inject_cpu_notifier);
cpu_notifier_register_done();
} }
module_init(err_inject_init); module_init(err_inject_init);
......
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