From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932193AbcGMRVO (ORCPT ); Wed, 13 Jul 2016 13:21:14 -0400 Received: from www.linutronix.de ([62.245.132.108]:40323 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752260AbcGMRTX (ORCPT ); Wed, 13 Jul 2016 13:19:23 -0400 Message-Id: <20160713153336.881124821@linutronix.de> User-Agent: quilt/0.63-1 Date: Wed, 13 Jul 2016 17:16:51 -0000 From: Anna-Maria Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , rt@linutronix.de, Richard Cochran , Sebastian Andrzej Siewior , Daniel Lezcano , Eric Anholt , Felipe Balbi , Heiko Stuebner , Linus Torvalds , Marc Gonzalez , Russell King , Vineet Gupta , Viresh Kumar , linux-arm-kernel@lists.infradead.org, Anna-Maria Gleixner Subject: [patch V2 48/67] arm/twd: Convert to hotplug state machine References: <20160713153219.128052238@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0047-arm-twd-Convert-to-hotplug-state-machine.patch X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Cochran Install the callbacks via the state machine. The callbacks won't be invoked on already online CPUs. Signed-off-by: Richard Cochran Reviewed-by: Sebastian Andrzej Siewior Cc: Daniel Lezcano Cc: Eric Anholt Cc: Felipe Balbi Cc: Heiko Stuebner Cc: Linus Torvalds Cc: Marc Gonzalez Cc: Peter Zijlstra Cc: Russell King Cc: Thomas Gleixner Cc: Vineet Gupta Cc: Viresh Kumar Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Anna-Maria Gleixner --- arch/arm/kernel/smp_twd.c | 31 +++++++++++-------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index b6ec65e..02d5e5e 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -310,24 +310,17 @@ static void twd_timer_setup(void) enable_percpu_irq(clk->irq, 0); } -static int twd_timer_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int twd_timer_starting_cpu(unsigned int cpu) { - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_STARTING: - twd_timer_setup(); - break; - case CPU_DYING: - twd_timer_stop(); - break; - } - - return NOTIFY_OK; + twd_timer_setup(); + return 0; } -static struct notifier_block twd_timer_cpu_nb = { - .notifier_call = twd_timer_cpu_notify, -}; +static int twd_timer_dying_cpu(unsigned int cpu) +{ + twd_timer_stop(); + return 0; +} static int __init twd_local_timer_common_register(struct device_node *np) { @@ -345,9 +338,9 @@ static int __init twd_local_timer_common_register(struct device_node *np) goto out_free; } - err = register_cpu_notifier(&twd_timer_cpu_nb); - if (err) - goto out_irq; + cpuhp_setup_state_nocalls(CPUHP_AP_ARM_TWD_STARTING, + "AP_ARM_TWD_STARTING", + twd_timer_starting_cpu, twd_timer_dying_cpu); twd_get_clock(np); if (!of_property_read_bool(np, "always-on")) @@ -365,8 +358,6 @@ static int __init twd_local_timer_common_register(struct device_node *np) return 0; -out_irq: - free_percpu_irq(twd_ppi, twd_evt); out_free: iounmap(twd_base); twd_base = NULL; diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 1876377..86ac982 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -41,6 +41,7 @@ enum cpuhp_state { CPUHP_AP_ARM_L2X0_STARTING, CPUHP_AP_ARM_ARCH_TIMER_STARTING, CPUHP_AP_DUMMY_TIMER_STARTING, + CPUHP_AP_ARM_TWD_STARTING, CPUHP_AP_METAG_TIMER_STARTING, CPUHP_AP_QCOM_TIMER_STARTING, CPUHP_AP_MIPS_GIC_TIMER_STARTING, -- 2.8.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: anna-maria@linutronix.de (Anna-Maria Gleixner) Date: Wed, 13 Jul 2016 17:16:51 -0000 Subject: [patch V2 48/67] arm/twd: Convert to hotplug state machine References: <20160713153219.128052238@linutronix.de> Message-ID: <20160713153336.881124821@linutronix.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org From: Richard Cochran Install the callbacks via the state machine. The callbacks won't be invoked on already online CPUs. Signed-off-by: Richard Cochran Reviewed-by: Sebastian Andrzej Siewior Cc: Daniel Lezcano Cc: Eric Anholt Cc: Felipe Balbi Cc: Heiko Stuebner Cc: Linus Torvalds Cc: Marc Gonzalez Cc: Peter Zijlstra Cc: Russell King Cc: Thomas Gleixner Cc: Vineet Gupta Cc: Viresh Kumar Cc: linux-arm-kernel at lists.infradead.org Signed-off-by: Anna-Maria Gleixner --- arch/arm/kernel/smp_twd.c | 31 +++++++++++-------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index b6ec65e..02d5e5e 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -310,24 +310,17 @@ static void twd_timer_setup(void) enable_percpu_irq(clk->irq, 0); } -static int twd_timer_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) +static int twd_timer_starting_cpu(unsigned int cpu) { - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_STARTING: - twd_timer_setup(); - break; - case CPU_DYING: - twd_timer_stop(); - break; - } - - return NOTIFY_OK; + twd_timer_setup(); + return 0; } -static struct notifier_block twd_timer_cpu_nb = { - .notifier_call = twd_timer_cpu_notify, -}; +static int twd_timer_dying_cpu(unsigned int cpu) +{ + twd_timer_stop(); + return 0; +} static int __init twd_local_timer_common_register(struct device_node *np) { @@ -345,9 +338,9 @@ static int __init twd_local_timer_common_register(struct device_node *np) goto out_free; } - err = register_cpu_notifier(&twd_timer_cpu_nb); - if (err) - goto out_irq; + cpuhp_setup_state_nocalls(CPUHP_AP_ARM_TWD_STARTING, + "AP_ARM_TWD_STARTING", + twd_timer_starting_cpu, twd_timer_dying_cpu); twd_get_clock(np); if (!of_property_read_bool(np, "always-on")) @@ -365,8 +358,6 @@ static int __init twd_local_timer_common_register(struct device_node *np) return 0; -out_irq: - free_percpu_irq(twd_ppi, twd_evt); out_free: iounmap(twd_base); twd_base = NULL; diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 1876377..86ac982 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -41,6 +41,7 @@ enum cpuhp_state { CPUHP_AP_ARM_L2X0_STARTING, CPUHP_AP_ARM_ARCH_TIMER_STARTING, CPUHP_AP_DUMMY_TIMER_STARTING, + CPUHP_AP_ARM_TWD_STARTING, CPUHP_AP_METAG_TIMER_STARTING, CPUHP_AP_QCOM_TIMER_STARTING, CPUHP_AP_MIPS_GIC_TIMER_STARTING, -- 2.8.1