From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964798AbcIFPYu (ORCPT ); Tue, 6 Sep 2016 11:24:50 -0400 Received: from terminus.zytor.com ([198.137.202.10]:42936 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935391AbcIFPYo (ORCPT ); Tue, 6 Sep 2016 11:24:44 -0400 Date: Tue, 6 Sep 2016 08:24:06 -0700 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, rjw@rjwysocki.net, mingo@kernel.org, daniel.lezcano@linaro.org, bigeasy@linutronix.de, peterz@infradead.org Reply-To: hpa@zytor.com, rjw@rjwysocki.net, mingo@kernel.org, daniel.lezcano@linaro.org, bigeasy@linutronix.de, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org In-Reply-To: <20160818125731.27256-11-bigeasy@linutronix.de> References: <20160818125731.27256-11-bigeasy@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] cpuidle/pseries: Convert to hotplug state machine Git-Commit-ID: b3ec381d61767492a8ed8c85a92b58f7e4512139 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: b3ec381d61767492a8ed8c85a92b58f7e4512139 Gitweb: http://git.kernel.org/tip/b3ec381d61767492a8ed8c85a92b58f7e4512139 Author: Sebastian Andrzej Siewior AuthorDate: Thu, 18 Aug 2016 14:57:25 +0200 Committer: Thomas Gleixner CommitDate: Tue, 6 Sep 2016 16:20:30 +0200 cpuidle/pseries: Convert to hotplug state machine Install the callbacks via the state machine. Signed-off-by: Sebastian Andrzej Siewior Cc: linux-pm@vger.kernel.org Cc: Peter Zijlstra Cc: Daniel Lezcano Cc: "Rafael J. Wysocki" Cc: rt@linutronix.de Link: http://lkml.kernel.org/r/20160818125731.27256-11-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner --- drivers/cpuidle/cpuidle-pseries.c | 51 ++++++++++++++++++--------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index 07135e0..166ccd7 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -171,40 +171,30 @@ static struct cpuidle_state shared_states[] = { .enter = &shared_cede_loop }, }; -static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n, - unsigned long action, void *hcpu) +static int pseries_cpuidle_cpu_online(unsigned int cpu) { - int hotcpu = (unsigned long)hcpu; - struct cpuidle_device *dev = - per_cpu(cpuidle_devices, hotcpu); + struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu); if (dev && cpuidle_get_driver()) { - switch (action) { - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - cpuidle_pause_and_lock(); - cpuidle_enable_device(dev); - cpuidle_resume_and_unlock(); - break; + cpuidle_pause_and_lock(); + cpuidle_enable_device(dev); + cpuidle_resume_and_unlock(); + } + return 0; +} - case CPU_DEAD: - case CPU_DEAD_FROZEN: - cpuidle_pause_and_lock(); - cpuidle_disable_device(dev); - cpuidle_resume_and_unlock(); - break; +static int pseries_cpuidle_cpu_dead(unsigned int cpu) +{ + struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu); - default: - return NOTIFY_DONE; - } + if (dev && cpuidle_get_driver()) { + cpuidle_pause_and_lock(); + cpuidle_disable_device(dev); + cpuidle_resume_and_unlock(); } - return NOTIFY_OK; + return 0; } -static struct notifier_block setup_hotplug_notifier = { - .notifier_call = pseries_cpuidle_add_cpu_notifier, -}; - /* * pseries_cpuidle_driver_init() */ @@ -273,7 +263,14 @@ static int __init pseries_processor_idle_init(void) return retval; } - register_cpu_notifier(&setup_hotplug_notifier); + retval = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, + "cpuidle/pseries:online", + pseries_cpuidle_cpu_online, NULL); + WARN_ON(retval < 0); + retval = cpuhp_setup_state_nocalls(CPUHP_CPUIDLE_DEAD, + "cpuidle/pseries:DEAD", NULL, + pseries_cpuidle_cpu_dead); + WARN_ON(retval < 0); printk(KERN_DEBUG "pseries_idle_driver registered\n"); return 0; } diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index d8bc6e7..962c37b 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -19,6 +19,7 @@ enum cpuhp_state { CPUHP_MM_WRITEBACK_DEAD, CPUHP_SOFTIRQ_DEAD, CPUHP_NET_MVNETA_DEAD, + CPUHP_CPUIDLE_DEAD, CPUHP_WORKQUEUE_PREP, CPUHP_POWER_NUMA_PREPARE, CPUHP_HRTIMERS_PREPARE,