From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753159AbcGSHNq (ORCPT ); Tue, 19 Jul 2016 03:13:46 -0400 Received: from terminus.zytor.com ([198.137.202.10]:45574 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752661AbcGSHNo (ORCPT ); Tue, 19 Jul 2016 03:13:44 -0400 Date: Tue, 19 Jul 2016 00:13:00 -0700 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: viresh.kumar@linaro.org, hpa@zytor.com, peterz@infradead.org, mingo@kernel.org, bigeasy@linutronix.de, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, bp@suse.de, tglx@linutronix.de, JBeulich@suse.com, dvlasenk@redhat.com, jiang.liu@linux.intel.com, anna-maria@linutronix.de, luto@kernel.org Reply-To: jiang.liu@linux.intel.com, anna-maria@linutronix.de, luto@kernel.org, bp@suse.de, tglx@linutronix.de, JBeulich@suse.com, dvlasenk@redhat.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, hpa@zytor.com, viresh.kumar@linaro.org, peterz@infradead.org, mingo@kernel.org, bigeasy@linutronix.de In-Reply-To: <20160713153335.279718463@linutronix.de> References: <20160713153335.279718463@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] x86/hpet: Convert to hotplug state machine Git-Commit-ID: 48d7f6c715782a6f6d4a5535f1233b764ce6b6f2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 48d7f6c715782a6f6d4a5535f1233b764ce6b6f2 Gitweb: http://git.kernel.org/tip/48d7f6c715782a6f6d4a5535f1233b764ce6b6f2 Author: Sebastian Andrzej Siewior AuthorDate: Wed, 13 Jul 2016 17:16:30 +0000 Committer: Ingo Molnar CommitDate: Thu, 14 Jul 2016 09:34:44 +0200 x86/hpet: 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: Sebastian Andrzej Siewior Signed-off-by: Anna-Maria Gleixner Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Denys Vlasenko Cc: Jan Beulich Cc: Jiang Liu Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Viresh Kumar Cc: rt@linutronix.de Link: http://lkml.kernel.org/r/20160713153335.279718463@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/hpet.c | 69 +++++++++++++++++++++++----------------------- include/linux/cpuhotplug.h | 2 ++ 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index f112af7..3d74707 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -710,31 +710,29 @@ static void hpet_work(struct work_struct *w) complete(&hpet_work->complete); } -static int hpet_cpuhp_notify(struct notifier_block *n, - unsigned long action, void *hcpu) +static int hpet_cpuhp_online(unsigned int cpu) { - unsigned long cpu = (unsigned long)hcpu; struct hpet_work_struct work; + + INIT_DELAYED_WORK_ONSTACK(&work.work, hpet_work); + init_completion(&work.complete); + /* FIXME: add schedule_work_on() */ + schedule_delayed_work_on(cpu, &work.work, 0); + wait_for_completion(&work.complete); + destroy_delayed_work_on_stack(&work.work); + return 0; +} + +static int hpet_cpuhp_dead(unsigned int cpu) +{ struct hpet_dev *hdev = per_cpu(cpu_hpet_dev, cpu); - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_ONLINE: - INIT_DELAYED_WORK_ONSTACK(&work.work, hpet_work); - init_completion(&work.complete); - /* FIXME: add schedule_work_on() */ - schedule_delayed_work_on(cpu, &work.work, 0); - wait_for_completion(&work.complete); - destroy_delayed_work_on_stack(&work.work); - break; - case CPU_DEAD: - if (hdev) { - free_irq(hdev->irq, hdev); - hdev->flags &= ~HPET_DEV_USED; - per_cpu(cpu_hpet_dev, cpu) = NULL; - } - break; - } - return NOTIFY_OK; + if (!hdev) + return 0; + free_irq(hdev->irq, hdev); + hdev->flags &= ~HPET_DEV_USED; + per_cpu(cpu_hpet_dev, cpu) = NULL; + return 0; } #else @@ -750,11 +748,8 @@ static void hpet_reserve_msi_timers(struct hpet_data *hd) } #endif -static int hpet_cpuhp_notify(struct notifier_block *n, - unsigned long action, void *hcpu) -{ - return NOTIFY_OK; -} +#define hpet_cpuhp_online NULL +#define hpet_cpuhp_dead NULL #endif @@ -931,7 +926,7 @@ out_nohpet: */ static __init int hpet_late_init(void) { - int cpu; + int ret; if (boot_hpet_disable) return -ENODEV; @@ -961,16 +956,20 @@ static __init int hpet_late_init(void) if (boot_cpu_has(X86_FEATURE_ARAT)) return 0; - cpu_notifier_register_begin(); - for_each_online_cpu(cpu) { - hpet_cpuhp_notify(NULL, CPU_ONLINE, (void *)(long)cpu); - } - /* This notifier should be called after workqueue is ready */ - __hotcpu_notifier(hpet_cpuhp_notify, -20); - cpu_notifier_register_done(); - + ret = cpuhp_setup_state(CPUHP_AP_X86_HPET_ONLINE, "AP_X86_HPET_ONLINE", + hpet_cpuhp_online, NULL); + if (ret) + return ret; + ret = cpuhp_setup_state(CPUHP_X86_HPET_DEAD, "X86_HPET_DEAD", NULL, + hpet_cpuhp_dead); + if (ret) + goto err_cpuhp; return 0; + +err_cpuhp: + cpuhp_remove_state(CPUHP_AP_X86_HPET_ONLINE); + return ret; } fs_initcall(hpet_late_init); diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 60557a9..7449081 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -12,6 +12,7 @@ enum cpuhp_state { CPUHP_PERF_BFIN, CPUHP_PERF_POWER, CPUHP_PERF_SUPERH, + CPUHP_X86_HPET_DEAD, CPUHP_WORKQUEUE_PREP, CPUHP_NOTIFY_PREPARE, CPUHP_BRINGUP_CPU, @@ -54,6 +55,7 @@ enum cpuhp_state { CPUHP_AP_NOTIFY_ONLINE, CPUHP_AP_ONLINE_DYN, CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30, + CPUHP_AP_X86_HPET_ONLINE, CPUHP_AP_ACTIVE, CPUHP_ONLINE, };