Skip to content

Commit 47dcd35

Browse files
committed
Merge tag 'remove-local-timers' of git://git.kernel.org/pub/scm/linux/kernel/git/davidb/linux-msm into next/cleanup
From Stephen Boyd: Now that we have a generic arch hook for broadcast we can remove the local timer API entirely. Doing so will reduce code in ARM core, reduce the architecture dependencies of our timer drivers, and simplify the code because we no longer go through an architecture layer that is essentially a hotplug notifier. * tag 'remove-local-timers' of git://git.kernel.org/pub/scm/linux/kernel/git/davidb/linux-msm: ARM: smp: Remove local timer API clocksource: time-armada-370-xp: Divorce from local timer API clocksource: time-armada-370-xp: Fix sparse warning ARM: msm: Divorce msm_timer from local timer API ARM: PRIMA2: Divorce timer-marco from local timer API ARM: EXYNOS4: Divorce mct from local timer API ARM: OMAP2+: Divorce from local timer API ARM: smp_twd: Divorce smp_twd from local timer API ARM: smp: Remove duplicate dummy timer implementation Resolved a large number of conflicts due to __cpuinit cleanups, etc. Signed-off-by: Olof Johansson <olof@lixom.net>
2 parents 3b2f64d + 060fd30 commit 47dcd35

19 files changed

Lines changed: 265 additions & 341 deletions

File tree

‎arch/arm/Kconfig‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ config ARCH_SHMOBILE
645645
select CLKDEV_LOOKUP
646646
select GENERIC_CLOCKEVENTS
647647
select HAVE_ARM_SCU if SMP
648-
select HAVE_ARM_TWD if LOCAL_TIMERS
648+
select HAVE_ARM_TWD if SMP
649649
select HAVE_CLK
650650
select HAVE_MACH_CLKDEV
651651
select HAVE_SMP
@@ -1584,16 +1584,6 @@ config ARM_PSCI
15841584
0022A ("Power State Coordination Interface System Software on
15851585
ARM processors").
15861586

1587-
config LOCAL_TIMERS
1588-
bool "Use local timer interrupts"
1589-
depends on SMP
1590-
default y
1591-
help
1592-
Enable support for local timers on SMP platforms, rather then the
1593-
legacy IPI broadcast method. Local timers allows the system
1594-
accounting to be spread across the timer interval, preventing a
1595-
"thundering herd" at every timer tick.
1596-
15971587
# The GPIO number here must be sorted by descending number. In case of
15981588
# a multiplatform kernel, we just want the highest value required by the
15991589
# selected platforms.

‎arch/arm/include/asm/localtimer.h‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎arch/arm/kernel/smp.c‎

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include <asm/sections.h>
4242
#include <asm/tlbflush.h>
4343
#include <asm/ptrace.h>
44-
#include <asm/localtimer.h>
4544
#include <asm/smp_plat.h>
4645
#include <asm/virt.h>
4746
#include <asm/mach/arch.h>
@@ -146,8 +145,6 @@ int boot_secondary(unsigned int cpu, struct task_struct *idle)
146145
}
147146

