diff options
author | Andreas Larsson <andreas@gaisler.com> | 2013-06-10 02:53:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-19 05:10:29 -0400 |
commit | 1ffbc51a0d00e52983c70aa7c8dbc7b621d6287d (patch) | |
tree | 3b5e0a1a91a2dfde1b93d2d3295d1170ffe2bae3 /arch/sparc/kernel/leon_kernel.c | |
parent | 117a0c5fc9c2d06045bd217385b2b39ea426b5a6 (diff) |
sparc32, leon: Remove separate "ticker" timer for SMP
This reduces the need from two timers to one timer.
Moreover, without this patch, when the "ticker" timer triggers timer_cs_read via
tick_periodic it reads the value of the usual timer it can get an wrapped timer
value without timer_cs_internal_counter having been updated leading to the clock
going backwards. This effectively hangs one cpu that gets stuck in
update_wall_time with an offset slightly smaller than 0xffffffffffffffff.
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/leon_kernel.c')
-rw-r--r-- | arch/sparc/kernel/leon_kernel.c | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c index 7c0231dabe44..b7c68976cbc7 100644 --- a/arch/sparc/kernel/leon_kernel.c +++ b/arch/sparc/kernel/leon_kernel.c | |||
@@ -38,7 +38,6 @@ static DEFINE_SPINLOCK(leon_irq_lock); | |||
38 | 38 | ||
39 | unsigned long leon3_gptimer_irq; /* interrupt controller irq number */ | 39 | unsigned long leon3_gptimer_irq; /* interrupt controller irq number */ |
40 | unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */ | 40 | unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */ |
41 | int leon3_ticker_irq; /* Timer ticker IRQ */ | ||
42 | unsigned int sparc_leon_eirq; | 41 | unsigned int sparc_leon_eirq; |
43 | #define LEON_IMASK(cpu) (&leon3_irqctrl_regs->mask[cpu]) | 42 | #define LEON_IMASK(cpu) (&leon3_irqctrl_regs->mask[cpu]) |
44 | #define LEON_IACK (&leon3_irqctrl_regs->iclear) | 43 | #define LEON_IACK (&leon3_irqctrl_regs->iclear) |
@@ -278,6 +277,9 @@ irqreturn_t leon_percpu_timer_ce_interrupt(int irq, void *unused) | |||
278 | 277 | ||
279 | leon_clear_profile_irq(cpu); | 278 | leon_clear_profile_irq(cpu); |
280 | 279 | ||
280 | if (cpu == boot_cpu_id) | ||
281 | timer_interrupt(irq, NULL); | ||
282 | |||
281 | ce = &per_cpu(sparc32_clockevent, cpu); | 283 | ce = &per_cpu(sparc32_clockevent, cpu); |
282 | 284 | ||
283 | irq_enter(); | 285 | irq_enter(); |
@@ -299,6 +301,7 @@ void __init leon_init_timers(void) | |||
299 | int icsel; | 301 | int icsel; |
300 | int ampopts; | 302 | int ampopts; |
301 | int err; | 303 | int err; |
304 | u32 config; | ||
302 | 305 | ||
303 | sparc_config.get_cycles_offset = leon_cycles_offset; | 306 | sparc_config.get_cycles_offset = leon_cycles_offset; |
304 | sparc_config.cs_period = 1000000 / HZ; | 307 | sparc_config.cs_period = 1000000 / HZ; |
@@ -377,23 +380,6 @@ void __init leon_init_timers(void) | |||
377 | LEON3_BYPASS_STORE_PA( | 380 | LEON3_BYPASS_STORE_PA( |
378 | &leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 0); | 381 | &leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 0); |
379 | 382 | ||
380 | #ifdef CONFIG_SMP | ||
381 | leon3_ticker_irq = leon3_gptimer_irq + 1 + leon3_gptimer_idx; | ||
382 | |||
383 | if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) & | ||
384 | (1<<LEON3_GPTIMER_SEPIRQ))) { | ||
385 | printk(KERN_ERR "timer not configured with separate irqs\n"); | ||
386 | BUG(); | ||
387 | } | ||
388 | |||
389 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].val, | ||
390 | 0); | ||
391 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].rld, | ||
392 | (((1000000/HZ) - 1))); | ||
393 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl, | ||
394 | 0); | ||
395 | #endif | ||
396 | |||
397 | /* | 383 | /* |
398 | * The IRQ controller may (if implemented) consist of multiple | 384 | * The IRQ controller may (if implemented) consist of multiple |
399 | * IRQ controllers, each mapped on a 4Kb boundary. | 385 | * IRQ controllers, each mapped on a 4Kb boundary. |
@@ -416,13 +402,6 @@ void __init leon_init_timers(void) | |||
416 | if (eirq != 0) | 402 | if (eirq != 0) |
417 | leon_eirq_setup(eirq); | 403 | leon_eirq_setup(eirq); |
418 | 404 | ||
419 | irq = _leon_build_device_irq(NULL, leon3_gptimer_irq+leon3_gptimer_idx); | ||
420 | err = request_irq(irq, timer_interrupt, IRQF_TIMER, "timer", NULL); | ||
421 | if (err) { | ||
422 | printk(KERN_ERR "unable to attach timer IRQ%d\n", irq); | ||
423 | prom_halt(); | ||
424 | } | ||
425 | |||
426 | #ifdef CONFIG_SMP | 405 | #ifdef CONFIG_SMP |
427 | { | 406 | { |
428 | unsigned long flags; | 407 | unsigned long flags; |
@@ -439,30 +418,31 @@ void __init leon_init_timers(void) | |||
439 | } | 418 | } |
440 | #endif | 419 | #endif |
441 | 420 | ||
442 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, | 421 | config = LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config); |
443 | LEON3_GPTIMER_EN | | 422 | if (config & (1 << LEON3_GPTIMER_SEPIRQ)) |
444 | LEON3_GPTIMER_RL | | 423 | leon3_gptimer_irq += leon3_gptimer_idx; |
445 | LEON3_GPTIMER_LD | | 424 | else if ((config & LEON3_GPTIMER_TIMERS) > 1) |
446 | LEON3_GPTIMER_IRQEN); | 425 | pr_warn("GPTIMER uses shared irqs, using other timers of the same core will fail.\n"); |
447 | 426 | ||
448 | #ifdef CONFIG_SMP | 427 | #ifdef CONFIG_SMP |
449 | /* Install per-cpu IRQ handler for broadcasted ticker */ | 428 | /* Install per-cpu IRQ handler for broadcasted ticker */ |
450 | irq = leon_build_device_irq(leon3_ticker_irq, handle_percpu_irq, | 429 | irq = leon_build_device_irq(leon3_gptimer_irq, handle_percpu_irq, |
451 | "per-cpu", 0); | 430 | "per-cpu", 0); |
452 | err = request_irq(irq, leon_percpu_timer_ce_interrupt, | 431 | err = request_irq(irq, leon_percpu_timer_ce_interrupt, |
453 | IRQF_PERCPU | IRQF_TIMER, "ticker", | 432 | IRQF_PERCPU | IRQF_TIMER, "timer", NULL); |
454 | NULL); | 433 | #else |
434 | irq = _leon_build_device_irq(NULL, leon3_gptimer_irq); | ||
435 | err = request_irq(irq, timer_interrupt, IRQF_TIMER, "timer", NULL); | ||
436 | #endif | ||
455 | if (err) { | 437 | if (err) { |
456 | printk(KERN_ERR "unable to attach ticker IRQ%d\n", irq); | 438 | pr_err("Unable to attach timer IRQ%d\n", irq); |
457 | prom_halt(); | 439 | prom_halt(); |
458 | } | 440 | } |
459 | 441 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, | |
460 | LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl, | ||
461 | LEON3_GPTIMER_EN | | 442 | LEON3_GPTIMER_EN | |
462 | LEON3_GPTIMER_RL | | 443 | LEON3_GPTIMER_RL | |
463 | LEON3_GPTIMER_LD | | 444 | LEON3_GPTIMER_LD | |
464 | LEON3_GPTIMER_IRQEN); | 445 | LEON3_GPTIMER_IRQEN); |
465 | #endif | ||
466 | return; | 446 | return; |
467 | bad: | 447 | bad: |
468 | printk(KERN_ERR "No Timer/irqctrl found\n"); | 448 | printk(KERN_ERR "No Timer/irqctrl found\n"); |