Complete set of clocksource/sched_clock patches
Subsystems (19)
cover Complete set of clocksource/sched_clock patches
Here is the entire set of clocksource and sched_clock patches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.
Still looking for acks or tested-by's for these patches.
PATCH 1/40 ARM: AT91: update clock source registration
In d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-at91/at91rm9200_time.c | 4 +--- arch/arm/mach-at91/at91sam926x_time.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
arch/arm/mach-at91/at91rm9200_time.c +1 -3
@@ -101,7 +101,6 @@ static struct clocksource clk32k = { .rating = 150, .read = read_clk32k, .mask = CLOCKSOURCE_MASK(20), - .shift = 10, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -201,8 +200,7 @@ void __init at91rm9200_timer_init(void)clockevents_register_device (&clkevt);/* register clocksource */ - clk32k.mult =clocksource_hz2mult (AT91_SLOW_CLOCK , clk32k.shift); -clocksource_register (&clk32k); +clocksource_register_hz (&clk32k,AT91_SLOW_CLOCK ); }struct sys_timer at91rm9200_timer = {
arch/arm/mach-at91/at91sam926x_time.c +1 -3
@@ -51,7 +51,6 @@ static struct clocksource pit_clk = { .name = "pit", .rating = 175, .read = read_pit_clk, - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -163,10 +162,9 @@ static void __init at91sam926x_pit_init(void)* Register clocksource. The high order bits of PIV are unused, * so this isn't a 32-bit counter unless we get clockevent irqs. */ - pit_clk.mult =clocksource_hz2mult (pit_rate, pit_clk.shift); bits =12 /* PICNT */ +ilog2 (pit_cycle)/* PIV */ ; pit_clk.mask =CLOCKSOURCE_MASK (bits); -clocksource_register (&pit_clk); +clocksource_register_hz (&pit_clk, pit_rate);/* Set up irq handler */ setup_irq (AT91_ID_SYS , &at91sam926x_pit_irq);
Signature · 1 line
1.6.2.5
PATCH 1/40 ARM: AT91: update clock source registration
Quoted 5 lines · Russell King - ARM Linux
In d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
Signed-off-by Russell King <[email protected]>
I'll test it monday
Best Regards,
J.
PATCH 2/40 ARM: bcmring: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-bcmring/core.c | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-)
arch/arm/mach-bcmring/core.c +4 -10
@@ -294,7 +294,6 @@ static struct clocksource clocksource_bcmring_timer1 = { .rating = 200, .read = bcmring_get_cycles_timer1, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -303,7 +302,6 @@ static struct clocksource clocksource_bcmring_timer3 = { .rating = 100, .read = bcmring_get_cycles_timer3, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -316,10 +314,8 @@ static int __init bcmring_clocksource_init(void)writel (TIMER_CTRL_32BIT |TIMER_CTRL_ENABLE |TIMER_CTRL_PERIODIC ,TIMER1_VA_BASE +TIMER_CTRL ); - clocksource_bcmring_timer1.mult = -clocksource_khz2mult (TIMER1_FREQUENCY_MHZ *1000 , - clocksource_bcmring_timer1.shift); -clocksource_register (&clocksource_bcmring_timer1); +clocksource_register_khz (&clocksource_bcmring_timer1, +TIMER1_FREQUENCY_MHZ *1000 );/* setup timer3 as free-running clocksource */ writel (0 ,TIMER3_VA_BASE +TIMER_CTRL );
@@ -328,10 +324,8 @@ static int __init bcmring_clocksource_init(void)writel (TIMER_CTRL_32BIT |TIMER_CTRL_ENABLE |TIMER_CTRL_PERIODIC ,TIMER3_VA_BASE +TIMER_CTRL ); - clocksource_bcmring_timer3.mult = -clocksource_khz2mult (TIMER3_FREQUENCY_KHZ , - clocksource_bcmring_timer3.shift); -clocksource_register (&clocksource_bcmring_timer3); +clocksource_register_khz (&clocksource_bcmring_timer3, +TIMER3_FREQUENCY_KHZ );return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 3/40 ARM: davinci: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-davinci/time.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
arch/arm/mach-davinci/time.c +2 -5
@@ -276,7 +276,6 @@ static struct clocksource clocksource_davinci = { .rating = 300, .read = read_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 24, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -378,10 +377,8 @@ static void __init davinci_timer_init(void)/* setup clocksource */ clocksource_davinci.name = id_to_name[clocksource_id]; - clocksource_davinci.mult = -clocksource_khz2mult (davinci_clock_tick_rate/1000 , - clocksource_davinci.shift); -if (clocksource_register (&clocksource_davinci)) +if (clocksource_register_hz (&clocksource_davinci, + davinci_clock_tick_rate))printk (err, clocksource_davinci.name);/* setup clockevent */
Signature · 1 line
1.6.2.5
PATCH 3/40 ARM: davinci: update clock source registration
Quoted 5 lines · Russell King - ARM Linux
In d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
Signed-off-by Russell King <[email protected]>
Quoted 29 lines
--- arch/arm/mach-davinci/time.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)arch/arm/mach-davinci/time.c +2
-5@@ -276,7 +276,6 @@ static struct clocksource clocksource_davinci = { .rating = 300, .read = read_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 24, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };@@ -378,10 +377,8 @@ static void __init davinci_timer_init(void)/* setup clocksource */ clocksource_davinci.name = id_to_name[clocksource_id]; - clocksource_davinci.mult = -clocksource_khz2mult (davinci_clock_tick_rate/1000 , - clocksource_davinci.shift); -if (clocksource_register (&clocksource_davinci)) +if (clocksource_register_hz (&clocksource_davinci, + davinci_clock_tick_rate))printk (err, clocksource_davinci.name);/* setup clockevent */
PATCH 4/40 ARM: integrator: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-integrator/integrator_ap.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/mach-integrator/integrator_ap.c +1 -3
@@ -372,7 +372,6 @@ static struct clocksource clocksource_timersp = { .rating = 200, .read = timersp_read, .mask = CLOCKSOURCE_MASK(16), - .shift = 16, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -390,8 +389,7 @@ static void integrator_clocksource_init(u32 khz)writel (ctrl, base +TIMER_CTRL );writel (0xffff , base +TIMER_LOAD ); - cs->mult =clocksource_khz2mult (khz, cs->shift); -clocksource_register (cs); +clocksource_register_khz (cs, khz); }static void __iomem *const clkevt_base = (void __iomem *)TIMER1_VA_BASE ;
Signature · 1 line
1.6.2.5
PATCH 5/40 ARM: ixp4xx: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-ixp4xx/common.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/mach-ixp4xx/common.c +1 -5
@@ -411,7 +411,6 @@ static struct clocksource clocksource_ixp4xx = { .rating = 200, .read = ixp4xx_get_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -419,10 +418,7 @@ unsigned long ixp4xx_timer_freq = FREQ;EXPORT_SYMBOL (ixp4xx_timer_freq);static void __init ixp4xx_clocksource_init (void ) { - clocksource_ixp4xx.mult = -clocksource_hz2mult (ixp4xx_timer_freq, - clocksource_ixp4xx.shift); -clocksource_register (&clocksource_ixp4xx); +clocksource_register_hz (&clocksource_ixp4xx, ixp4xx_timer_freq); }/*
Signature · 1 line
1.6.2.5
PATCH 6/40 ARM: lpc32xx: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-lpc32xx/timer.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/mach-lpc32xx/timer.c +1 -4
@@ -38,7 +38,6 @@ static cycle_t lpc32xx_clksrc_read(struct clocksource *cs)static struct clocksource lpc32xx_clksrc = { .name ="lpc32xx_clksrc" , - .shift =24 , .rating =300 , .read = lpc32xx_clksrc_read, .mask =CLOCKSOURCE_MASK (32 ),
@@ -171,9 +170,7 @@ static void __init lpc32xx_timer_init(void)__raw_writel (0 ,LCP32XX_TIMER_MCR (LPC32XX_TIMER1_BASE ));__raw_writel (LCP32XX_TIMER_CNTR_TCR_EN ,LCP32XX_TIMER_TCR (LPC32XX_TIMER1_BASE )); - lpc32xx_clksrc.mult =clocksource_hz2mult (clkrate, - lpc32xx_clksrc.shift); -clocksource_register (&lpc32xx_clksrc); +clocksource_register_hz (&lpc32xx_clksrc, clkrate); }struct sys_timer lpc32xx_timer = {
Signature · 1 line
1.6.2.5
PATCH 7/40 ARM: mmp: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-mmp/time.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/mach-mmp/time.c +1 -4
@@ -146,7 +146,6 @@ static cycle_t clksrc_read(struct clocksource *cs)static struct clocksource cksrc = { .name ="clocksource" , - .shift =20 , .rating =200 , .read = clksrc_read, .mask =CLOCKSOURCE_MASK (32 ),
@@ -193,10 +192,8 @@ void __init timer_init(int irq) ckevt.min_delta_ns =clockevent_delta2ns (MIN_DELTA , &ckevt); ckevt.cpumask =cpumask_of (0 ); - cksrc.mult =clocksource_hz2mult (CLOCK_TICK_RATE , cksrc.shift); -setup_irq (irq, &timer_irq); -clocksource_register (&cksrc); +clocksource_register_hz (&cksrc,CLOCK_TICK_RATE );clockevents_register_device (&ckevt); }
Signature · 1 line
1.6.2.5
PATCH 8/40 ARM: MSM: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-msm/timer.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/mach-msm/timer.c +1 -4
@@ -137,7 +137,6 @@ static struct msm_clock msm_clocks[] = { .rating = 200, .read = msm_gpt_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 17, .flags = CLOCK_SOURCE_IS_CONTINUOUS, }, .irq = {
@@ -164,7 +163,6 @@ static struct msm_clock msm_clocks[] = { .rating = 300, .read = msm_dgt_read, .mask = CLOCKSOURCE_MASK((32 - MSM_DGT_SHIFT)), - .shift = 24 - MSM_DGT_SHIFT, .flags = CLOCK_SOURCE_IS_CONTINUOUS, }, .irq = {
@@ -205,8 +203,7 @@ static void __init msm_timer_init(void) ce->min_delta_ns =clockevent_delta2ns (4 , ce); ce->cpumask =cpumask_of (0 ); - cs->mult =clocksource_hz2mult (clock->freq, cs->shift); - res =clocksource_register (cs); + res =clocksource_register_hz (cs, clock->freq);if (res)printk (KERN_ERR "msm_timer_init: clocksource_register " "failed for %s\n" , cs->name);
Signature · 1 line
1.6.2.5
PATCH 8/40 ARM: MSM: update clock source registration
Quoted 6 lines · Russell King - ARM Linux
In d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
Tested-by Jeff Ohlstein <[email protected]>Signed-off-by Russell King <[email protected]>
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 9/40 ARM: netx: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-netx/time.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/mach-netx/time.c +1 -4
@@ -114,7 +114,6 @@ static struct clocksource clocksource_netx = { .rating = 200, .read = netx_get_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -151,9 +150,7 @@ static void __init netx_timer_init(void)writel (NETX_GPIO_COUNTER_CTRL_RUN ,NETX_GPIO_COUNTER_CTRL (TIMER_CLOCKSOURCE )); - clocksource_netx.mult = -clocksource_hz2mult (CLOCK_TICK_RATE , clocksource_netx.shift); -clocksource_register (&clocksource_netx); +clocksource_register_hz (&clocksource_netx,CLOCK_TICK_RATE ); netx_clockevent.mult =div_sc (CLOCK_TICK_RATE ,NSEC_PER_SEC , netx_clockevent.shift);
Signature · 1 line
1.6.2.5
PATCH 10/40 ARM: ns9xxx: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-ns9xxx/time-ns9360.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/mach-ns9xxx/time-ns9360.c +1 -5
@@ -35,7 +35,6 @@ static struct clocksource ns9360_clocksource = { .rating = 300, .read = ns9360_clocksource_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -148,10 +147,7 @@ static void __init ns9360_timer_init(void)__raw_writel (tc,SYS_TC (TIMER_CLOCKSOURCE )); - ns9360_clocksource.mult =clocksource_hz2mult (ns9360_cpuclock (), - ns9360_clocksource.shift); - -clocksource_register (&ns9360_clocksource); +clocksource_register_hz (&ns9360_clocksource,ns9360_cpuclock ()); latch =SH_DIV (ns9360_cpuclock (),HZ ,0 );
Signature · 1 line
1.6.2.5
PATCH 11/40 ARM: omap: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-omap1/time.c | 6 +----- arch/arm/mach-omap2/timer-gp.c | 5 +---- arch/arm/plat-omap/counter_32k.c | 6 +----- 3 files changed, 3 insertions(+), 14 deletions(-)
arch/arm/mach-omap1/time.c +1 -5
@@ -208,7 +208,6 @@ static struct clocksource clocksource_mpu = { .rating = 300, .read = mpu_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 24, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -217,13 +216,10 @@ static void __init omap_init_clocksource(unsigned long rate)static char err[]__initdata =KERN_ERR "%s: can't register clocksource!\n" ; - clocksource_mpu.mult - =clocksource_khz2mult (rate/1000 , clocksource_mpu.shift); -setup_irq (INT_TIMER2 , &omap_mpu_timer2_irq);omap_mpu_timer_start (1 , ~0 ,1 ); -if (clocksource_register (&clocksource_mpu)) +if (clocksource_register_hz (&clocksource_mpu, rate))printk (err, clocksource_mpu.name); }
arch/arm/mach-omap2/timer-gp.c +1 -4
@@ -195,7 +195,6 @@ static struct clocksource clocksource_gpt = { .rating = 300, .read = clocksource_read_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 24, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -220,9 +219,7 @@ static void __init omap2_gp_clocksource_init(void)omap_dm_timer_set_load_start (gpt,1 ,0 ); - clocksource_gpt.mult = -clocksource_khz2mult (tick_rate/1000 , clocksource_gpt.shift); -if (clocksource_register (&clocksource_gpt)) +if (clocksource_register_hz (&clocksource_gpt, tick_rate)) printk(err2, clocksource_gpt.name); }#endif
arch/arm/plat-omap/counter_32k.c +1 -5
@@ -102,7 +102,6 @@ static struct clocksource clocksource_32k = { .rating = 250, .read = omap_32k_read_dummy, .mask = CLOCKSOURCE_MASK(32), - .shift = 10, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -167,12 +166,9 @@ static int __init omap_init_clocksource_32k(void)if (sync_32k_ick)clk_enable (sync_32k_ick); - clocksource_32k.mult =clocksource_hz2mult (32768 , - clocksource_32k.shift); - offset_32k = clocksource_32k.read (&clocksource_32k); -if (clocksource_register (&clocksource_32k)) +if (clocksource_register_hz (&clocksource_32k,32768 ))printk (err, clocksource_32k.name); }return 0 ;
Signature · 1 line
1.6.2.5
PATCH 12/40 ARM: PXA: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-pxa/time.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/mach-pxa/time.c +1 -5
@@ -127,7 +127,6 @@ static struct clocksource cksrc_pxa_oscr0 = { .rating = 200, .read = pxa_read_oscr, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -155,12 +154,9 @@ static void __init pxa_timer_init(void)clockevent_delta2ns (MIN_OSCR_DELTA *2 , &ckevt_pxa_osmr0) +1 ; ckevt_pxa_osmr0.cpumask =cpumask_of (0 ); - cksrc_pxa_oscr0.mult = -clocksource_hz2mult (clock_tick_rate, cksrc_pxa_oscr0.shift); -setup_irq (IRQ_OST0 , &pxa_ost0_irq); -clocksource_register (&cksrc_pxa_oscr0); +clocksource_register_hz (&cksrc_pxa_oscr0, clock_tick_rate);clockevents_register_device (&ckevt_pxa_osmr0); }
Signature · 1 line
1.6.2.5
PATCH 13/40 ARM: s5pv310: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-s5pv310/time.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/mach-s5pv310/time.c +1 -5
@@ -211,7 +211,6 @@ struct clocksource pwm_clocksource = { .rating = 250, .read = s5pv310_pwm4_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS , };
@@ -230,10 +229,7 @@ static void __init s5pv310_clocksource_init(void)s5pv310_pwm_init (4 , ~0 );s5pv310_pwm_start (4 ,1 ); - pwm_clocksource.mult = -clocksource_khz2mult (clock_rate/1000 , pwm_clocksource.shift); - -if (clocksource_register (&pwm_clocksource)) +if (clocksource_register_hz (&pwm_clocksource, clock_rate))panic ("%s: can't register clocksource\n" , pwm_clocksource.name); }
Signature · 1 line
1.6.2.5
PATCH 14/40 ARM: SA11x0: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-sa1100/time.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/mach-sa1100/time.c +1 -5
@@ -81,7 +81,6 @@ static struct clocksource cksrc_sa1100_oscr = { .rating = 200, .read = sa1100_read_oscr, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -105,12 +104,9 @@ static void __init sa1100_timer_init(void)clockevent_delta2ns (MIN_OSCR_DELTA *2 , &ckevt_sa1100_osmr0) +1 ; ckevt_sa1100_osmr0.cpumask =cpumask_of (0 ); - cksrc_sa1100_oscr.mult = -clocksource_hz2mult (CLOCK_TICK_RATE , cksrc_sa1100_oscr.shift); -setup_irq (IRQ_OST0 , &sa1100_timer_irq); -clocksource_register (&cksrc_sa1100_oscr); +clocksource_register_hz (&cksrc_sa1100_oscr,CLOCK_TICK_RATE );clockevents_register_device (&ckevt_sa1100_osmr0); }
Signature · 1 line
1.6.2.5
PATCH 15/40 ARM: tcc8k: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-tcc8k/time.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/mach-tcc8k/time.c +1 -4
@@ -35,7 +35,6 @@ static struct clocksource clocksource_tcc = { .rating = 200, .read = tcc_get_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 28, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -103,9 +102,7 @@ static int __init tcc_clockevent_init(struct clk *clock) {unsigned int c =clk_get_rate (clock); - clocksource_tcc.mult =clocksource_hz2mult (c, - clocksource_tcc.shift); -clocksource_register (&clocksource_tcc); +clocksource_register_hz (&clocksource_tcc, c); clockevent_tcc.mult =div_sc (c,NSEC_PER_SEC , clockevent_tcc.shift);
Signature · 1 line
1.6.2.5
PATCH 16/40 ARM: U300: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-u300/timer.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/mach-u300/timer.c +1 -3
@@ -412,9 +412,7 @@ static void __init u300_timer_init(void)writel (U300_TIMER_APP_EGPT2_TIMER_ENABLE ,U300_TIMER_APP_VBASE +U300_TIMER_APP_EGPT2 ); -clocksource_calc_mult_shift (&clocksource_u300_1mhz, - rate,APPTIMER_MIN_RANGE ); -if (clocksource_register (&clocksource_u300_1mhz)) +if (clocksource_register_hz (&clocksource_u300_1mhz, rate))printk (KERN_ERR "timer: failed to initialize clock " "source %s\n" , clocksource_u300_1mhz.name);
Signature · 1 line
1.6.2.5
PATCH 17/40 ARM: nuc: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/mach-w90x900/time.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/mach-w90x900/time.c +1 -4
@@ -153,7 +153,6 @@ static struct clocksource clocksource_nuc900 = { .rating = 200, .read = nuc900_get_cycles, .mask = CLOCKSOURCE_MASK(TDR_SHIFT), - .shift = 10, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -176,9 +175,7 @@ static void __init nuc900_clocksource_init(void) val |= (COUNTEN |PERIOD |PRESCALE );__raw_writel (val,REG_TCSR1 ); - clocksource_nuc900.mult = -clocksource_khz2mult ((rate /1000 ), clocksource_nuc900.shift); -clocksource_register (&clocksource_nuc900); +clocksource_register_hz (&clocksource_nuc900, rate); }static void __init nuc900_timer_init (void )
Signature · 1 line
1.6.2.5
PATCH 17/40 ARM: nuc: update clock source registration
2010/12/17 Russell King - ARM Linux <[email protected]>:
Quoted 22 lines
In d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. ?Switch over to using this new interface.
Signed-off-by Russell King <[email protected]>---
?arch/arm/mach-w90x900/time.c | ? ?5 +----
?1 files changed, 1 insertions(+), 4 deletions(-)arch/arm/mach-w90x900/time.c +0
-1@@ -153,7 +153,6 @@ static struct clocksource clocksource_nuc900 = { ? ? ? ?.rating = 200, ? ? ? ?.read ? = nuc900_get_cycles, ? ? ? ?.mask ? = CLOCKSOURCE_MASK(TDR_SHIFT), - ? ? ? .shift ?= 10, ? ? ? ?.flags ?= CLOCK_SOURCE_IS_CONTINUOUS, ?};
arch/arm/mach-w90x900/time.c static void __init nuc900_clocksource_init(void) · line 181
Quoted 10 lines
arch/arm/mach-w90x900/time.c +1
-3@@ -176,9 +175,7 @@ static void __init nuc900_clocksource_init(void) ? ? ? ?val |= (COUNTEN | PERIOD | PRESCALE); ? ? ? ?__raw_writel(val, REG_TCSR1); - ? ? ? clocksource_nuc900.mult = - ? ? ? ? ? ? ? clocksource_khz2mult((rate / 1000), clocksource_nuc900.shift); - ? ? ? clocksource_register(&clocksource_nuc900); + ? ? ? clocksource_register_hz(&clocksource_nuc900, rate); ?} ?static void __init nuc900_timer_init(void)
Quoted 4 lines
--
1.6.2.5
Signature · 10 lines
*linux-arm-kernel mailing list mail addr:linux-arm-kernel at lists.infradead.org you can subscribe by: http://lists.infradead.org/mailman/listinfo/linux-arm-kernel * linux-arm-NUC900 mailing list mail addr:NUC900 at googlegroups.com main web: https://groups.google.com/group/NUC900 you can subscribe it by sending me mail: mcuos.com at gmail.com
PATCH 18/40 ARM: iop: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-iop/time.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/plat-iop/time.c +1 -3
@@ -171,7 +171,5 @@ void __init iop_init_time(unsigned long tick_rate)write_trr1 (0xffffffff );write_tcr1 (0xffffffff );write_tmr1 (timer_ctl); -clocksource_calc_mult_shift (&iop_clocksource, tick_rate, -IOP_MIN_RANGE ); -clocksource_register (&iop_clocksource); +clocksource_register_hz (&iop_clocksource, tick_rate); }
Signature · 1 line
1.6.2.5
PATCH 19/40 ARM: mxc: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-mxc/epit.c | 5 +---- arch/arm/plat-mxc/time.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-)
arch/arm/plat-mxc/epit.c +1 -4
@@ -93,7 +93,6 @@ static struct clocksource clocksource_epit = { .rating = 200, .read = epit_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -101,9 +100,7 @@ static int __init epit_clocksource_init(struct clk *timer_clk) {unsigned int c =clk_get_rate (timer_clk); - clocksource_epit.mult =clocksource_hz2mult (c, - clocksource_epit.shift); -clocksource_register (&clocksource_epit); +clocksource_register_hz (&clocksource_epit, c);return 0 ; }
arch/arm/plat-mxc/time.c +1 -4
@@ -120,7 +120,6 @@ static struct clocksource clocksource_mxc = { .rating = 200, .read = mx1_2_get_cycles, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -131,9 +130,7 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)if (timer_is_v2 ()) clocksource_mxc.read = v2_get_cycles; - clocksource_mxc.mult =clocksource_hz2mult (c, - clocksource_mxc.shift); -clocksource_register (&clocksource_mxc); +clocksource_register_hz (&clocksource_mxc, c);return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 20/40 ARM: nomadik: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-nomadik/timer.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
arch/arm/plat-nomadik/timer.c +1 -2
@@ -222,7 +222,6 @@ void __init nmdk_timer_init(void) }else { cr |= MTU_CRn_PRESCALE_1; } -clocksource_calc_mult_shift (&nmdk_clksrc, rate,MTU_MIN_RANGE );/* Timer 0 is the free running clocksource */ writel (cr, mtu_base +MTU_CR (0 ));
@@ -233,7 +232,7 @@ void __init nmdk_timer_init(void)/* Now the clock source is ready */ nmdk_clksrc.read = nmdk_read_timer; -if (clocksource_register (&nmdk_clksrc)) +if (clocksource_register_hz (&nmdk_clksrc, rate))pr_err ("timer: failed to initialize clock source %s\n" , nmdk_clksrc.name);
Signature · 1 line
1.6.2.5
PATCH 21/40 ARM: spear: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-spear/time.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
arch/arm/plat-spear/time.c +1 -5
@@ -81,8 +81,6 @@ static struct clocksource clksrc = { .rating = 200, /* its a pretty decent clock */ .read = clocksource_read_cycles, .mask = 0xFFFF, /* 16 bits */ - .mult = 0, /* to be computed */ - .shift = 0, /* to be computed */ .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -105,10 +103,8 @@ static void spear_clocksource_init(void) val |=CTRL_ENABLE ;writew (val, gpt_base +CR (CLKSRC )); -clocksource_calc_mult_shift (&clksrc, tick_rate,SPEAR_MIN_RANGE ); -/* register the clocksource */ -clocksource_register (&clksrc); +clocksource_register_hz (&clksrc, tick_rate); }static struct clock_event_device clkevt = {
Signature · 1 line
1.6.2.5
PATCH 22/40 ARM: orion: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-orion/time.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/plat-orion/time.c +1 -3
@@ -102,7 +102,6 @@ static cycle_t orion_clksrc_read(struct clocksource *cs)static struct clocksource orion_clksrc = { .name ="orion_clocksource" , - .shift =20 , .rating =300 , .read = orion_clksrc_read, .mask =CLOCKSOURCE_MASK (32 ),
@@ -245,8 +244,7 @@ void __init orion_time_init(unsigned int irq, unsigned int tclk)writel (u & ~BRIDGE_INT_TIMER0 ,BRIDGE_MASK ); u =readl (TIMER_CTRL );writel (u |TIMER0_EN |TIMER0_RELOAD_EN ,TIMER_CTRL ); - orion_clksrc.mult =clocksource_hz2mult (tclk, orion_clksrc.shift); -clocksource_register (&orion_clksrc); +clocksource_register_hz (&orion_clksrc, tclk);/* * Setup clockevent timer (interrupt-driven.)
Signature · 1 line
1.6.2.5
PATCH 23/40 ARM: stmp: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-stmp3xxx/timer.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/arm/plat-stmp3xxx/timer.c +1 -4
@@ -89,7 +89,6 @@ static struct clocksource cksrc_stmp3xxx = { .rating = 250, .read = stmp3xxx_clock_read, .mask = CLOCKSOURCE_MASK(16), - .shift = 10, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -106,8 +105,6 @@ static struct irqaction stmp3xxx_timer_irq = {*/ static void __init stmp3xxx_init_timer (void ) { - cksrc_stmp3xxx.mult =clocksource_hz2mult (CLOCK_TICK_RATE , - cksrc_stmp3xxx.shift); ckevt_timrot.mult =div_sc (CLOCK_TICK_RATE ,NSEC_PER_SEC , ckevt_timrot.shift); ckevt_timrot.min_delta_ns =clockevent_delta2ns (2 , &ckevt_timrot);
@@ -140,7 +137,7 @@ static void __init stmp3xxx_init_timer(void)setup_irq (IRQ_TIMER0 , &stmp3xxx_timer_irq); -clocksource_register (&cksrc_stmp3xxx); +clocksource_register_hz (&cksrc_stmp3xxx,CLOCK_TICK_RATE );clockevents_register_device (&ckevt_timrot); }
Signature · 1 line
1.6.2.5
PATCH 24/40 ARM: realview/versatile: update clock source registration
In reply to Russell King - ARM LinuxIn d7e81c2 (clocksource: Add clocksource_register_hz/khz interface) new interfaces were added which simplify (and optimize) the selection of the divisor shift/mult constants. Switch over to using this new interface.
--- arch/arm/plat-versatile/timer-sp.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/plat-versatile/timer-sp.c +1 -3
@@ -46,7 +46,6 @@ static struct clocksource clocksource_sp804 = { .rating = 200, .read = sp804_read, .mask = CLOCKSOURCE_MASK(32), - .shift = 20, .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
@@ -63,8 +62,7 @@ void __init sp804_clocksource_init(void __iomem *base)writel (TIMER_CTRL_32BIT |TIMER_CTRL_ENABLE |TIMER_CTRL_PERIODIC , clksrc_base +TIMER_CTRL ); - cs->mult =clocksource_khz2mult (TIMER_FREQ_KHZ , cs->shift); -clocksource_register (cs); +clocksource_register_khz (cs,TIMER_FREQ_KHZ ); }
Signature · 1 line
1.6.2.5
PATCH 25/40 ARM: tegra: timer: Separate clocksource and sched_clock
In reply to Russell King - ARM Linuxtegra_clocksource_read should not use cnt32_to_63, wrapping is already handled in the clocksource code. Move the cnt32_to_63 into the sched_clock function, and replace the use of clocksource mult and shift with a multiplication by 1000 to convert us to ns.
--- arch/arm/mach-tegra/timer.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/arm/mach-tegra/timer.c +3 -4
@@ -91,7 +91,7 @@ static void tegra_timer_set_mode(enum clock_event_mode mode,static cycle_t tegra_clocksource_read (struct clocksource *cs) { -return cnt32_to_63 (timer_readl (TIMERUS_CNTR_1US )); +return timer_readl (TIMERUS_CNTR_1US ); }static struct clock_event_device tegra_clockevent = {
@@ -106,14 +106,13 @@ static struct clocksource tegra_clocksource = { .name = "timer_us", .rating = 300, .read = tegra_clocksource_read, - .mask = 0x7FFFFFFFFFFFFFFFULL, + .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, };unsigned long long sched_clock (void ) { -return clocksource_cyc2ns (tegra_clocksource.read (&tegra_clocksource), - tegra_clocksource.mult, tegra_clocksource.shift); +return cnt32_to_63 (timer_readl (TIMERUS_CNTR_1US )) *1000 ; }static irqreturn_t tegra_timer_interrupt (int irq,void *dev_id)
Signature · 1 line
1.6.2.5
PATCH 26/40 ARM: ensure all sched_clock() implementations are notrace marked
In reply to Russell King - ARM Linuxftrace requires sched_clock() to be notrace. Ensure that all implementations are so marked. Also make sure that they include linux/sched.h
Also ensure OMAP clocksource read functions are marked notrace as they're used for sched_clock() too.
--- arch/arm/mach-ixp4xx/common.c | 2 +- arch/arm/mach-mmp/time.c | 2 +- arch/arm/mach-pxa/time.c | 2 +- arch/arm/mach-sa1100/generic.c | 2 +- arch/arm/mach-tegra/timer.c | 3 ++- arch/arm/mach-u300/timer.c | 1 + arch/arm/plat-iop/time.c | 3 ++- arch/arm/plat-nomadik/timer.c | 1 + arch/arm/plat-omap/counter_32k.c | 15 ++++++++------- arch/arm/plat-orion/time.c | 2 +- arch/arm/plat-versatile/sched-clock.c | 2 +- 11 files changed, 20 insertions(+), 15 deletions(-)
arch/arm/mach-ixp4xx/common.c +1 -1
@@ -424,7 +424,7 @@ static void __init ixp4xx_clocksource_init(void)/* * sched_clock() */ -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {cycle_t cyc =ixp4xx_get_cycles (NULL );struct clocksource *cs = &clocksource_ixp4xx;
arch/arm/mach-mmp/time.c +1 -1
@@ -75,7 +75,7 @@ static inline uint32_t timer_read(void)return __raw_readl (TIMERS_VIRT_BASE +TMR_CVWR (0 )); } -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {unsigned long long v =cnt32_to_63 (timer_read ());return (v * tcr2ns_scale) >>TCR2NS_SCALE_FACTOR ;
arch/arm/mach-pxa/time.c +1 -1
@@ -51,7 +51,7 @@ static void __init set_oscr2ns_scale(unsigned long oscr_rate) oscr2ns_scale++; } -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {unsigned long long v =cnt32_to_63 (OSCR );return (v * oscr2ns_scale) >>OSCR2NS_SCALE_FACTOR ;
arch/arm/mach-sa1100/generic.c +1 -1
@@ -119,7 +119,7 @@ unsigned int sa11x0_getspeed(unsigned int cpu)* * ( * 1E9 / 3686400 => * 78125 / 288) */ -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {unsigned long long v =cnt32_to_63 (OSCR );
arch/arm/mach-tegra/timer.c +2 -1
@@ -18,6 +18,7 @@*/ #include <linux/init.h> +#include <linux/sched.h> #include <linux/time.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -110,7 +111,7 @@ static struct clocksource tegra_clocksource = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {return cnt32_to_63 (timer_readl (TIMERUS_CNTR_1US )) *1000 ; }
arch/arm/mach-u300/timer.c +1 -0
@@ -9,6 +9,7 @@* Author: Linus Walleij <[email protected]> */ #include <linux/interrupt.h> +#include <linux/sched.h> #include <linux/time.h> #include <linux/timex.h> #include <linux/clockchips.h>
arch/arm/plat-iop/time.c +2 -1
@@ -17,6 +17,7 @@#include <linux/interrupt.h> #include <linux/time.h> #include <linux/init.h> +#include <linux/sched.h> #include <linux/timex.h> #include <linux/io.h> #include <linux/clocksource.h>
@@ -52,7 +53,7 @@ static struct clocksource iop_clocksource = {/* * IOP sched_clock() implementation via its clocksource. */ -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {cycle_t cyc =iop_clocksource_read (NULL );struct clocksource *cs = &iop_clocksource;
arch/arm/plat-nomadik/timer.c +1 -0
@@ -19,6 +19,7 @@#include <linux/err.h> #include <linux/cnt32_to_63.h> #include <linux/timer.h> +#include <linux/sched.h> #include <asm/mach/time.h> #include <plat/mtu.h>
arch/arm/plat-omap/counter_32k.c +8 -7
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/clk.h> #include <linux/io.h> +#include <linux/sched.h> #include <plat/common.h> #include <plat/board.h>
@@ -44,7 +45,7 @@static u32 offset_32k__read_mostly ;#ifdef CONFIG_ARCH_OMAP16XX -static cycle_t omap16xx_32k_read (struct clocksource *cs) +static cycle_t notrace omap16xx_32k_read(struct clocksource *cs) {return omap_readl (OMAP16XX_TIMER_32K_SYNCHRONIZED ) - offset_32k; }
@@ -53,7 +54,7 @@ static cycle_t omap16xx_32k_read(struct clocksource *cs)#endif #ifdef CONFIG_ARCH_OMAP2420 -static cycle_t omap2420_32k_read (struct clocksource *cs) +static cycle_t notrace omap2420_32k_read(struct clocksource *cs) {return omap_readl (OMAP2420_32KSYNCT_BASE +0x10 ) - offset_32k; }
@@ -62,7 +63,7 @@ static cycle_t omap2420_32k_read(struct clocksource *cs)#endif #ifdef CONFIG_ARCH_OMAP2430 -static cycle_t omap2430_32k_read (struct clocksource *cs) +static cycle_t notrace omap2430_32k_read(struct clocksource *cs) {return omap_readl (OMAP2430_32KSYNCT_BASE +0x10 ) - offset_32k; }
@@ -71,7 +72,7 @@ static cycle_t omap2430_32k_read(struct clocksource *cs)#endif #ifdef CONFIG_ARCH_OMAP3 -static cycle_t omap34xx_32k_read (struct clocksource *cs) +static cycle_t notrace omap34xx_32k_read(struct clocksource *cs) {return omap_readl (OMAP3430_32KSYNCT_BASE +0x10 ) - offset_32k; }
@@ -80,7 +81,7 @@ static cycle_t omap34xx_32k_read(struct clocksource *cs)#endif #ifdef CONFIG_ARCH_OMAP4 -static cycle_t omap44xx_32k_read (struct clocksource *cs) +static cycle_t notrace omap44xx_32k_read(struct clocksource *cs) {return omap_readl (OMAP4430_32KSYNCT_BASE +0x10 ) - offset_32k; }
@@ -92,7 +93,7 @@ static cycle_t omap44xx_32k_read(struct clocksource *cs)* Kernel assumes that sched_clock can be called early but may not have * things ready yet. */ -static cycle_t omap_32k_read_dummy (struct clocksource *cs) +static cycle_t notrace omap_32k_read_dummy(struct clocksource *cs) {return 0 ; }
@@ -109,7 +110,7 @@ static struct clocksource clocksource_32k = {* Returns current time from boot in nsecs. It's OK for this to wrap * around for now, as it's just a relative time stamp. */ -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {return clocksource_cyc2ns (clocksource_32k.read (&clocksource_32k), clocksource_32k.mult, clocksource_32k.shift);
arch/arm/plat-orion/time.c +1 -1
@@ -55,7 +55,7 @@ static u32 ticks_per_jiffy;static unsigned long tclk2ns_scale; -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {unsigned long long v =cnt32_to_63 (0xffffffff -readl (TIMER0_VAL ));return (v * tclk2ns_scale) >>TCLK2NS_SCALE_FACTOR ;
arch/arm/plat-versatile/sched-clock.c +1 -1
@@ -42,7 +42,7 @@* long as there is always less than 89 seconds between successive * calls to this function. */ -unsigned long long sched_clock (void ) +unsigned long long notrace sched_clock (void ) {unsigned long long v =cnt32_to_63 (readl (REFCOUNTER ));
Signature · 1 line
1.6.2.5
PATCH 27/40 Fix rounding in clocks_calc_mult_shift()
In reply to Russell King - ARM LinuxRussell King reports:
| On the ARM dev boards, we have a 32-bit counter running at 24MHz. Calling | clocks_calc_mult_shift(&mult, &shift, 24MHz, NSEC_PER_SEC, 60) gives | us a multiplier of 2796202666 and a shift of 26. | | Over a large counter delta, this produces an error - lets take a count | from 362976315 to 4280663372: | | (4280663372-362976315) * 2796202666 / 2^26 - (4280663372-362976315) * (1000/24) | => -38.91872422891230269990 | | Can we do better? | | (4280663372-362976315) * 2796202667 / 2^26 - (4280663372-362976315) * (1000/24) | 19.45936211449532822051 | | which is about twice as good as the 2796202666 multiplier. | | Looking at the equivalent divisions obtained, 2796202666 / 2^26 gives | 41.66666665673255920410ns per tick, whereas 2796202667 / 2^26 gives | 41.66666667163372039794ns. The actual value wanted is 1000/24 = | 41.66666666666666666666ns.
Fix this by ensuring we round to nearest when calculating the multiplier.
--- kernel/time/clocksource.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/time/clocksource.c +1 -0
@@ -152,6 +152,7 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec)*/ for (sft =32 ; sft >0 ; sft--) { tmp = (u64 ) to << sft; + tmp += from /2 ;do_div (tmp, from);if ((tmp >> sftacc) ==0 )break ;
Signature · 1 line
1.6.2.5
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
In reply to Russell King - ARM LinuxProvide common sched_clock() infrastructure for platforms to use to create a 64-bit ns based sched_clock() implementation from a counter running at a non-variable clock rate.
This implementation is based upon maintaining an epoch for the counter and an epoch for the nanosecond time. When we desire a sched_clock() time, we calculate the number of counter ticks since the last epoch update, convert this to nanoseconds and add to the epoch nanoseconds.
We regularly refresh these epochs within the counter wrap interval. We perform a similar calculation as above, and store the new epochs.
We read and write the epochs in such a way that sched_clock() can easily (and locklessly) detect when an update is in progress, and repeat the loading of these constants when they're known not to be stable. The one caveat is that sched_clock() is not called in the middle of an update.
Finally, if the clock rate is known at compile time, the counter to ns conversion factors can be specified, allowing sched_clock() to be tightly optimized. We ensure that these factors are correct by providing an initialization function which performs a run-time check.
--- arch/arm/Kconfig | 3 + arch/arm/include/asm/sched_clock.h | 115 ++++++++++++++++++++++++++++++++++++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/sched_clock.c | 69 +++++++++++++++++++++ 4 files changed, 188 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/sched_clock.h create mode 100644 arch/arm/kernel/sched_clock.c
arch/arm/Kconfig +3 -0
@@ -38,6 +38,9 @@ config HAVE_PWM config SYS_SUPPORTS_APM_EMULATION bool +config HAVE_SCHED_CLOCK + bool + config GENERIC_GPIO bool
arch/arm/include/asm/sched_clock.h new file +115 -0
115 lines not on this page · raw message
arch/arm/kernel/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_MODULES) += armksyms.o module.o obj-$(CONFIG_ARTHUR) += arthur.o obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o +obj-$(CONFIG_HAVE_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o
arch/arm/kernel/sched_clock.c new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
Quoted 9 lines · Russell King - ARM Linux
Provide common
sched_clock()infrastructure for platforms to use to create a 64-bit ns basedsched_clock()implementation from a counter running at a non-variable clock rate.This implementation is based upon maintaining an epoch for the counter and an epoch for the nanosecond time. When we desire a
sched_clock()time, we calculate the number of counter ticks since the last epoch update, convert this to nanoseconds and add to the epoch nanoseconds.
Quoted 8 lines
We regularly refresh these epochs within the counter wrap interval. We perform a similar calculation as above, and store the new epochs.
We read and write the epochs in such a way that
sched_clock()can easily (and locklessly) detect when an update is in progress, and repeat the loading of these constants when they're known not to be stable. The one caveat is thatsched_clock()is not called in the middle of an update.
How is this ensured? I think this is currently a problem.
Right now there is nothing that prevents update_sched_clock() from being interrupted in the middle of cd->epoch_cyc and cd->epoch_cyc_copy. Let's say an interrupt happens when those two are different.
Within an interrupt handler, you may find calls to printk(), which may also end up calling sched_clock() for time stamping. The sched_clock() function will call cyc_to_fixed_sched_clock() which will deadlock.
Maybe you should at least mask interrupts in update_sched_clock() so that the epoch update is not interruptible.
Nicolas
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
Quoted 26 lines · Nicolas Pitre
Quoted 9 lines · Russell King - ARM Linux
Provide common
sched_clock()infrastructure for platforms to use to create a 64-bit ns basedsched_clock()implementation from a counter running at a non-variable clock rate.This implementation is based upon maintaining an epoch for the counter and an epoch for the nanosecond time. When we desire a
sched_clock()time, we calculate the number of counter ticks since the last epoch update, convert this to nanoseconds and add to the epoch nanoseconds.Quoted 8 lines
We regularly refresh these epochs within the counter wrap interval. We perform a similar calculation as above, and store the new epochs.
We read and write the epochs in such a way that
sched_clock()can easily (and locklessly) detect when an update is in progress, and repeat the loading of these constants when they're known not to be stable. The one caveat is thatsched_clock()is not called in the middle of an update.How is this ensured? I think this is currently a problem.
Right now there is nothing that prevents
update_sched_clock()from being interrupted in the middle ofcd->epoch_cycandcd->epoch_cyc_copy. Let's say an interrupt happens when those two are different.
Quoted 6 lines
Within an interrupt handler, you may find calls to
printk(), which may also end up callingsched_clock()for time stamping. Thesched_clock()function will callcyc_to_fixed_sched_clock()which will deadlock.Maybe you should at least mask interrupts in
update_sched_clock()so that the epoch update is not interruptible.
I left this for you to find, as I knew you wouldn't be satisfied without finding some hole in my scheme. ;)
Yes, you're right, it should disable local IRQs across the update. Thanks for spotting.
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
Quoted 2 lines · Russell King - ARM Linux
Yes, you're right, it should disable local IRQs across the update. Thanks for spotting.
Here's the incremental patch for it. Note that we can safely explicitly disable and re-enable IRQs as the timer subsystem ensures that we will always be called with IRQs enabled:
spin_unlock_irq(&base->lock);
call_timer_fn(timer, fn, data);
spin_lock_irq(&base->lock);arch/arm/include/asm/sched_clock.h +3 -1
@@ -30,7 +30,7 @@ static inline u64 cyc_to_ns(u64 cyc, u32 mult, u32 shift)* Atomically update the sched_clock epoch. Your update callback will * be called from a timer before the counter wraps - read the current * counter value, and call this function to safely move the epochs -* forward. +* forward. Only use this from the update callback. */ static inline void update_sched_clock (struct clock_data *cd,u32 cyc,u32 mask) {
@@ -41,11 +41,13 @@ static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask)* Write epoch_cyc and epoch_ns in a way that the update is * detectable in cyc_to_fixed_sched_clock(). */ +local_irq_disable (); cd->epoch_cyc = cyc;smp_wmb (); cd->epoch_ns = ns;smp_wmb (); cd->epoch_cyc_copy = cyc; +local_irq_enable (); }/*
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
Quoted 11 lines · Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux
Yes, you're right, it should disable local IRQs across the update. Thanks for spotting.
Here's the incremental patch for it. Note that we can safely explicitly disable and re-enable IRQs as the timer subsystem ensures that we will always be called with IRQs enabled:
spin_unlock_irq(&base->lock); call_timer_fn(timer, fn, data); spin_lock_irq(&base->lock);
Right. Might be worth putting the above in the commit log too.
With that change you may add:
Quoted 28 lines
arch/arm/include/asm/sched_clock.h +3
-1@@ -30,7 +30,7 @@ static inline u64 cyc_to_ns(u64 cyc, u32 mult, u32 shift)* Atomically update the sched_clock epoch. Your update callback will * be called from a timer before the counter wraps - read the current * counter value, and call this function to safely move the epochs -* forward. +* forward. Only use this from the update callback. */ static inline void update_sched_clock (struct clock_data *cd,u32 cyc,u32 mask) {@@ -41,11 +41,13 @@ static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask)* Write epoch_cyc and epoch_ns in a way that the update is * detectable in cyc_to_fixed_sched_clock(). */ +local_irq_disable (); cd->epoch_cyc = cyc;smp_wmb (); cd->epoch_ns = ns;smp_wmb (); cd->epoch_cyc_copy = cyc; +local_irq_enable (); }/*
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
In reply to Russell King - ARM LinuxQuoted 26 lines · Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux
Yes, you're right, it should disable local IRQs across the update. Thanks for spotting.
Here's the incremental patch for it. Note that we can safely explicitly disable and re-enable IRQs as the timer subsystem ensures that we will always be called with IRQs enabled:
spin_unlock_irq(&base->lock); call_timer_fn(timer, fn, data); spin_lock_irq(&base->lock);arch/arm/include/asm/sched_clock.h +1
-1@@ -30,7 +30,7 @@ static inline u64 cyc_to_ns(u64 cyc, u32 mult, u32 shift)* Atomically update the sched_clock epoch. Your update callback will * be called from a timer before the counter wraps - read the current * counter value, and call this function to safely move the epochs -* forward. +* forward. Only use this from the update callback. */ static inline void update_sched_clock (struct clock_data *cd,u32 cyc,u32 mask) {
arch/arm/include/asm/sched_clock.h static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask) · line 44
Quoted 4 lines
arch/arm/include/asm/sched_clock.h +1
-0@@ -41,11 +41,13 @@ static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask)* Write epoch_cyc and epoch_ns in a way that the update is * detectable in cyc_to_fixed_sched_clock(). */ +local_irq_disable ();
Actually, wouldn't it be better to use raw_local_irq_disable() here so this is safe with a RT kernel as well?
Nicolas
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
Quoted 27 lines · Nicolas Pitre
Quoted 25 lines · Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux
Yes, you're right, it should disable local IRQs across the update. Thanks for spotting.
Here's the incremental patch for it. Note that we can safely explicitly disable and re-enable IRQs as the timer subsystem ensures that we will always be called with IRQs enabled:
spin_unlock_irq(&base->lock); call_timer_fn(timer, fn, data); spin_lock_irq(&base->lock);arch/arm/include/asm/sched_clock.h +1
-1@@ -30,7 +30,7 @@ static inline u64 cyc_to_ns(u64 cyc, u32 mult, u32 shift)* Atomically update the sched_clock epoch. Your update callback will * be called from a timer before the counter wraps - read the current * counter value, and call this function to safely move the epochs -* forward. +* forward. Only use this from the update callback. */ static inline void update_sched_clock (struct clock_data *cd,u32 cyc,u32 mask) {
Quoted 8 lines
arch/arm/include/asm/sched_clock.h static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask) · line 44
Quoted 5 lines
arch/arm/include/asm/sched_clock.h +1
-0@@ -41,11 +41,13 @@ static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask)* Write epoch_cyc and epoch_ns in a way that the update is * detectable in cyc_to_fixed_sched_clock(). */ +local_irq_disable ();Actually, wouldn't it be better to use
raw_local_irq_disable()here so this is safe with a RT kernel as well?
Grr, there's too many different combinations of stuff... yes, it should be.
PATCH 28/40 ARM: sched_clock: provide common infrastructure for sched_clock()
Quoted 9 lines · Russell King - ARM Linux
Quoted 6 lines · Nicolas Pitre
arch/arm/include/asm/sched_clock.h static inline void update_sched_clock(struct clock_data *cd, u32 cyc, u32 mask) · line 44
Quoted 1 line · Russell King - ARM Linux
arch/arm/include/asm/sched_clock.h +1
-0+local_irq_disable ();Actually, wouldn't it be better to use
raw_local_irq_disable()here so this is safe with a RT kernel as well?Grr, there's too many different combinations of stuff... yes, it should be.
That's why we have peer review. :-)
Nicolas
PATCH 29/40 ARM: ixp4xx: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert ixp4xx to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-ixp4xx/common.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-)
arch/arm/Kconfig +1 -0
@@ -437,6 +437,7 @@ config ARCH_IXP4XX select CPU_XSCALE select GENERIC_GPIO select GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK select DMABOUNCE if PCI help Support for Intel's IXP4XX (XScale) family of processors.
arch/arm/mach-ixp4xx/common.c +20 -11
@@ -35,6 +35,7 @@#include <asm/pgtable.h> #include <asm/page.h> #include <asm/irq.h> +#include <asm/sched_clock.h> #include <asm/mach/map.h> #include <asm/mach/irq.h>
@@ -399,6 +400,23 @@ void __init ixp4xx_sys_init(void) }/* +* sched_clock() +*/ +static DEFINE_CLOCK_DATA (cd); + +unsigned long long notrace sched_clock (void ) +{ +u32 cyc = *IXP4XX_OSTS ; +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); +} + +static void notrace ixp4xx_update_sched_clock(void) +{ +u32 cyc = *IXP4XX_OSTS ; +update_sched_clock (&cd, cyc, (u32 )~0 ); +} + +/* * clocksource */ static cycle_t ixp4xx_get_cycles (struct clocksource *cs)
@@ -418,18 +436,9 @@ unsigned long ixp4xx_timer_freq = FREQ;EXPORT_SYMBOL (ixp4xx_timer_freq);static void __init ixp4xx_clocksource_init (void ) { -clocksource_register_hz (&clocksource_ixp4xx, ixp4xx_timer_freq); -} - -/* -* sched_clock() -*/ -unsigned long long notrace sched_clock (void ) -{ -cycle_t cyc =ixp4xx_get_cycles (NULL ); -struct clocksource *cs = &clocksource_ixp4xx; +init_sched_clock (&cd, ixp4xx_update_sched_clock,32 , ixp4xx_timer_freq); -return clocksource_cyc2ns (cyc, cs->mult, cs->shift); +clocksource_register_hz (&clocksource_ixp4xx, ixp4xx_timer_freq); }/*
Signature · 1 line
1.6.2.5
PATCH 30/40 ARM: mmp: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert mmp to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-mmp/time.c | 32 +++++++++++--------------------- 2 files changed, 12 insertions(+), 21 deletions(-)
arch/arm/Kconfig +1 -0
@@ -513,6 +513,7 @@ config ARCH_MMP select ARCH_REQUIRE_GPIOLIB select COMMON_CLKDEV select GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK select TICK_ONESHOT select PLAT_PXA select SPARSE_IRQ
arch/arm/mach-mmp/time.c +11 -21
@@ -26,8 +26,8 @@#include <linux/io.h> #include <linux/irq.h> #include <linux/sched.h> -#include <linux/cnt32_to_63.h> +#include <asm/sched_clock.h> #include <mach/addr-map.h> #include <mach/regs-timers.h> #include <mach/regs-apbc.h>
@@ -42,23 +42,7 @@#define MAX_DELTA (0xfffffffe)#define MIN_DELTA (16) -#define TCR2NS_SCALE_FACTOR 10 - -static unsigned long tcr2ns_scale; - -static void __init set_tcr2ns_scale (unsigned long tcr_rate) -{ -unsigned long long v =1000000000ULL <<TCR2NS_SCALE_FACTOR ; -do_div (v, tcr_rate); - tcr2ns_scale = v; -/* -* We want an even value to automatically clear the top bit -* returned by cnt32_to_63() without an additional run time -* instruction. So if the LSB is 1 then round it up. -*/ -if (tcr2ns_scale &1 ) - tcr2ns_scale++; -} +static DEFINE_CLOCK_DATA (cd);/* * FIXME: the timer needs some delay to stablize the counter capture
@@ -77,8 +61,14 @@ static inline uint32_t timer_read(void)unsigned long long notrace sched_clock (void ) { -unsigned long long v =cnt32_to_63 (timer_read ()); -return (v * tcr2ns_scale) >>TCR2NS_SCALE_FACTOR ; +u32 cyc =timer_read (); +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); +} + +static void notrace mmp_update_sched_clock(void) +{ +u32 cyc =timer_read (); +update_sched_clock (&cd, cyc, (u32 )~0 ); }static irqreturn_t timer_interrupt (int irq,void *dev_id)
@@ -185,7 +175,7 @@ void __init timer_init(int irq) {timer_config (); -set_tcr2ns_scale (CLOCK_TICK_RATE ); +init_sched_clock (&cd, mmp_update_sched_clock,32 ,CLOCK_TICK_RATE ); ckevt.mult =div_sc (CLOCK_TICK_RATE ,NSEC_PER_SEC , ckevt.shift); ckevt.max_delta_ns =clockevent_delta2ns (MAX_DELTA , &ckevt);
Signature · 1 line
1.6.2.5
PATCH 31/40 ARM: pxa: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert pxa to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-pxa/time.c | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-)
arch/arm/Kconfig +1 -0
@@ -593,6 +593,7 @@ config ARCH_PXA select COMMON_CLKDEV select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK select TICK_ONESHOT select PLAT_PXA select SPARSE_IRQ
arch/arm/mach-pxa/time.c +9 -20
@@ -17,11 +17,11 @@#include <linux/interrupt.h> #include <linux/clockchips.h> #include <linux/sched.h> -#include <linux/cnt32_to_63.h> #include <asm/div64.h> #include <asm/mach/irq.h> #include <asm/mach/time.h> +#include <asm/sched_clock.h> #include <mach/regs-ost.h> /*
@@ -32,29 +32,18 @@* long as there is always less than 582 seconds between successive * calls to sched_clock() which should always be the case in practice. */ +static DEFINE_CLOCK_DATA (cd); -#define OSCR2NS_SCALE_FACTOR 10 - -static unsigned long oscr2ns_scale; - -static void __init set_oscr2ns_scale (unsigned long oscr_rate) +unsigned long long notrace sched_clock (void ) { -unsigned long long v =1000000000ULL <<OSCR2NS_SCALE_FACTOR ; -do_div (v, oscr_rate); - oscr2ns_scale = v; -/* -* We want an even value to automatically clear the top bit -* returned by cnt32_to_63() without an additional run time -* instruction. So if the LSB is 1 then round it up. -*/ -if (oscr2ns_scale &1 ) - oscr2ns_scale++; +u32 cyc =OSCR ; +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); } -unsigned long long notrace sched_clock (void ) +static void notrace pxa_update_sched_clock(void) { -unsigned long long v =cnt32_to_63 (OSCR ); -return (v * oscr2ns_scale) >>OSCR2NS_SCALE_FACTOR ; +u32 cyc =OSCR ; +update_sched_clock (&cd, cyc, (u32 )~0 ); }
@@ -144,7 +133,7 @@ static void __init pxa_timer_init(void)OIER =0 ;OSSR =OSSR_M0 |OSSR_M1 |OSSR_M2 |OSSR_M3 ; -set_oscr2ns_scale (clock_tick_rate); +init_sched_clock (&cd, pxa_update_sched_clock,32 , clock_tick_rate); ckevt_pxa_osmr0.mult =div_sc (clock_tick_rate,NSEC_PER_SEC , ckevt_pxa_osmr0.shift);
Signature · 1 line
1.6.2.5
PATCH 32/40 ARM: sa1100: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert sa1100 to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-sa1100/generic.c | 23 ----------------------- arch/arm/mach-sa1100/time.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 23 deletions(-)
arch/arm/Kconfig +1 -0
@@ -642,6 +642,7 @@ config ARCH_SA1100 select CPU_FREQ select GENERIC_CLOCKEVENTS select HAVE_CLK + select HAVE_SCHED_CLOCK select TICK_ONESHOT select ARCH_REQUIRE_GPIOLIB help
arch/arm/mach-sa1100/generic.c +0 -23
@@ -16,9 +16,7 @@#include <linux/pm.h> #include <linux/cpufreq.h> #include <linux/ioport.h> -#include <linux/sched.h> /* just for sched_clock() - funny that */ #include <linux/platform_device.h> -#include <linux/cnt32_to_63.h> #include <asm/div64.h> #include <mach/hardware.h>
@@ -110,27 +108,6 @@ unsigned int sa11x0_getspeed(unsigned int cpu) }/* -* This is the SA11x0 sched_clock implementation. This has -* a resolution of 271ns, and a maximum value of 32025597s (370 days). -* -* The return value is guaranteed to be monotonic in that range as -* long as there is always less than 582 seconds between successive -* calls to this function. -* -* ( * 1E9 / 3686400 => * 78125 / 288) -*/ -unsigned long long notrace sched_clock (void ) -{ -unsigned long long v =cnt32_to_63 (OSCR ); - -/* the <<1 gets rid of the cnt_32_to_63 top bit saving on a bic insn */ - v *=78125 <<1 ; -do_div (v,288 <<1 ); - -return v; -} - -/* * Default power-off for SA1100 */ static void sa1100_power_off (void )
arch/arm/mach-sa1100/time.c +30 -0
@@ -12,12 +12,39 @@#include <linux/errno.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/sched.h> /* just for sched_clock() - funny that */ #include <linux/timex.h> #include <linux/clockchips.h> #include <asm/mach/time.h> +#include <asm/sched_clock.h> #include <mach/hardware.h> +/* +* This is the SA11x0 sched_clock implementation. +*/ +static DEFINE_CLOCK_DATA (cd); + +/* +* Constants generated by clocks_calc_mult_shift(m, s, 3.6864MHz, +* NSEC_PER_SEC, 60). +* This gives a resolution of about 271ns and a wrap period of about 19min. +*/ +#define SC_MULT 2275555556u +#define SC_SHIFT 23 + +unsigned long long notrace sched_clock (void ) +{ +u32 cyc =OSCR ; +return cyc_to_fixed_sched_clock (&cd, cyc, (u32 )~0 ,SC_MULT ,SC_SHIFT ); +} + +static void notrace sa1100_update_sched_clock(void) +{ +u32 cyc =OSCR ; +update_sched_clock (&cd, cyc, (u32 )~0 ); +} +#define MIN_OSCR_DELTA 2static irqreturn_t sa1100_ost0_interrupt (int irq,void *dev_id)
@@ -96,6 +123,9 @@ static void __init sa1100_timer_init(void)OIER =0 ;/* disable any timer interrupts */ OSSR =0xf ;/* clear status on all timers */ +init_fixed_sched_clock (&cd, sa1100_update_sched_clock,32 , +3686400 ,SC_MULT ,SC_SHIFT ); + ckevt_sa1100_osmr0.mult =div_sc (3686400 ,NSEC_PER_SEC , ckevt_sa1100_osmr0.shift); ckevt_sa1100_osmr0.max_delta_ns =
Signature · 1 line
1.6.2.5
PATCH 33/40 ARM: tegra: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert tegra to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-tegra/timer.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
@@ -570,6 +570,7 @@ config ARCH_TEGRA select GENERIC_CLOCKEVENTS select GENERIC_GPIO select HAVE_CLK + select HAVE_SCHED_CLOCK select COMMON_CLKDEV select ARCH_HAS_BARRIERS if CACHE_L2X0 select ARCH_HAS_CPUFREQ
arch/arm/mach-tegra/timer.c +20 -2
@@ -26,7 +26,6 @@#include <linux/clocksource.h> #include <linux/clk.h> #include <linux/io.h> -#include <linux/cnt32_to_63.h> #include <asm/mach/time.h> #include <asm/localtimer.h>
@@ -111,9 +110,25 @@ static struct clocksource tegra_clocksource = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +static DEFINE_CLOCK_DATA (cd); + +/* +* Constants generated by clocks_calc_mult_shift(m, s, 1MHz, NSEC_PER_SEC, 60). +* This gives a resolution of about 1us and a wrap period of about 1h11min. +*/ +#define SC_MULT 4194304000u +#define SC_SHIFT 22 +unsigned long long notrace sched_clock (void ) { -return cnt32_to_63 (timer_readl (TIMERUS_CNTR_1US )) *1000 ; +u32 cyc =timer_readl (TIMERUS_CNTR_1US ); +return cyc_to_fixed_sched_clock (&cd, cyc, (u32 )~0 ,SC_MULT ,SC_SHIFT ); +} + +static void notrace tegra_update_sched_clock(void) +{ +u32 cyc =timer_readl (TIMERUS_CNTR_1US ); +update_sched_clock (&cd, cyc, (u32 )~0 ); }static irqreturn_t tegra_timer_interrupt (int irq,void *dev_id)
@@ -158,6 +173,9 @@ static void __init tegra_init_timer(void)WARN (1 ,"Unknown clock rate" ); } +init_fixed_sched_clock (&cd, tegra_update_sched_clock,32 , +1000000 ,SC_MULT ,SC_SHIFT ); +if (clocksource_register_hz (&tegra_clocksource,1000000 )) {printk (KERN_ERR "Failed to register clocksource\n" );BUG ();
Signature · 1 line
1.6.2.5
PATCH 33/40 ARM: tegra: convert sched_clock() to use new infrastructure
Hi,
Quoted 31 lines · Russell King - ARM Linux
Convert tegra to use the new
sched_clock()infrastructure for extending 32bit counters to full 64-bit nanoseconds.Signed-off-by Russell King <[email protected]>---
?arch/arm/Kconfig ? ? ? ? ? ?| ? ?1 + ?arch/arm/mach-tegra/timer.c | ? 22 ++++++++++++++++++++-- ?2 files changed, 21 insertions(+), 2 deletions(-)arch/arm/Kconfig +0
-0@@ -570,6 +570,7 @@ config ARCH_TEGRA? ? ? ?select
GENERIC_CLOCKEVENTS
? ? ? ?selectGENERIC_GPIO
? ? ? ?selectHAVE_CLK
+ ? ? ? selectHAVE_SCHED_CLOCK
? ? ? ?selectCOMMON_CLKDEV
? ? ? ?selectARCH_HAS_BARRIERSifCACHE_L2X0
? ? ? ?selectARCH_HAS_CPUFREQarch/arm/mach-tegra/timer.c +0
-0@@ -26,7 +26,6 @@?#include <
linux/clocksource.h>
?#include <linux/clk.h>
?#include <linux/io.h>
-#include <linux/cnt32_to_63.h>
Quoted 2 lines
?#include <
asm/mach/time.h>
?#include <asm/localtimer.h>
This needs:
#include <asm/sched_clock.h>
(for DEFINE_CLOCK_DATA and other declarations)
-Olof
PATCH 33/40 ARM: tegra: convert sched_clock() to use new infrastructure
Quoted 5 lines · Olof Johansson
This needs:
#include <
asm/sched_clock.h>(for
DEFINE_CLOCK_DATAand other declarations)
Fixed, thanks for testing.
PATCH 34/40 ARM: u300: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert u300 to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-u300/timer.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
arch/arm/Kconfig +1 -0
@@ -790,6 +790,7 @@ config ARCH_U300 bool "ST-Ericsson U300 Series" depends on MMU select CPU_ARM926T + select HAVE_SCHED_CLOCK select HAVE_TCM select ARM_AMBA select ARM_VIC
arch/arm/mach-u300/timer.c +13 -4
@@ -22,6 +22,7 @@#include <mach/hardware.h> /* Generic stuff */ +#include <asm/sched_clock.h> #include <asm/mach/map.h> #include <asm/mach/time.h> #include <asm/mach/irq.h>
@@ -353,12 +354,18 @@ static struct clocksource clocksource_u300_1mhz = {* this wraps around for now, since it is just a relative time * stamp. (Inspired by OMAP implementation.) */ +static DEFINE_CLOCK_DATA (cd); +unsigned long long notrace sched_clock (void ) { -return clocksource_cyc2ns (clocksource_u300_1mhz.read ( - &clocksource_u300_1mhz), - clocksource_u300_1mhz.mult, - clocksource_u300_1mhz.shift); +u32 cyc =readl (U300_TIMER_APP_VBASE +U300_TIMER_APP_GPT2CC ); +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); +} + +static void notrace u300_update_sched_clock(void) +{ +u32 cyc =readl (U300_TIMER_APP_VBASE +U300_TIMER_APP_GPT2CC ); +update_sched_clock (&cd, cyc, (u32 )~0 ); }
@@ -376,6 +383,8 @@ static void __init u300_timer_init(void)clk_enable (clk); rate =clk_get_rate (clk); +init_sched_clock (&cd, u300_update_sched_clock,32 , rate); +/* * Disable the "OS" and "DD" timers - these are designed for Symbian! * Example usage in cnh1601578 cpu subsystem pd_timer_app.c
Signature · 1 line
1.6.2.5
PATCH 34/40 ARM: u300: convert sched_clock() to use new infrastructure
2010/12/17 Russell King - ARM Linux <[email protected]>:
Quoted 2 lines
Convert u300 to use the new
sched_clock()infrastructure for extending 32bit counters to full 64-bit nanoseconds.
Yours,
Linus Walleij
PATCH 35/40 ARM: iop: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert iop platforms to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/plat-iop/time.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
arch/arm/Kconfig +1 -0
@@ -992,6 +992,7 @@ config ARCH_ACORN config PLAT_IOP bool select GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK config PLAT_ORION bool
arch/arm/plat-iop/time.c +11 -3
@@ -50,15 +50,21 @@ static struct clocksource iop_clocksource = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +static DEFINE_CLOCK_DATA (cd); +/* * IOP sched_clock() implementation via its clocksource. */ unsigned long long notrace sched_clock (void ) { -cycle_t cyc =iop_clocksource_read (NULL ); -struct clocksource *cs = &iop_clocksource; +u32 cyc =0xffffffffu -read_tcr1 (); +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); +} -return clocksource_cyc2ns (cyc, cs->mult, cs->shift); +static void notrace iop_update_sched_clock(void) +{ +u32 cyc =0xffffffffu -read_tcr1 (); +update_sched_clock (&cd, cyc, (u32 )~0 ); }/*
@@ -143,6 +149,8 @@ void __init iop_init_time(unsigned long tick_rate) {u32 timer_ctl; +init_sched_clock (&cd, iop_update_sched_clock,32 , tick_rate); + ticks_per_jiffy =DIV_ROUND_CLOSEST (tick_rate,HZ ); iop_tick_rate = tick_rate;
Signature · 1 line
1.6.2.5
PATCH 35/40 ARM: iop: convert sched_clock() to use new infrastructure
Convert iop platforms to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
---
Now with missing include added!
arch/arm/Kconfig | 1 + arch/arm/plat-iop/time.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
arch/arm/Kconfig +1 -0
@@ -992,6 +992,7 @@ config ARCH_ACORN config PLAT_IOP bool select GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK config PLAT_ORION bool
arch/arm/plat-iop/time.c +12 -3
@@ -24,6 +24,7 @@#include <linux/clockchips.h> #include <mach/hardware.h> #include <asm/irq.h> +#include <asm/sched_clock.h> #include <asm/uaccess.h> #include <asm/mach/irq.h> #include <asm/mach/time.h>
@@ -50,15 +51,21 @@ static struct clocksource iop_clocksource = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +static DEFINE_CLOCK_DATA (cd); +/* * IOP sched_clock() implementation via its clocksource. */ unsigned long long notrace sched_clock (void ) { -cycle_t cyc =iop_clocksource_read (NULL ); -struct clocksource *cs = &iop_clocksource; +u32 cyc =0xffffffffu -read_tcr1 (); +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); +} -return clocksource_cyc2ns (cyc, cs->mult, cs->shift); +static void notrace iop_update_sched_clock(void) +{ +u32 cyc =0xffffffffu -read_tcr1 (); +update_sched_clock (&cd, cyc, (u32 )~0 ); }/*
@@ -143,6 +150,8 @@ void __init iop_init_time(unsigned long tick_rate) {u32 timer_ctl; +init_sched_clock (&cd, iop_update_sched_clock,32 , tick_rate); + ticks_per_jiffy =DIV_ROUND_CLOSEST (tick_rate,HZ ); iop_tick_rate = tick_rate;
Signature · 1 line
1.6.2.5
PATCH 36/40 ARM: nomadik: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert nomadik platforms to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/plat-nomadik/Kconfig | 1 + arch/arm/plat-nomadik/timer.c | 76 +++++------------------------------------ 2 files changed, 10 insertions(+), 67 deletions(-)
arch/arm/plat-nomadik/Kconfig +1 -0
@@ -14,6 +14,7 @@ if PLAT_NOMADIK config HAS_MTU bool + select HAVE_SCHED_CLOCK help Support for Multi Timer Unit. MTU provides access to multiple interrupt generating programmable
arch/arm/plat-nomadik/timer.c +9 -67
107 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 36/40 ARM: nomadik: convert sched_clock() to use new infrastructure
2010/12/17 Russell King - ARM Linux <[email protected]>:
Quoted 2 lines
Convert nomadik platforms to use the new
sched_clock()infrastructure for extending 32bit counters to full 64-bit nanoseconds.
Much better this way, thanks Russell.
Yours,
Linus Walleij
PATCH 37/40 ARM: omap: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert omap to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/plat-omap/counter_32k.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
@@ -839,6 +839,7 @@ config ARCH_OMAP select ARCH_REQUIRE_GPIOLIB select ARCH_HAS_CPUFREQ select GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK select ARCH_HAS_HOLES_MEMORYMODEL help Support for TI's OMAP platform (OMAP1/2/3/4).
arch/arm/plat-omap/counter_32k.c +22 -2
@@ -18,6 +18,8 @@#include <linux/io.h> #include <linux/sched.h> +#include <asm/sched_clock.h> +#include <plat/common.h> #include <plat/board.h>
@@ -110,10 +112,25 @@ static struct clocksource clocksource_32k = {* Returns current time from boot in nsecs. It's OK for this to wrap * around for now, as it's just a relative time stamp. */ +static DEFINE_CLOCK_DATA (cd); + +/* +* Constants generated by clocks_calc_mult_shift(m, s, 32768, NSEC_PER_SEC, 60). +* This gives a resolution of about 30us and a wrap period of about 36hrs. +*/ +#define SC_MULT 4000000000u +#define SC_SHIFT 17 +unsigned long long notrace sched_clock (void ) { -return clocksource_cyc2ns (clocksource_32k.read (&clocksource_32k), - clocksource_32k.mult, clocksource_32k.shift); +u32 cyc = clocksource_32k.read (&clocksource_32k); +return cyc_to_fixed_sched_clock (&cd, cyc, (u32 )~0 ,SC_MULT ,SC_SHIFT ); +} + +static void notrace omap_update_sched_clock(void) +{ +u32 cyc = clocksource_32k.read (&clocksource_32k); +update_sched_clock (&cd, cyc, (u32 )~0 ); }/**
@@ -171,6 +188,9 @@ static int __init omap_init_clocksource_32k(void)if (clocksource_register_hz (&clocksource_32k,32768 ))printk (err, clocksource_32k.name); + +init_fixed_sched_clock (&cd, omap_update_sched_clock,32 , +32768 ,SC_MULT ,SC_SHIFT ); }return 0 ; }
Signature · 1 line
1.6.2.5
PATCH 38/40 ARM: orion: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert orion platforms to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/plat-orion/time.c | 44 +++++++++----------------------------------- 2 files changed, 10 insertions(+), 35 deletions(-)
arch/arm/Kconfig +1 -0
@@ -997,6 +997,7 @@ config PLAT_IOP config PLAT_ORION bool + select HAVE_SCHED_CLOCK config PLAT_PXA bool
arch/arm/plat-orion/time.c +9 -35
72 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 38/40 ARM: orion: convert sched_clock() to use new infrastructure
Quoted 4 lines · Russell King - ARM Linux
Convert orion platforms to use the new
sched_clock()infrastructure for extending 32bit counters to full 64-bit nanoseconds.Signed-off-by Russell King <[email protected]>
Quoted 98 lines
--- arch/arm/Kconfig | 1 + arch/arm/plat-orion/time.c | 44 +++++++++----------------------------------- 2 files changed, 10 insertions(+), 35 deletions(-)arch/arm/Kconfig +1
-0@@ -997,6 +997,7 @@ config PLAT_IOP config PLAT_ORION bool + select HAVE_SCHED_CLOCK config PLAT_PXA boolarch/arm/plat-orion/time.c +9
-35@@ -13,11 +13,11 @@#include <linux/kernel.h> #include <linux/sched.h> -#include <linux/cnt32_to_63.h> #include <linux/timer.h> #include <linux/clockchips.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <asm/sched_clock.h> #include <asm/mach/time.h> #include <mach/bridge-regs.h> #include <mach/hardware.h> @@ -44,52 +44,26 @@ static u32 ticks_per_jiffy;/* * Orion's sched_clock implementation. It has a resolution of -* at least 7.5ns (133MHz TCLK) and a maximum value of 834 days. -* -* Because the hardware timer period is quite short (21 secs if -* 200MHz TCLK) and because cnt32_to_63() needs to be called at -* least once per half period to work properly, a kernel timer is -* set up to ensure this requirement is always met. +* at least 7.5ns (133MHz TCLK). */ -#define TCLK2NS_SCALE_FACTOR 8 - -static unsigned long tclk2ns_scale; +static DEFINE_CLOCK_DATA (cd);unsigned long long notrace sched_clock (void ) { -unsigned long long v =cnt32_to_63 (0xffffffff -readl (TIMER0_VAL )); -return (v * tclk2ns_scale) >>TCLK2NS_SCALE_FACTOR ; +u32 cyc =0xffffffff -readl (TIMER0_VAL ); +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); } -static struct timer_list cnt32_to_63_keepwarm_timer; -static void cnt32_to_63_keepwarm (unsigned long data) +static void notrace orion_update_sched_clock(void) { -mod_timer (&cnt32_to_63_keepwarm_timer,round_jiffies (jiffies + data)); - (void )sched_clock (); +u32 cyc =0xffffffff -readl (TIMER0_VAL ); +update_sched_clock (&cd, cyc, (u32 )~0 ); }static void __init setup_sched_clock (unsigned long tclk) { -unsigned long long v; -unsigned long data; - - v =NSEC_PER_SEC ; - v <<=TCLK2NS_SCALE_FACTOR ; - v += tclk/2 ; -do_div (v, tclk); -/* -* We want an even value to automatically clear the top bit -* returned by cnt32_to_63() without an additional run time -* instruction. So if the LSB is 1 then round it up. -*/ -if (v &1 ) - v++; - tclk2ns_scale = v; - - data = (0xffffffffUL / tclk /2 -2 ) *HZ ; -setup_timer (&cnt32_to_63_keepwarm_timer, cnt32_to_63_keepwarm, data); -mod_timer (&cnt32_to_63_keepwarm_timer,round_jiffies (jiffies + data)); +init_sched_clock (&cd, orion_update_sched_clock,32 , tclk); }/* Signature · 1 line
1.6.2.5
PATCH 39/40 ARM: versatile: convert sched_clock() to use new infrastructure
In reply to Russell King - ARM LinuxConvert versatile platforms to use the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 2 + arch/arm/mach-realview/core.c | 10 ++++ arch/arm/mach-versatile/core.c | 10 ++++ arch/arm/plat-versatile/include/plat/sched_clock.h | 6 +++ arch/arm/plat-versatile/sched-clock.c | 48 +++++++++++--------- 5 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 arch/arm/plat-versatile/include/plat/sched_clock.h
arch/arm/Kconfig +2 -0
@@ -236,6 +236,7 @@ config ARCH_REALVIEW bool "ARM Ltd. RealView family" select ARM_AMBA select COMMON_CLKDEV + select HAVE_SCHED_CLOCK select ICST select GENERIC_CLOCKEVENTS select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -250,6 +251,7 @@ config ARCH_VERSATILE select ARM_AMBA select ARM_VIC select COMMON_CLKDEV + select HAVE_SCHED_CLOCK select ICST select GENERIC_CLOCKEVENTS select ARCH_WANT_OPTIONAL_GPIOLIB
arch/arm/mach-realview/core.c +10 -0
@@ -52,6 +52,8 @@#include <mach/irqs.h> #include <plat/timer-sp.h> +#include <plat/sched_clock.h> +#include "core.h" /* used by entry-macro.S and platsmp.c */
@@ -658,6 +660,12 @@ void realview_leds_event(led_event_t ledevt)#endif /* CONFIG_LEDS */ /* +* The sched_clock counter +*/ +#define REFCOUNTER (__io_address(REALVIEW_SYS_BASE) + \ + REALVIEW_SYS_24MHz_OFFSET) + +/* * Where is the timer (VA)? */ void __iomem *timer0_va_base;
@@ -672,6 +680,8 @@ void __init realview_timer_init(unsigned int timer_irq) {u32 val; +versatile_sched_clock_init (REFCOUNTER ,24000000 ); +/* * set clock frequency: * REALVIEW_REFCLK is 32KHz
arch/arm/mach-versatile/core.c +10 -0
@@ -51,6 +51,8 @@#include <mach/platform.h> #include <plat/timer-sp.h> +#include <plat/sched_clock.h> +#include "core.h" /*
@@ -886,6 +888,12 @@ void __init versatile_init(void) }/* +* The sched_clock counter +*/ +#define REFCOUNTER (__io_address(VERSATILE_SYS_BASE) + \ + VERSATILE_SYS_24MHz_OFFSET) + +/* * Where is the timer (VA)? */ #define TIMER0_VA_BASE __io_address(VERSATILE_TIMER0_1_BASE)
@@ -900,6 +908,8 @@ static void __init versatile_timer_init(void) {u32 val; +versatile_sched_clock_init (REFCOUNTER ,24000000 ); +/* * set clock frequency: * VERSATILE_REFCLK is 32KHz
arch/arm/plat-versatile/include/plat/sched_clock.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef ARM_PLAT_SCHED_CLOCK_H +#define ARM_PLAT_SCHED_CLOCK_H + +void versatile_sched_clock_init (void __iomem *,unsigned long ); + +#endif
arch/arm/plat-versatile/sched-clock.c +26 -22
63 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 40/40 ARM: vexpress: add sched_clock() for Versatile Express
In reply to Russell King - ARM LinuxAdd a sched_clock() implementation to Versatile Express using the new sched_clock() infrastructure for extending 32bit counters to full 64-bit nanoseconds.
--- arch/arm/Kconfig | 1 + arch/arm/mach-vexpress/v2m.c | 4 ++++ arch/arm/plat-versatile/Makefile | 4 +--- 3 files changed, 6 insertions(+), 3 deletions(-)
arch/arm/Kconfig +1 -0
@@ -268,6 +268,7 @@ config ARCH_VEXPRESS select COMMON_CLKDEV select GENERIC_CLOCKEVENTS select HAVE_CLK + select HAVE_SCHED_CLOCK select ICST select PLAT_VERSATILE help
arch/arm/mach-vexpress/v2m.c +4 -0
@@ -22,6 +22,8 @@#include <mach/clkdev.h> #include <mach/motherboard.h> +#include <plat/sched_clock.h> +#include <plat/timer-sp.h> #include "core.h"
@@ -50,6 +52,8 @@ void __init v2m_map_io(struct map_desc *tile, size_t num)static void __init v2m_timer_init (void ) { +versatile_sched_clock_init (MMIO_P2V (V2M_SYS_24MHZ ),24000000 ); +writel (0 ,MMIO_P2V (V2M_TIMER0 ) +TIMER_CTRL );writel (0 ,MMIO_P2V (V2M_TIMER1 ) +TIMER_CTRL );
arch/arm/plat-versatile/Makefile +1 -3
@@ -1,7 +1,5 @@ -obj-y := clock.o +obj-y := clock.o sched-clock.o obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o -obj-$(CONFIG_ARCH_REALVIEW) += sched-clock.o -obj-$(CONFIG_ARCH_VERSATILE) += sched-clock.o ifeq ($(CONFIG_LEDS_CLASS),y) obj-$(CONFIG_ARCH_REALVIEW) += leds.o obj-$(CONFIG_ARCH_VERSATILE) += leds.o
Signature · 1 line
1.6.2.5
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 8 lines
-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap- owner at vger.kernel.org] On Behalf Of Russell King - ARM Linux
Sent: Friday, December 17, 2010 5:02 PM
To: Alessandro Rubini; Bryan Huntsman; Colin Cross; Daniel Walker; David Brown; Eric Miao; Erik Gilling; Hans J. Koch; Imre Kaloz; Kevin Hilman; Krzysztof Halasa; Kukjin Kim; Lennert Buytenhek; Jiandong Zheng; Linus Walleij; linux-arm-msm at vger.kernel.org; linux-omap at vger.kernel.org;
linux-
Quoted 6 lines
samsung-soc at vger.kernel.org; linux-tegra at vger.kernel.org; Nicolas Pitre; Olof Johansson; Sascha Hauer; Scott Branden; STEricsson; Tony Lindgren; Viresh Kumar; Wan ZongShun
Cc: linux-arm-kernel at lists.infradead.org
Subject: [PATCH 0/40] Complete set of clocksource/sched_clock patches
Quoted 6 lines
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Have boot tested this series on OMAP4430 SDP and OMAP3630 ZOOM.
Regards,
Santosh
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxHi Russell,
Quoted 6 lines
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
I took these for a spin on my Versatile Express board and it seems happy enough doing parallel builds with all the CPUs fully loaded.
I don't think these conflict with the multi-tile patch I sent to the patch system, but if you see a conflict please let me know.
Will
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 6 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Which tree is this based on? Is this scheduled for 2.6.37 or .38?
Since the problem affects 2.6.37-rc I tried it on top of 2.6.37-rc6.
First there were patch rejects in two sub-archs, but they were easily fixed.
On n2100 (plat-iop) a missing #include <asm/sched_clock.h> in plat-iop/time.c caused a compile error. With that added the kernel built w/o warnings but hung immediately after being decompressed.
On mach-ixp4xx the kernel built and booted fine, and the interactivity problems were gone.
cover Complete set of clocksource/sched_clock patches
Quoted 9 lines · Mikael Pettersson
Quoted 6 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Which tree is this based on? Is this scheduled for 2.6.37 or .38?
It's based on the point where the ftrace updates were merged into my tree. I can't produce all the patches that lead up to this set because there's just too many.
However, it probably applies cleanly on top of the devel-stable stuff.
It's scheduled for the next merge window.
Quoted 3 lines
On n2100 (plat-iop) a missing #include <
asm/sched_clock.h> inplat-iop/time.ccaused a compile error. With that added the kernel built w/o warnings but hung immediately after being decompressed.
Will add the missing include.
Normally, this is because sched_clock() is called prior to the mapping for reading the counter being available, but this is no different from what was already there. So, I suspect that n2100 doesn't boot without these patches applied either.
Any chance of an boot log using the early printk or debug_ll stuff?
Quoted 4 lines
On mach-ixp4xx the kernel built and booted fine, and the interactivity problems were gone.
Thanks - will add that to the IXP4xx specific parts.
cover Complete set of clocksource/sched_clock patches
Quoted 6 lines · Russell King - ARM Linux
Quoted 4 lines
On mach-ixp4xx the kernel built and booted fine, and the interactivity problems were gone.
Thanks - will add that to the IXP4xx specific parts.
BTW, can I add that to the common parts as well?
cover Complete set of clocksource/sched_clock patches
Quoted 9 lines · Russell King - ARM Linux
Quoted 6 lines · Russell King - ARM Linux
Quoted 4 lines
On mach-ixp4xx the kernel built and booted fine, and the interactivity problems were gone.
Thanks - will add that to the IXP4xx specific parts.
BTW, can I add that to the common parts as well?
Sure.
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 23 lines · Russell King - ARM Linux
Quoted 9 lines · Mikael Pettersson
Quoted 6 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Which tree is this based on? Is this scheduled for 2.6.37 or .38?
It's based on the point where the ftrace updates were merged into my tree. I can't produce all the patches that lead up to this set because there's just too many.
However, it probably applies cleanly on top of the devel-stable stuff.
It's scheduled for the next merge window.
Quoted 3 lines
On n2100 (plat-iop) a missing #include <
asm/sched_clock.h> inplat-iop/time.ccaused a compile error. With that added the kernel built w/o warnings but hung immediately after being decompressed.
Quoted 6 lines
Will add the missing include.
Normally, this is because
sched_clock()is called prior to the mapping for reading the counter being available, but this is no different from what was already there. So, I suspect that n2100 doesn't boot without these patches applied either.
The n2100 boots just fine without the sched_clock patches.
Quoted 1 line
Any chance of an boot log using the early printk or
debug_llstuff?
Here it is:
Build ATAGATAG_MEM: Overwrite ram_end with real_region_top=0x20000000, memsize=512 M
ATAG_MEM=536870912 at 0xa0000000, MACH_TYPE=1101
Using base address 0x00200000 and length 0x0018e3c0
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.37-rc6 (mikpe at brewer) (gcc version 4.4.6 20101116 (prerelease) (GCC) ) #1 Sun Dec 19 12:58:45 CET 2010
CPU: XScale-80219 [69052e30] revision 0 (ARMv5TE), cr=0000397f
CPU: VIVT data cache, VIVT instruction cache
Machine: Thecus N2100
bootconsole [earlycon0] enabled
Memory policy: ECC disabled, Data cache writeback
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048
Kernel command line: console=ttyS0,115200 ro root=/dev/sda1 mem=512M at 0xa0000000 earlyprintk
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 512MB = 512MB total
Memory: 516424k/516424k available, 7864k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xe0800000 - 0xfe000000 ( 472 MB)
lowmem : 0xc0000000 - 0xe0000000 ( 512 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0022000 ( 104 kB)
.text : 0xc0022000 - 0xc030d000 (2988 kB)
.data : 0xc030e000 - 0xc0329d60 ( 112 kB)
NR_IRQS:32
sched_clock: 32 bits at 198MHz, resolution 5ns, wraps every 21691ms
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 80000005 [#1]
last sysfs file:
Modules linked in:
CPU: 0 Not tainted (2.6.37-rc6 #1)
PC is at 0x0
LR is at iop_timer_interrupt+0x20/0x28
pc : [<00000000>] lr : [<c002b580>] psr: 400000d3sp : c030fe98 ip : c030fea8 fp : c030fea4
r10: a001c494 r9 : 69052e30 r8 : c0315a8c
r7 : 00000009 r6 : 00000000 r5 : 00000000 r4 : c0312fa0 r3 : 00000000 r2 : 00000001 r1 : c0312fc8 r0 : c0312fc8
Flags: nZcv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
Control: 0000397f Table: a0004000 DAC: 00000017
Process swapper (pid: 0, stack limit = 0xc030e270)
Stack: (0xc030fe98 to 0xc0310000)
fe80: c030fec4 c030fea8
fea0: c005ebfc c002b56c c0315a68 00000009 00000200 60000053 c030fedc c030fec8
fec0: c0060e78 c005ebdc 00000009 00000000 c030fef4 c030fee0 c002207c c0060dd8
fee0: ffffffff c030ff2c c030ff6c c030fef8 c0022ba8 c002200c 00000000 00000001
ff00: 00000000 00000000 c0315a68 c0312fa0 00000009 60000053 c0315a8c 69052e30
ff20: a001c494 c030ff6c c030ff08 c030ff40 c00603e0 c005f7cc 60000053 ffffffff
ff40: 52ef041b 00000001 c0312fa0 00000009 c001d9e4 c0311a58 a001c704 a001c494
ff60: c030ff84 c030ff70 c005fa54 c005f598 c0312fa0 0bcd3d80 c030ffac c030ff88
ff80: c000c3a4 c005fa38 c0315560 600000d3 c0330020 c0329d60 c001d9e8 c001d9e4
ffa0: c030ffbc c030ffb0 c000bee4 c000c358 c030ffcc c030ffc0 c0009f54 c000bedc
ffc0: c030fff4 c030ffd0 c0008a1c c0009f44 c000865c 00000000 00000000 c001d9e8
ffe0: 0000397d c0329e64 00000000 c030fff8 a0008034 c00088b8 00000000 00000000
Backtrace: [<c002b560>] (iop_timer_interrupt+0x0/0x28) from [<c005ebfc>] (handle_IRQ_event+0x2c/0xfc) [<c005ebd0>] (handle_IRQ_event+0x0/0xfc) from [<c0060e78>] (handle_level_irq+0xac/0x11c) r7:60000053 r6:00000200 r5:00000009 r4:c0315a68 [<c0060dcc>] (handle_level_irq+0x0/0x11c) from [<c002207c>] (asm_do_IRQ+0x7c/0xa0) r5:00000000 r4:00000009 [<c0022000>] (asm_do_IRQ+0x0/0xa0) from [<c0022ba8>] (__irq_svc+0x48/0x80) Exception stack(0xc030fef8 to 0xc030ff40)
fee0: 00000000 00000001
ff00: 00000000 00000000 c0315a68 c0312fa0 00000009 60000053 c0315a8c 69052e30
ff20: a001c494 c030ff6c c030ff08 c030ff40 c00603e0 c005f7cc 60000053 ffffffff
r5:c030ff2c r4:ffffffff
[<c005f58c>] (__setup_irq+0x0/0x310) from [<c005fa54>] (setup_irq+0x28/0x2c) [<c005fa2c>] (setup_irq+0x0/0x2c) from [<c000c3a4>] (iop_init_time+0x58/0x108)
r5:0bcd3d80 r4:c0312fa0
[<c000c34c>] (iop_init_time+0x0/0x108) from [<c000bee4>] (n2100_timer_init+0x14/0x1c)
r6:c001d9e4 r5:c001d9e8 r4:c0329d60
[<c000bed0>] (n2100_timer_init+0x0/0x1c) from [<c0009f54>] (time_init+0x1c/0x24) [<c0009f38>] (time_init+0x0/0x24) from [<c0008a1c>] (start_kernel+0x170/0x264) [<c00088ac>] (start_kernel+0x0/0x264) from [<a0008034>] (0xa0008034)
r5:c0329e64 r4:0000397d
Code: bad PC value ---[ end trace 1b75b31a2719ed1c ]--- Kernel panic - not syncing: Fatal exception in interrupt Backtrace: [<c0026314>] (dump_backtrace+0x0/0x118) from [<c025b65c>] (dump_stack+0x18/0x1c) r7:00000000 r6:c030e270 r5:c032a030 r4:c032a030 [<c025b644>] (dump_stack+0x0/0x1c) from [<c025b6c4>] (panic+0x64/0x188) [<c025b660>] (panic+0x0/0x188) from [<c0026758>] (die+0x194/0x1d8) r3:00010000 r2:c030fcf8 r1:00001315 r0:c02ca1bf r7:00000000 [<c00265c4>] (die+0x0/0x1d8) from [<c00285d8>] (__do_kernel_fault+0x6c/0x90) r8:00000000 r7:80000005 r6:00000000 r5:c030fe50 r4:00000000 [<c002856c>] (__do_kernel_fault+0x0/0x90) from [<c00287b8>] (do_page_fault+0x1bc/0x1d4) r9:000000d3 r8:00000000 r7:00000000 r6:00000000 r5:c030fe50
r4:c0310df8
[<c00285fc>] (do_page_fault+0x0/0x1d4) from [<c0028868>] (do_translation_fault+0x24/0xac) [<c0028844>] (do_translation_fault+0x0/0xac) from [<c0022230>] (do_PrefetchAbort+0x3c/0xa0)
r7:c030fe50 r6:00000000 r5:c0311e5c r4:00000005
[<c00221f4>] (do_PrefetchAbort+0x0/0xa0) from [<c0022c90>] (__pabt_svc+0x50/0x80)
Exception stack(0xc030fe50 to 0xc030fe98)
fe40: c0312fc8 c0312fc8 00000001 00000000
fe60: c0312fa0 00000000 00000000 00000009 c0315a8c 69052e30 a001c494 c030fea4
fe80: c030fea8 c030fe98 c002b580 00000000 400000d3 ffffffff
r7:00000009 r6:00000000 r5:c030fe84 r4:ffffffff
[<c002b560>] (iop_timer_interrupt+0x0/0x28) from [<c005ebfc>] (handle_IRQ_event+0x2c/0xfc) [<c005ebd0>] (handle_IRQ_event+0x0/0xfc) from [<c0060e78>] (handle_level_irq+0xac/0x11c)
r7:60000053 r6:00000200 r5:00000009 r4:c0315a68
[<c0060dcc>] (handle_level_irq+0x0/0x11c) from [<c002207c>] (asm_do_IRQ+0x7c/0xa0)
r5:00000000 r4:00000009
[<c0022000>] (asm_do_IRQ+0x0/0xa0) from [<c0022ba8>] (__irq_svc+0x48/0x80)
Exception stack(0xc030fef8 to 0xc030ff40)
fee0: 00000000 00000001
ff00: 00000000 00000000 c0315a68 c0312fa0 00000009 60000053 c0315a8c 69052e30
ff20: a001c494 c030ff6c c030ff08 c030ff40 c00603e0 c005f7cc 60000053 ffffffff
r5:c030ff2c r4:ffffffff
[<c005f58c>] (__setup_irq+0x0/0x310) from [<c005fa54>] (setup_irq+0x28/0x2c) [<c005fa2c>] (setup_irq+0x0/0x2c) from [<c000c3a4>] (iop_init_time+0x58/0x108)
r5:0bcd3d80 r4:c0312fa0
[<c000c34c>] (iop_init_time+0x0/0x108) from [<c000bee4>] (n2100_timer_init+0x14/0x1c)
r6:c001d9e4 r5:c001d9e8 r4:c0329d60
[<c000bed0>] (n2100_timer_init+0x0/0x1c) from [<c0009f54>] (time_init+0x1c/0x24) [<c0009f38>] (time_init+0x0/0x24) from [<c0008a1c>] (start_kernel+0x170/0x264) [<c00088ac>] (start_kernel+0x0/0x264) from [<a0008034>] (0xa0008034)
r5:c0329e64 r4:0000397d
We take an early timer interrupt and call NULL in the
evt->event_handler(evt);
statement in iop_timer_interrupt(). Apparently the evt (dev_id) passed to the interrupt handler isn't initialized at this point.
The most visible change the sched_clock patches did in plat-iop was to add a call to init_sched_clock() at the very start of iop_init_time(), before the timer IRQ, clockevent, and clocksource have been set up. Moving that call to the very end of iop_init_time() [see below] made the kernel boot again, and the interactivity problems were also solved.
With the update below,
arch/arm/plat-iop/time.c renamed from arch/arm/plat-iop/time.c.~1~ +2 -2
@@ -151,8 +151,6 @@ void __init iop_init_time(unsigned long {u32 timer_ctl; -init_sched_clock (&cd, iop_update_sched_clock,32 , tick_rate); - ticks_per_jiffy =DIV_ROUND_CLOSEST (tick_rate,HZ ); iop_tick_rate = tick_rate;
@@ -183,4 +181,6 @@ void __init iop_init_time(unsigned longwrite_tcr1 (0xffffffff );write_tmr1 (timer_ctl);clocksource_register_hz (&iop_clocksource, tick_rate); + +init_sched_clock (&cd, iop_update_sched_clock,32 , tick_rate); }
cover Complete set of clocksource/sched_clock patches
Quoted 130 lines · Mikael Pettersson
Here it is:
Build ATAG
ATAG_MEM: Overwriteram_endwith real_region_top=0x20000000, memsize=512 M
ATAG_MEM=536870912 at0xa0000000, MACH_TYPE=1101
Using base address0x00200000and length0x0018e3c0
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.37-rc6 (mikpe at brewer) (gcc version 4.4.6 20101116 (prerelease) (GCC) ) #1 Sun Dec 19 12:58:45 CET 2010
CPU: XScale-80219 [69052e30] revision 0 (ARMv5TE), cr=0000397f
CPU: VIVT data cache, VIVT instruction cache
Machine: Thecus N2100
bootconsole [earlycon0] enabled
Memory policy: ECC disabled, Data cache writeback
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048
Kernel command line: console=ttyS0,115200 ro root=/dev/sda1 mem=512M at0xa0000000earlyprintk
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 512MB = 512MB total
Memory: 516424k/516424k available, 7864k reserved, 0K highmem
Virtual kernel memory layout:vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) DMA : 0xffc00000 - 0xffe00000 ( 2 MB) vmalloc : 0xe0800000 - 0xfe000000 ( 472 MB) lowmem : 0xc0000000 - 0xe0000000 ( 512 MB) modules : 0xbf000000 - 0xc0000000 ( 16 MB) .init : 0xc0008000 - 0xc0022000 ( 104 kB) .text : 0xc0022000 - 0xc030d000 (2988 kB) .data : 0xc030e000 - 0xc0329d60 ( 112 kB) NR_IRQS:32 sched_clock: 32 bits at 198MHz, resolution 5ns, wraps every 21691ms Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 80000005 [#1] last sysfs file: Modules linked in: CPU: 0 Not tainted (2.6.37-rc6 #1) PC is at 0x0 LR is at iop_timer_interrupt+0x20/0x28 pc : [<00000000>] lr : [<c002b580>] psr: 400000d3sp :
c030fe98ip :c030fea8fp :c030fea4
r10:a001c494r9 :69052e30r8 :c0315a8c
r7 : 00000009 r6 : 00000000 r5 : 00000000 r4 :c0312fa0r3 : 00000000 r2 : 00000001 r1 :c0312fc8r0 :c0312fc8
Flags: nZcv IRQs off FIQs off ModeSVC_32ISA ARM Segment kernel
Control:0000397fTable:a0004000DAC: 00000017
Process swapper (pid: 0, stack limit =0xc030e270)Stack: (0xc030fe98 to 0xc0310000)fe80:
c030fec4c030fea8
fea0:c005ebfcc002b56cc0315a6800000009 00000200 60000053c030fedcc030fec8
fec0:c0060e78c005ebdc00000009 00000000c030fef4c030fee0c002207cc0060dd8
fee0: ffffffffc030ff2cc030ff6cc030fef8c0022ba8c002200c00000000 00000001
ff00: 00000000 00000000c0315a68c0312fa000000009 60000053c0315a8c69052e30
ff20:a001c494c030ff6cc030ff08c030ff40c00603e0c005f7cc60000053 ffffffff
ff40:52ef041b00000001c0312fa000000009c001d9e4c0311a58a001c704a001c494
ff60:c030ff84c030ff70c005fa54c005f598c0312fa00bcd3d80c030ffacc030ff88
ff80:c000c3a4c005fa38c0315560600000d3c0330020c0329d60c001d9e8c001d9e4
ffa0:c030ffbcc030ffb0c000bee4c000c358c030ffccc030ffc0c0009f54c000bedc
ffc0:c030fff4c030ffd0c0008a1cc0009f44c000865c00000000 00000000c001d9e8
ffe0:0000397dc0329e6400000000c030fff8a0008034c00088b800000000 00000000Backtrace: [<c002b560>] (iop_timer_interrupt+0x0/0x28) from [<c005ebfc>] (handle_IRQ_event+0x2c/0xfc) [<c005ebd0>] (handle_IRQ_event+0x0/0xfc) from [<c0060e78>] (handle_level_irq+0xac/0x11c) r7:60000053 r6:00000200 r5:00000009 r4:c0315a68 [<c0060dcc>] (handle_level_irq+0x0/0x11c) from [<c002207c>] (asm_do_IRQ+0x7c/0xa0) r5:00000000 r4:00000009 [<c0022000>] (asm_do_IRQ+0x0/0xa0) from [<c0022ba8>] (__irq_svc+0x48/0x80) Exception stack(0xc030fef8 to 0xc030ff40)fee0: 00000000 00000001
ff00: 00000000 00000000c0315a68c0312fa000000009 60000053c0315a8c69052e30
ff20:a001c494c030ff6cc030ff08c030ff40c00603e0c005f7cc60000053 ffffffff
r5:c030ff2c r4:ffffffff
[<c005f58c>] (__setup_irq+0x0/0x310) from [<c005fa54>] (setup_irq+0x28/0x2c) [<c005fa2c>] (setup_irq+0x0/0x2c) from [<c000c3a4>] (iop_init_time+0x58/0x108)
r5:0bcd3d80 r4:c0312fa0
[<c000c34c>] (iop_init_time+0x0/0x108) from [<c000bee4>] (n2100_timer_init+0x14/0x1c)
r6:c001d9e4 r5:c001d9e8 r4:c0329d60
[<c000bed0>] (n2100_timer_init+0x0/0x1c) from [<c0009f54>] (time_init+0x1c/0x24) [<c0009f38>] (time_init+0x0/0x24) from [<c0008a1c>] (start_kernel+0x170/0x264) [<c00088ac>] (start_kernel+0x0/0x264) from [<a0008034>] (0xa0008034)
r5:c0329e64 r4:0000397dCode: bad PC value ---[ end trace 1b75b31a2719ed1c ]--- Kernel panic - not syncing: Fatal exception in interrupt Backtrace: [<c0026314>] (dump_backtrace+0x0/0x118) from [<c025b65c>] (dump_stack+0x18/0x1c) r7:00000000 r6:c030e270 r5:c032a030 r4:c032a030 [<c025b644>] (dump_stack+0x0/0x1c) from [<c025b6c4>] (panic+0x64/0x188) [<c025b660>] (panic+0x0/0x188) from [<c0026758>] (die+0x194/0x1d8) r3:00010000 r2:c030fcf8 r1:00001315 r0:c02ca1bf r7:00000000 [<c00265c4>] (die+0x0/0x1d8) from [<c00285d8>] (__do_kernel_fault+0x6c/0x90) r8:00000000 r7:80000005 r6:00000000 r5:c030fe50 r4:00000000 [<c002856c>] (__do_kernel_fault+0x0/0x90) from [<c00287b8>] (do_page_fault+0x1bc/0x1d4) r9:000000d3 r8:00000000 r7:00000000 r6:00000000 r5:c030fe50r4:c0310df8
[<c00285fc>] (do_page_fault+0x0/0x1d4) from [<c0028868>] (do_translation_fault+0x24/0xac) [<c0028844>] (do_translation_fault+0x0/0xac) from [<c0022230>] (do_PrefetchAbort+0x3c/0xa0)
r7:c030fe50 r6:00000000 r5:c0311e5c r4:00000005
[<c00221f4>] (do_PrefetchAbort+0x0/0xa0) from [<c0022c90>] (__pabt_svc+0x50/0x80)Exception stack(0xc030fe50 to 0xc030fe98)fe40:
c0312fc8c0312fc800000001 00000000
fe60:c0312fa000000000 00000000 00000009c0315a8c69052e30a001c494c030fea4
fe80:c030fea8c030fe98c002b58000000000400000d3ffffffff
r7:00000009 r6:00000000 r5:c030fe84 r4:ffffffff
[<c002b560>] (iop_timer_interrupt+0x0/0x28) from [<c005ebfc>] (handle_IRQ_event+0x2c/0xfc) [<c005ebd0>] (handle_IRQ_event+0x0/0xfc) from [<c0060e78>] (handle_level_irq+0xac/0x11c)
r7:60000053 r6:00000200 r5:00000009 r4:c0315a68
[<c0060dcc>] (handle_level_irq+0x0/0x11c) from [<c002207c>] (asm_do_IRQ+0x7c/0xa0)
r5:00000000 r4:00000009
[<c0022000>] (asm_do_IRQ+0x0/0xa0) from [<c0022ba8>] (__irq_svc+0x48/0x80)Exception stack(0xc030fef8 to 0xc030ff40)fee0: 00000000 00000001
ff00: 00000000 00000000c0315a68c0312fa000000009 60000053c0315a8c69052e30
ff20:a001c494c030ff6cc030ff08c030ff40c00603e0c005f7cc60000053 ffffffff
r5:c030ff2c r4:ffffffff
[<c005f58c>] (__setup_irq+0x0/0x310) from [<c005fa54>] (setup_irq+0x28/0x2c) [<c005fa2c>] (setup_irq+0x0/0x2c) from [<c000c3a4>] (iop_init_time+0x58/0x108)
r5:0bcd3d80 r4:c0312fa0
[<c000c34c>] (iop_init_time+0x0/0x108) from [<c000bee4>] (n2100_timer_init+0x14/0x1c)
r6:c001d9e4 r5:c001d9e8 r4:c0329d60
[<c000bed0>] (n2100_timer_init+0x0/0x1c) from [<c0009f54>] (time_init+0x1c/0x24) [<c0009f38>] (time_init+0x0/0x24) from [<c0008a1c>] (start_kernel+0x170/0x264) [<c00088ac>] (start_kernel+0x0/0x264) from [<a0008034>] (0xa0008034)
r5:c0329e64 r4:0000397d
Quoted 6 lines
We take an early timer interrupt and call NULL in the
evt->event_handler(evt);statement in
iop_timer_interrupt(). Apparently the evt (dev_id) passed to the interrupt handler isn't initialized at this point.
evt is initialized, it's done statically:
static struct irqaction iop_timer_irq = {
.dev_id = &iop_clockevent,
};
What isn't initialized at this early point is evt->event_handler.
Quoted 5 lines
The most visible change the
sched_clockpatches did in plat-iop was to add a call toinit_sched_clock()at the very start ofiop_init_time(), before the timer IRQ, clockevent, and clocksource have been set up. Moving that call to the very end ofiop_init_time()[see below] made the kernel boot again, and the interactivity problems were also solved.
I think this is a bug just waiting to happen, and the sched_clock patch just gives it a helping hand (by accidentally enabling interrupts early
- and that's something which also needs fixing.)
Here's the event device setup code:
write_tmr0(timer_ctl & ~IOP_TMR_EN);
setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq);
clockevents_calc_mult_shift(&iop_clockevent,
tick_rate, IOP_MIN_RANGE);
iop_clockevent.max_delta_ns =
clockevent_delta2ns(0xfffffffe, &iop_clockevent);
iop_clockevent.min_delta_ns =
clockevent_delta2ns(0xf, &iop_clockevent);
iop_clockevent.cpumask = cpumask_of(0);
clockevents_register_device(&iop_clockevent);
write_trr0(ticks_per_jiffy - 1);
write_tcr0(ticks_per_jiffy - 1);
write_tmr0(timer_ctl);First thing is that although the timer is stopped before the IRQ is registered, there is no clearing of any pending timer interrupt at that time. As we don't know what state the timer was in, we can't be sure that the interrupt isn't already pending.
Second thing is why is the timer being enabled by this code after it's been registered. This is something which should be done by the clockevents code when it's ready via the ->set_mode callback, not when the platform decides to do so - otherwise you can call the interrupt handler when evt->event_handler has not been setup.
So, I think this will solve the IOP misbehaviour. What I don't know is what the cryptic txx0() suffixes on these write statements are (what's the difference between trr and tcr? tcr = timer counter register, trr = timer ? register? Does trr need to be written in ->set_mode (if so that's another bug in this code)?
arch/arm/plat-iop/time.c +1 -3
@@ -162,6 +162,7 @@ void __init iop_init_time(unsigned long tick_rate)* Set up interrupting clockevent timer 0. */ write_tmr0 (timer_ctl & ~IOP_TMR_EN ); +write_tisr (1 );setup_irq (IRQ_IOP_TIMER0 , &iop_timer_irq);clockevents_calc_mult_shift (&iop_clockevent, tick_rate,IOP_MIN_RANGE );
@@ -171,9 +172,6 @@ void __init iop_init_time(unsigned long tick_rate)clockevent_delta2ns (0xf , &iop_clockevent); iop_clockevent.cpumask =cpumask_of (0 );clockevents_register_device (&iop_clockevent); -write_trr0 (ticks_per_jiffy -1 ); -write_tcr0 (ticks_per_jiffy -1 ); -write_tmr0 (timer_ctl);/* * Set up free-running clocksource timer 1.
cover Complete set of clocksource/sched_clock patches
Quoted 46 lines · Russell King - ARM Linux
Quoted 6 lines
We take an early timer interrupt and call NULL in the
evt->event_handler(evt);statement in
iop_timer_interrupt(). Apparently the evt (dev_id) passed to the interrupt handler isn't initialized at this point.evt is initialized, it's done statically:
static struct irqaction
iop_timer_irq= {
.dev_id =&iop_clockevent,
};What isn't initialized at this early point is
evt->event_handler.Quoted 5 lines
The most visible change the
sched_clockpatches did in plat-iop was to add a call toinit_sched_clock()at the very start ofiop_init_time(), before the timer IRQ, clockevent, and clocksource have been set up. Moving that call to the very end ofiop_init_time()[see below] made the kernel boot again, and the interactivity problems were also solved.I think this is a bug just waiting to happen, and the
sched_clockpatch just gives it a helping hand (by accidentally enabling interrupts early
- and that's something which also needs fixing.)Here's the event device setup code:
write_tmr0(timer_ctl & ~IOP_TMR_EN); setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq); clockevents_calc_mult_shift(&iop_clockevent, tick_rate, IOP_MIN_RANGE); iop_clockevent.max_delta_ns = clockevent_delta2ns(0xfffffffe, &iop_clockevent); iop_clockevent.min_delta_ns = clockevent_delta2ns(0xf, &iop_clockevent); iop_clockevent.cpumask = cpumask_of(0); clockevents_register_device(&iop_clockevent); write_trr0(ticks_per_jiffy - 1); write_tcr0(ticks_per_jiffy - 1); write_tmr0(timer_ctl);First thing is that although the timer is stopped before the IRQ is registered, there is no clearing of any pending timer interrupt at that time. As we don't know what state the timer was in, we can't be sure that the interrupt isn't already pending.
Quoted 5 lines
Second thing is why is the timer being enabled by this code after it's been registered. This is something which should be done by the clockevents code when it's ready via the ->set_mode callback, not when the platform decides to do so - otherwise you can call the interrupt handler when
evt->event_handlerhas not been setup.
When I did the IOP clockevents conversion I didn't know that the timer should be disabled, so I probably just kept the previous code to enable it.
Quoted 4 lines
So, I think this will solve the IOP misbehaviour. What I don't know is what the cryptic
txx0()suffixes on these write statements are (what's the difference between trr and tcr? tcr = timer counter register, trr = timer ? register?
tmr = timer mode register
tcr = timer counter register
trr = timer reload register
When a timer is in periodic mode it reloads itself from its reload register when the counter register decrements to zero.
Quoted 2 lines
Does trr need to be written in
->set_mode (if so that's another bug in this code)?
trr{0,1} need not and should not be changed after iop_time_init().
Quoted 13 lines
arch/arm/plat-iop/time.c +1
-0@@ -162,6 +162,7 @@ void __init iop_init_time(unsigned long tick_rate)* Set up interrupting clockevent timer 0. */ write_tmr0 (timer_ctl & ~IOP_TMR_EN ); +write_tisr (1 );setup_irq (IRQ_IOP_TIMER0 , &iop_timer_irq);clockevents_calc_mult_shift (&iop_clockevent, tick_rate,IOP_MIN_RANGE );
arch/arm/plat-iop/time.c void __init iop_init_time(unsigned long tick_rate) · line 177
Quoted 9 lines
arch/arm/plat-iop/time.c +0
-3@@ -171,9 +172,6 @@ void __init iop_init_time(unsigned long tick_rate)clockevent_delta2ns (0xf , &iop_clockevent); iop_clockevent.cpumask =cpumask_of (0 );clockevents_register_device (&iop_clockevent); -write_trr0 (ticks_per_jiffy -1 ); -write_tcr0 (ticks_per_jiffy -1 ); -write_tmr0 (timer_ctl);/* * Set up free-running clocksource timer 1.
Yes, this seems correct. Tested in a vanilla kernel w/o sched_clock patches, and in a kernel with the sched_clock patches it eliminated the boot hang.
cover Complete set of clocksource/sched_clock patches
Quoted 6 lines · Mikael Pettersson
tmr = timer mode register
tcr = timer counter register
trr = timer reload registerWhen a timer is in periodic mode it reloads itself from its reload register when the counter register decrements to zero.
Ok.
Quoted 4 lines
Quoted 2 lines
Does trr need to be written in
->set_mode (if so that's another bug in this code)?trr{0,1} need not and should not be changed after
iop_time_init().
It sounds like trr0 needs to be written in ->set_mode's CLOCK_EVT_MODE_PERIODIC path then, because with my patch, we never set this register. Or will trr0 be updated when we write tcr0 ?
cover Complete set of clocksource/sched_clock patches
Quoted 8 lines · Russell King - ARM Linux
Quoted 4 lines
Quoted 2 lines
Does trr need to be written in
->set_mode (if so that's another bug in this code)?trr{0,1} need not and should not be changed after
iop_time_init().It sounds like trr0 needs to be written in ->set_mode's
CLOCK_EVT_MODE_PERIODICpath then, because with my patch, we never set this register.
Hmm, yes, your patch does cause that. I think it's better to keep the write_trr0() in iop_init_time(), but move it ahead of the clockevents_register_device() call; this avoids a needless reinitialization of trr0 in ->set_mode's CLOCK_EVT_MODE_PERIODIC case. Writing to trr0 is safe, it's only the early write to tmr0 that's dangerous.
My kernel survived that bug because I have CONFIG_NO_HZ=y so the clockevents timer is always(?) reprogrammed into oneshot-mode, which doesn't use trr0.
Quoted 1 line
Or will trr0 be updated when we write tcr0 ?
No, only explicit write_trr0() calls can update trr0.
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 7 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. ?There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Hi Russell,
Sorry for late feedback. Tested the branch 'clksrc' on Littleton/PXA3xx, seems to be good.
cover Complete set of clocksource/sched_clock patches
Quoted 10 lines · Eric Miao
Quoted 7 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. ?There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Quoted 6 lines
Hi Russell,
Sorry for late feedback. Tested the branch 'clksrc' on Littleton/PXA3xx, seems to be good.
Tested-by Eric Miao <[email protected]>
Ok, I'll add that to the PXA and generic patches, thanks.
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 6 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
on a few davinci platforms.
Kevin
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 6 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. ?There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Tegra (see comment to that specific patch for a needed fixup):
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxQuoted 6 lines · Russell King - ARM Linux
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Don't know if it helps, but I've tested the core patches on my picoxcell series with the fixed versions and it works nicely.
Jamie
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM LinuxAdd my ack to [PATCH 02/40] ARM: bcmring: update clock source registration:
Thanks,
Jiandong Zheng
-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Friday, December 17, 2010 3:32 AM
To: Alessandro Rubini; Bryan Huntsman; Colin Cross; Daniel Walker; David Brown; Eric Miao; Erik Gilling; Hans J. Koch; Imre Kaloz; Kevin Hilman; Krzysztof Halasa; Kukjin Kim; Lennert Buytenhek; JD (Jiandong) Zheng; Linus Walleij; linux-arm-msm at vger.kernel.org; linux-omap at vger.kernel.org; linux-samsung-soc at vger.kernel.org; linux-tegra at vger.kernel.org; Nicolas Pitre; Olof Johansson; Sascha Hauer; Scott Branden; STEricsson; Tony Lindgren; Viresh Kumar; Wan ZongShun
Cc: linux-arm-kernel at lists.infradead.org
Subject: [PATCH 0/40] Complete set of clocksource/sched_clock patches
Here is the entire set of clocksource and sched_clock patches which have been previously posted. There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.
Still looking for acks or tested-by's for these patches.
cover Complete set of clocksource/sched_clock patches
In reply to Russell King - ARM Linux2010/12/17 Russell King - ARM Linux <[email protected]>:
Quoted 7 lines
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. ?There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Signature · 10 lines
*linux-arm-kernel mailing list mail addr:linux-arm-kernel at lists.infradead.org you can subscribe by: http://lists.infradead.org/mailman/listinfo/linux-arm-kernel * linux-arm-NUC900 mailing list mail addr:NUC900 at googlegroups.com main web: https://groups.google.com/group/NUC900 you can subscribe it by sending me mail: mcuos.com at gmail.com
cover Complete set of clocksource/sched_clock patches
Quoted 10 lines · Wan ZongShun
2010/12/17 Russell King - ARM Linux <[email protected]>:
Quoted 7 lines
Here is the entire set of clocksource and
sched_clockpatches which have been previously posted. ?There's a couple of small tweaks in a few of the patches (such as adding notrace to OMAP clocksource read functions), and this also shows the proper ordering of these patches.Still looking for acks or tested-by's for these patches.
Acked-by Wan Zongshun <[email protected]>
I'm afraid you're too late - it's already in mainline so your ack can't be added.