Skip to content

Commit

Permalink
arm/twd: Convert to hotplug state machine
Browse files Browse the repository at this point in the history
Install the callbacks via the state machine. The callbacks won't be invoked on
already online CPUs.

Signed-off-by: Richard Cochran <rcochran@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153336.881124821@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Richard Cochran authored and Ingo Molnar committed Jul 15, 2016
1 parent 9eeb226 commit 26b8768
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
31 changes: 11 additions & 20 deletions arch/arm/kernel/smp_twd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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"))
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/linux/cpuhotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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,
Expand Down

0 comments on commit 26b8768

Please sign in to comment.