148147
#ifdef CONFIG_HOTPLUG_CPU
149-
static void percpu_timer_stop(void);
150-
151148
static int platform_cpu_kill(unsigned int cpu)
152149
{
153150
if (smp_ops.cpu_kill)
@@ -190,11 +187,6 @@ int __cpu_disable(void)
190187
*/
191188
migrate_irqs();
192189

193-
/*
194-
* Stop the local timer for this CPU.
195-
*/
196-
percpu_timer_stop();
197-
198190
/*
199191
* Flush user cache and TLB mappings, and then remove this CPU
200192
* from the vm mask set of all processes.
@@ -316,8 +308,6 @@ static void smp_store_cpu_info(unsigned int cpuid)
316308
store_cpu_topology(cpuid);
317309
}
318310

319-
static void percpu_timer_setup(void);
320-
321311
/*
322312
* This is the secondary CPU boot entry. We're using this CPUs
323313
* idle thread stack, but a set of temporary page tables.
@@ -372,11 +362,6 @@ asmlinkage void secondary_start_kernel(void)
372362
set_cpu_online(cpu, true);
373363
complete(&cpu_running);
374364

375-
/*
376-
* Setup the percpu timer for this CPU.
377-
*/
378-
percpu_timer_setup();
379-
380365
local_irq_enable();
381366
local_fiq_enable();
382367

@@ -422,12 +407,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
422407
if (max_cpus > ncores)
423408
max_cpus = ncores;
424409
if (ncores > 1 && max_cpus) {
425-
/*
426-
* Enable the local timer or broadcast device for the
427-
* boot CPU, but only if we have more than one CPU.
428-
*/
429-
percpu_timer_setup();
430-
431410
/*
432411
* Initialise the present map, which describes the set of CPUs
433412
* actually populated at the present time. A platform should
@@ -504,79 +483,13 @@ u64 smp_irq_stat_cpu(unsigned int cpu)
504483
return sum;
505484
}
506485

507-
/*
508-
* Timer (local or broadcast) support
509-
*/
510-
static DEFINE_PER_CPU(struct clock_event_device, percpu_clockevent);
511-
512486
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
513487
void tick_broadcast(const struct cpumask *mask)
514488
{
515489
smp_cross_call(mask, IPI_TIMER);
516490
}
517491
#endif
518492

519-
static void broadcast_timer_set_mode(enum clock_event_mode mode,
520-
struct clock_event_device *evt)
521-
{
522-
}
523-
524-
static void broadcast_timer_setup(struct clock_event_device *evt)
525-
{
526-
evt->name = "dummy_timer";
527-
evt->features = CLOCK_EVT_FEAT_ONESHOT |
528-
CLOCK_EVT_FEAT_PERIODIC |
529-
CLOCK_EVT_FEAT_DUMMY;
530-
evt->rating = 100;
531-
evt->mult = 1;
532-
evt->set_mode = broadcast_timer_set_mode;
533-
534-
clockevents_register_device(evt);
535-
}
536-
537-
static struct local_timer_ops *lt_ops;
538-
539-
#ifdef CONFIG_LOCAL_TIMERS
540-
int local_timer_register(struct local_timer_ops *ops)
541-
{
542-
if (!is_smp() || !setup_max_cpus)
543-
return -ENXIO;
544-
545-
if (lt_ops)
546-
return -EBUSY;
547-
548-
lt_ops = ops;
549-
return 0;
550-
}
551-
#endif
552-
553-
static void percpu_timer_setup(void)
554-
{
555-
unsigned int cpu = smp_processor_id();
556-
struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
557-
558-
evt->cpumask = cpumask_of(cpu);
559-
560-
if (!lt_ops || lt_ops->setup(evt))
561-
broadcast_timer_setup(evt);
562-
}
563-
564-
#ifdef CONFIG_HOTPLUG_CPU
565-
/*
566-
* The generic clock events code purposely does not stop the local timer
567-
* on CPU_DEAD/CPU_DEAD_FROZEN hotplug events, so we have to do it
568-
* manually here.
569-
*/
570-
static void percpu_timer_stop(void)
571-
{
572-
unsigned int cpu = smp_processor_id();
573-
struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
574-
575-
if (lt_ops)
576-
lt_ops->stop(evt);
577-
}
578-
#endif
579-
580493
static DEFINE_RAW_SPINLOCK(stop_lock);
581494

582495
/*

‎arch/arm/kernel/smp_twd.c‎

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/init.h>
1212
#include <linux/kernel.h>
1313
#include <linux/clk.h>
14+
#include <linux/cpu.h>
1415
#include <linux/delay.h>
1516
#include <linux/device.h>
1617
#include <linux/err.h>
@@ -24,7 +25,6 @@
2425

2526
#include <asm/smp_plat.h>
2627
#include <asm/smp_twd.h>
27-
#include <asm/localtimer.h>
2828

2929
/* set up by the platform code */
3030
static void __iomem *twd_base;
@@ -33,7 +33,7 @@ static struct clk *twd_clk;
3333
static unsigned long twd_timer_rate;
3434
static DEFINE_PER_CPU(bool, percpu_setup_called);
3535

36-
static struct clock_event_device __percpu **twd_evt;
36+
static struct clock_event_device __percpu *twd_evt;
3737
static int twd_ppi;
3838

3939
static void twd_set_mode(enum clock_event_mode mode,
@@ -90,8 +90,10 @@ static int twd_timer_ack(void)
9090
return 0;
9191
}
9292

93-
static void twd_timer_stop(struct clock_event_device *clk)
93+
static void twd_timer_stop(void)
9494
{
95+
struct clock_event_device *clk = __this_cpu_ptr(twd_evt);
96+
9597
twd_set_mode(CLOCK_EVT_MODE_UNUSED, clk);
9698
disable_percpu_irq(clk->irq);
9799
}
@@ -106,7 +108,7 @@ static void twd_update_frequency(void *new_rate)
106108
{
107109
twd_timer_rate = *((unsigned long *) new_rate);
108110

109-
clockevents_update_freq(*__this_cpu_ptr(twd_evt), twd_timer_rate);
111+
clockevents_update_freq(__this_cpu_ptr(twd_evt), twd_timer_rate);
110112
}
111113

112114
static int twd_rate_change(struct notifier_block *nb,
@@ -132,7 +134,7 @@ static struct notifier_block twd_clk_nb = {
132134

133135
static int twd_clk_init(void)
134136
{
135-
if (twd_evt && *__this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
137+
if (twd_evt && __this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
136138
return clk_notifier_register(twd_clk, &twd_clk_nb);
137139

138140
return 0;
@@ -151,7 +153,7 @@ static void twd_update_frequency(void *data)
151153
{
152154
twd_timer_rate = clk_get_rate(twd_clk);
153155

154-
clockevents_update_freq(*__this_cpu_ptr(twd_evt), twd_timer_rate);
156+
clockevents_update_freq(__this_cpu_ptr(twd_evt), twd_timer_rate);
155157
}
156158

157159
static int twd_cpufreq_transition(struct notifier_block *nb,
@@ -177,7 +179,7 @@ static struct notifier_block twd_cpufreq_nb = {
177179

178180
static int twd_cpufreq_init(void)
179181
{
180-
if (twd_evt && *__this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
182+
if (twd_evt && __this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
181183
return cpufreq_register_notifier(&twd_cpufreq_nb,
182184
CPUFREQ_TRANSITION_NOTIFIER);
183185

@@ -228,7 +230,7 @@ static void twd_calibrate_rate(void)
228230

229231
static irqreturn_t twd_handler(int irq, void *dev_id)
230232
{
231-
struct clock_event_device *evt = *(struct clock_event_device **)dev_id;
233+
struct clock_event_device *evt = dev_id;
232234

233235
if (twd_timer_ack()) {
234236
evt->event_handler(evt);
@@ -265,9 +267,9 @@ static void twd_get_clock(struct device_node *np)
265267
/*
266268
* Setup the local clock events for a CPU.
267269
*/
268-
static int twd_timer_setup(struct clock_event_device *clk)
270+
static void twd_timer_setup(void)
269271
{
270-
struct clock_event_device **this_cpu_clk;
272+
struct clock_event_device *clk = __this_cpu_ptr(twd_evt);
271273
int cpu = smp_processor_id();
272274

273275
/*
@@ -276,9 +278,9 @@ static int twd_timer_setup(struct clock_event_device *clk)
276278
*/
277279
if (per_cpu(percpu_setup_called, cpu)) {
278280
__raw_writel(0, twd_base + TWD_TIMER_CONTROL);
279-
clockevents_register_device(*__this_cpu_ptr(twd_evt));
281+
clockevents_register_device(clk);
280282
enable_percpu_irq(clk->irq, 0);
281-
return 0;
283+
return;
282284
}
283285
per_cpu(percpu_setup_called, cpu) = true;
284286

@@ -297,27 +299,37 @@ static int twd_timer_setup(struct clock_event_device *clk)
297299
clk->set_mode = twd_set_mode;
298300
clk->set_next_event = twd_set_next_event;
299301
clk->irq = twd_ppi;
300-
301-
this_cpu_clk = __this_cpu_ptr(twd_evt);
302-
*this_cpu_clk = clk;
302+
clk->cpumask = cpumask_of(cpu);
303303

304304
clockevents_config_and_register(clk, twd_timer_rate,
305305
0xf, 0xffffffff);
306306
enable_percpu_irq(clk->irq, 0);
307+
}
307308

308-
return 0;
309+
static int twd_timer_cpu_notify(struct notifier_block *self,
310+
unsigned long action, void *hcpu)
311+
{
312+
switch (action & ~CPU_TASKS_FROZEN) {
313+
case CPU_STARTING:
314+
twd_timer_setup();
315+
break;
316+
case CPU_DYING:
317+
twd_timer_stop();
318+
break;
319+
}
320+
321+
return NOTIFY_OK;
309322
}
310323

311-
static struct local_timer_ops twd_lt_ops = {
312-
.setup = twd_timer_setup,
313-
.stop = twd_timer_stop,
324+
static struct notifier_block twd_timer_cpu_nb = {
325+
.notifier_call = twd_timer_cpu_notify,
314326
};
315327

316328
static int __init twd_local_timer_common_register(struct device_node *np)
317329
{
318330
int err;
319331

320-
twd_evt = alloc_percpu(struct clock_event_device *);
332+
twd_evt = alloc_percpu(struct clock_event_device);
321333
if (!twd_evt) {
322334
err = -ENOMEM;
323335
goto out_free;
@@ -329,12 +341,22 @@ static int __init twd_local_timer_common_register(struct device_node *np)
329341
goto out_free;
330342
}
331343

332-
err = local_timer_register(&twd_lt_ops);
344+
err = register_cpu_notifier(&twd_timer_cpu_nb);
333345
if (err)
334346
goto out_irq;
335347

336348
twd_get_clock(np);
337349

350+
/*
351+
* Immediately configure the timer on the boot CPU, unless we need
352+
* jiffies to be incrementing to calibrate the rate in which case
353+
* setup the timer in late_time_init.
354+
*/
355+
if (twd_timer_rate)
356+
twd_timer_setup();
357+
else
358+
late_time_init = twd_timer_setup;
359+
338360
return 0;
339361

340362
out_irq:

‎arch/arm/mach-highbank/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config ARCH_HIGHBANK
1212
select CPU_V7
1313
select GENERIC_CLOCKEVENTS
1414
select HAVE_ARM_SCU
15-
select HAVE_ARM_TWD if LOCAL_TIMERS
15+
select HAVE_ARM_TWD if SMP
1616
select HAVE_SMP
1717
select MAILBOX
1818
select PL320_MBOX

‎arch/arm/mach-imx/Kconfig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,8 @@ config SOC_IMX6Q
793793
select COMMON_CLK
794794
select CPU_V7
795795
select HAVE_ARM_SCU if SMP
796-
select HAVE_ARM_TWD if LOCAL_TIMERS
796+
select HAVE_ARM_TWD if SMP
797+
select HAVE_CAN_FLEXCAN if CAN
797798
select HAVE_IMX_ANATOP
798799
select HAVE_IMX_GPC
799800
select HAVE_IMX_MMDC

0 commit comments

Comments
 (0)