[patch 30/40] x86: tboot: Convert to hotplug state machine

From: Thomas Gleixner
Date: Thu Jan 31 2013 - 07:11:59 EST


Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
arch/x86/kernel/tboot.c | 23 +++++++----------------
include/linux/cpuhotplug.h | 1 +
2 files changed, 8 insertions(+), 16 deletions(-)

Index: linux-2.6/arch/x86/kernel/tboot.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/tboot.c
+++ linux-2.6/arch/x86/kernel/tboot.c
@@ -319,25 +319,16 @@ static int tboot_wait_for_aps(int num_ap
return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
}

-static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
- unsigned long action, void *hcpu)
+static int __cpuinit tboot_dying_cpu(unsigned int cpu)
{
- switch (action) {
- case CPU_DYING:
- atomic_inc(&ap_wfs_count);
- if (num_online_cpus() == 1)
- if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
- return NOTIFY_BAD;
- break;
+ atomic_inc(&ap_wfs_count);
+ if (num_online_cpus() == 1) {
+ if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
+ return -EBUSY;
}
- return NOTIFY_OK;
+ return 0;
}

-static struct notifier_block tboot_cpu_notifier __cpuinitdata =
-{
- .notifier_call = tboot_cpu_callback,
-};
-
static __init int tboot_late_init(void)
{
if (!tboot_enabled())
@@ -346,7 +337,7 @@ static __init int tboot_late_init(void)
tboot_create_trampoline();

atomic_set(&ap_wfs_count, 0);
- register_hotcpu_notifier(&tboot_cpu_notifier);
+ cpuhp_setup_state(CPUHP_AP_X86_TBOOT_DYING, NULL, tboot_dying_cpu);

acpi_os_set_prepare_sleep(&tboot_sleep);
return 0;
Index: linux-2.6/include/linux/cpuhotplug.h
===================================================================
--- linux-2.6.orig/include/linux/cpuhotplug.h
+++ linux-2.6/include/linux/cpuhotplug.h
@@ -27,6 +27,7 @@ enum cpuhp_states {
CPUHP_AP_ARM64_TIMER_STARTING,
CPUHP_AP_KVM_STARTING,
CPUHP_AP_NOTIFY_DYING,
+ CPUHP_AP_X86_TBOOT_DYING,
CPUHP_AP_S390_VTIME_DYING,
CPUHP_AP_SCHED_MIGRATE_DYING,
CPUHP_AP_MAX,


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/