timer changes for v3.13
Subsystems (20)
Ingo Molnar
maintainerLinus,
Please pull the latest timers-core-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-core-for-linus
# HEAD: ee5872befc9324fa4c2583c24d7ee7120314a2b7 x86/time: Honor ACPI FADT flag indicating absence of a CMOS RTC
Main changes in this cycle were:
* Updated full dynticks support.
* Event stream support for architected (ARM) timers.
* ARM clocksource driver updates.
* Move arm64 to using the generic sched_clock framework & resulting cleanup in the generic sched_clock code.
* Misc fixes and cleanups
Thanks,
Ingo
------------------>
Boris BREZILLON (3):
clocksource: tcb_clksrc: Replace clk_enable/disable with clk_prepare_enable/disable_unprepare
clocksource: tcb_clksrc: Improve driver robustness
clocksource: tcb_clksrc: Remove IRQF_DISABLED
Dong Zhu (1):
timer stats: Add a 'Collection: active/inactive' line to timer usage statistics
Elad Wexler (1):
clocksource: Fix 'ret' data type of sysfs_override_clocksource() and sysfs_unbind_clocksource()
Jan Beulich (1):
x86/time: Honor ACPI FADT flag indicating absence of a CMOS RTC
John Stultz (1):
rtc: rtc-pl031: Set wakeup flag prior to registering rtcdev
KOSAKI Motohiro (1):
alarmtimer: return EINVAL instead of ENOTSUPP if rtcdev doesn't exist
Kevin Hilman (3):
vtime: Add HAVE_VIRT_CPU_ACCOUNTING_GEN Kconfig
nohz: Drop generic vtime obsolete dependency on CONFIG_64BIT
ARM: Kconfig: allow full nohz CPU accounting
Maxime Ripard (3):
clocksource: sun4i: Select CLKSRC_MMIO
clocksource: sun4i: Report the minimum tick that we can program
clocksource: sun4i: remove IRQF_DISABLED
Miroslav Lichvar (1):
ntp: Make periodic RTC update more reliable
Patrick Palka (1):
time: Fix signedness bug in sysfs_get_uname() and its callers
Prarit Bhargava (1):
clocksource: Fix !CONFIG_CLOCKSOURCE_WATCHDOG compile
Shinya Kuribayashi (1):
clocksource: em_sti: convert to clk_prepare/unprepare
Soren Brinkmann (4):
clockchips: Add FEAT_PERCPU clockevent flag clocksource/arm_global_timer: Set FEAT_PERCPU flag
tick: broadcast: Deny per-cpu clockevents from being broadcast sources
arm: zynq: Enable arm_global_timer
Stephen Boyd (17):
clocksource: Extract max nsec calculation into separate function
sched_clock: Use seqcount instead of rolling our own
sched_clock: Use an hrtimer instead of timer
sched_clock: Add support for >32 bit sched_clock
clocksource: bcm2835: Switch to sched_clock_register()
clocksource: dbx500-prcmu: Switch to sched_clock_register()
clocksource: dw_apb_timer_of: Switch to sched_clock_register()
clocksource: mxs_timer: Switch to sched_clock_register()
clocksource: nomadik: Switch to sched_clock_register()
clocksource: samsung_pwm_timer: Switch to sched_clock_register()
clocksource: tegra: Switch to sched_clock_register()
clocksource: time-armada-370-xp: Switch to sched_clock_register()
clocksource: sirf: Switch to sched_clock_register() and use 64 bits
clocksource: vf_pit_timer: Switch to sched_clock_register()
clocksource: arm_arch_timer: Use clocksource for suspend timekeeping
arch_timer: Move to generic sched_clock framework
sched_clock: Remove sched_clock_func() hook
Sudeep KarkadaNagesha (4):
ARM/ARM64: arch_timer: add macros for bits in control register
ARM: arch_timer: add support to configure and enable event stream
ARM64: arch_timer: add support to configure and enable event stream
drivers: clocksource: add CPU PM notifier for ARM architected timer
Thierry Reding (1):
clocksource: arch_timer: Do not register arch_sys_counter twice
Uwe Kleine-König (3):
clocksource: Put nodes passed to CLOCKSOURCE_OF_DECLARE callbacks centrally
clocksource: dw_apb_timer_of: Mark a few more functions as __init
clocksource: Provide timekeeping for efm32 SoCs
Will Deacon (1):
drivers: clocksource: add support for ARM architected timer event stream
Xie XiuQi (1):
timekeeping: Fix some trivial typos in comments
Zoran Markovic (1):
rtc: Keep system awake until all expired RTC timers are handled
.../devicetree/bindings/timer/efm32,timer.txt | 23 ++ arch/Kconfig | 12 + arch/arm/Kconfig | 1 + arch/arm/boot/dts/zynq-7000.dtsi | 8 + arch/arm/include/asm/arch_timer.h | 36 ++- arch/arm/include/uapi/asm/hwcap.h | 1 + arch/arm/kernel/arch_timer.c | 14 -- arch/arm/kernel/setup.c | 1 + arch/arm/mach-msm/timer.c | 1 - arch/arm/mach-zynq/Kconfig | 1 + arch/arm64/Kconfig | 1 + arch/arm64/include/asm/arch_timer.h | 42 +++- arch/arm64/include/asm/hwcap.h | 11 +- arch/arm64/include/uapi/asm/hwcap.h | 1 + arch/arm64/kernel/setup.c | 11 + arch/arm64/kernel/time.c | 10 - arch/x86/kernel/rtc.c | 8 + drivers/clocksource/Kconfig | 24 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/arm_arch_timer.c | 55 ++++- drivers/clocksource/arm_global_timer.c | 3 +- drivers/clocksource/bcm2835_timer.c | 4 +- drivers/clocksource/clksrc-dbx500-prcmu.c | 5 +- drivers/clocksource/clksrc-of.c | 1 + drivers/clocksource/dw_apb_timer_of.c | 16 +- drivers/clocksource/em_sti.c | 4 +- drivers/clocksource/mxs_timer.c | 4 +- drivers/clocksource/nomadik-mtu.c | 4 +- drivers/clocksource/samsung_pwm_timer.c | 4 +- drivers/clocksource/sun4i_timer.c | 12 +- drivers/clocksource/tcb_clksrc.c | 61 ++++- drivers/clocksource/tegra20_timer.c | 8 +- drivers/clocksource/time-armada-370-xp.c | 4 +- drivers/clocksource/time-efm32.c | 275 +++++++++++++++++++++ drivers/clocksource/timer-prima2.c | 6 +- drivers/clocksource/vf_pit_timer.c | 4 +- drivers/clocksource/vt8500_timer.c | 2 - drivers/rtc/interface.c | 13 +- drivers/rtc/rtc-pl031.c | 3 +- include/clocksource/arm_arch_timer.h | 10 + include/linux/clockchips.h | 1 + include/linux/clocksource.h | 2 + include/linux/sched_clock.h | 4 +- init/Kconfig | 3 +- kernel/time/Kconfig | 2 +- kernel/time/alarmtimer.c | 4 +- kernel/time/clockevents.c | 2 +- kernel/time/clocksource.c | 52 ++-- kernel/time/ntp.c | 3 +- kernel/time/sched_clock.c | 114 ++++----- kernel/time/tick-broadcast.c | 1 + kernel/time/tick-internal.h | 2 +- kernel/time/timekeeping.c | 3 +- kernel/time/timer_stats.c | 8 +- 54 files changed, 717 insertions(+), 189 deletions(-) create mode 100644 Documentation/devicetree/bindings/timer/efm32,timer.txt create mode 100644 drivers/clocksource/time-efm32.c
Documentation/devicetree/bindings/timer/efm32,timer.txt new file +23 -0
@@ -0,0 +1,23 @@ +* EFM32 timer hardware + +The efm32 Giant Gecko SoCs come with four 16 bit timers. Two counters can be +connected to form a 32 bit counter. Each timer has three Compare/Capture +channels and can be used as PWM or Quadrature Decoder. Available clock sources +are the cpu's HFPERCLK (with a 10-bit prescaler) or an external pin. + +Required properties: +- compatible : Should be efm32,timer +- reg : Address and length of the register set +- clocks : Should contain a reference to the HFPERCLK + +Optional properties: +- interrupts : Reference to the timer interrupt + +Example: + +timer@40010c00 { + compatible = "efm32,timer"; + reg = <0x40010c00 0x400>; + interrupts = <14>; + clocks = <&cmu clk_HFPERCLKTIMER3>; +};
arch/Kconfig +12 -0
@@ -353,6 +353,18 @@ config HAVE_CONTEXT_TRACKING config HAVE_VIRT_CPU_ACCOUNTING bool +config HAVE_VIRT_CPU_ACCOUNTING_GEN + bool + default y if 64BIT + help + With VIRT_CPU_ACCOUNTING_GEN, cputime_t becomes 64-bit. + Before enabling this option, arch code must be audited + to ensure there are no races in concurrent read/write of + cputime_t. For example, reading/writing 64-bit cputime_t on + some 32-bit arches may require multiple accesses, so proper + locking is needed to protect against concurrent accesses. + + config HAVE_IRQ_TIME_ACCOUNTING bool help
arch/arm/Kconfig +1 -0
@@ -54,6 +54,7 @@ config ARM select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_SYSCALL_TRACEPOINTS select HAVE_UID16 + select HAVE_VIRT_CPU_ACCOUNTING_GEN select IRQ_FORCED_THREADING select KTIME_SCALAR select MODULES_USE_ELF_REL
arch/arm/boot/dts/zynq-7000.dtsi +8 -0
@@ -92,6 +92,14 @@ }; }; + global_timer: timer@f8f00200 { + compatible = "arm,cortex-a9-global-timer"; + reg = <0xf8f00200 0x20>; + interrupts = <1 11 0x301>; + interrupt-parent = <&intc>; + clocks = <&clkc 4>; + }; + ttc0: ttc0@f8001000 { interrupt-parent = <&intc>; interrupts = < 0 10 4 0 11 4 0 12 4 >;
arch/arm/include/asm/arch_timer.h +31 -5
@@ -87,17 +87,43 @@ static inline u64 arch_counter_get_cntvct(void)return cval; } -static inline void arch_counter_set_user_access (void ) +static inline u32 arch_timer_get_cntkctl (void ) {u32 cntkctl; - asmvolatile ("mrc p15, 0, %0, c14, c1, 0" :"=r" (cntkctl)); +return cntkctl; +} -/* disable user access to everything */ - cntkctl &= ~((3 <<8 ) | (7 <<0 )); - +static inline void arch_timer_set_cntkctl (u32 cntkctl) +{ asmvolatile ("mcr p15, 0, %0, c14, c1, 0" : :"r" (cntkctl)); } + +static inline void arch_counter_set_user_access (void ) +{ +u32 cntkctl =arch_timer_get_cntkctl (); + +/* Disable user access to both physical/virtual counters/timers */ +/* Also disable virtual event stream */ + cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN + |ARCH_TIMER_USR_VT_ACCESS_EN + |ARCH_TIMER_VIRT_EVT_EN + |ARCH_TIMER_USR_VCT_ACCESS_EN + |ARCH_TIMER_USR_PCT_ACCESS_EN ); +arch_timer_set_cntkctl (cntkctl); +} + +static inline void arch_timer_evtstrm_enable (int divider) +{ +u32 cntkctl =arch_timer_get_cntkctl (); + cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK ; +/* Set the divider and enable virtual event stream */ + cntkctl |= (divider <<ARCH_TIMER_EVT_TRIGGER_SHIFT ) + |ARCH_TIMER_VIRT_EVT_EN ; +arch_timer_set_cntkctl (cntkctl); + elf_hwcap |=HWCAP_EVTSTRM ; +} +#endif #endif
arch/arm/include/uapi/asm/hwcap.h +1 -0
@@ -26,5 +26,6 @@#define HWCAP_VFPD32 (1 << 19)/* set if VFP has 32 regs (not 16) */ #define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)#define HWCAP_LPAE (1 << 20) +#define HWCAP_EVTSTRM (1 << 21)#endif /* _UAPI__ASMARM_HWCAP_H */
arch/arm/kernel/arch_timer.c +0 -14
@@ -11,7 +11,6 @@#include <linux/init.h> #include <linux/types.h> #include <linux/errno.h> -#include <linux/sched_clock.h> #include <asm/delay.h>
@@ -22,13 +21,6 @@ static unsigned long arch_timer_read_counter_long(void)return arch_timer_read_counter (); } -static u32 sched_clock_mult__read_mostly ; - -static unsigned long long notrace arch_timer_sched_clock (void ) -{ -return arch_timer_read_counter () * sched_clock_mult; -} -static struct delay_timer arch_delay_timer;static void __init arch_timer_delay_timer_register (void )
@@ -48,11 +40,5 @@ int __init arch_timer_arch_init(void)arch_timer_delay_timer_register (); -/* Cache the sched_clock multiplier to save a divide in the hot path. */ - sched_clock_mult =NSEC_PER_SEC / arch_timer_rate; - sched_clock_func = arch_timer_sched_clock; -pr_info ("sched_clock: ARM arch timer >56 bits at %ukHz, resolution %uns\n" , - arch_timer_rate /1000 , sched_clock_mult); -return 0 ; }
arch/arm/kernel/setup.c +1 -0
@@ -975,6 +975,7 @@ static const char *hwcap_str[] = {"idivt" ,"vfpd32" ,"lpae" , +"evtstrm" , NULL };
arch/arm/mach-msm/timer.c +0 -1
@@ -274,7 +274,6 @@ static void __init msm_dt_timer_init(struct device_node *np)pr_err ("Unknown frequency\n" );return ; } -of_node_put (np); event_base = base +0x4 ; sts_base = base +0x88 ;
arch/arm/mach-zynq/Kconfig +1 -0
@@ -13,5 +13,6 @@ config ARCH_ZYNQ select HAVE_SMP select SPARSE_IRQ select CADENCE_TTC_TIMER + select ARM_GLOBAL_TIMER help Support for Xilinx Zynq ARM Cortex A9 Platform
arch/arm64/Kconfig +1 -0
@@ -14,6 +14,7 @@ config ARM64 select GENERIC_IOMAP select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW + select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select HARDIRQS_SW_RESEND
arch/arm64/include/asm/arch_timer.h +36 -6
55 lines not on this page · raw message
arch/arm64/include/asm/hwcap.h +6 -5
@@ -30,6 +30,7 @@#define COMPAT_HWCAP_IDIVA (1 << 17)#define COMPAT_HWCAP_IDIVT (1 << 18)#define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) +#define COMPAT_HWCAP_EVTSTRM (1 << 21)#ifndef __ASSEMBLY__/*
@@ -37,11 +38,11 @@* instruction set this cpu supports. */ #define ELF_HWCAP (elf_hwcap) -#define COMPAT_ELF_HWCAP (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\ - COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\ - COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\ - COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\ - COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV) + +#ifdef CONFIG_COMPAT +#define COMPAT_ELF_HWCAP (compat_elf_hwcap) +extern unsigned int compat_elf_hwcap; +#endif extern unsigned long elf_hwcap;#endif
arch/arm64/include/uapi/asm/hwcap.h +1 -0
@@ -21,6 +21,7 @@*/ #define HWCAP_FP (1 << 0)#define HWCAP_ASIMD (1 << 1) +#define HWCAP_EVTSTRM (1 << 2)#endif /* _UAPI__ASM_HWCAP_H */
arch/arm64/kernel/setup.c +11 -0
@@ -60,6 +60,16 @@ EXPORT_SYMBOL(processor_id);unsigned long elf_hwcap__read_mostly ;EXPORT_SYMBOL_GPL (elf_hwcap); +#ifdef CONFIG_COMPAT +#define COMPAT_ELF_HWCAP_DEFAULT \ + (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\ + COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\ + COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\ + COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\ + COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV) +unsigned int compat_elf_hwcap__read_mostly =COMPAT_ELF_HWCAP_DEFAULT ; +#endif +static const char *cpu_name;static const char *machine_name;phys_addr_t __fdt_pointer__initdata ;
@@ -304,6 +314,7 @@ subsys_initcall(topology_init);static const char *hwcap_str[] = {"fp" ,"asimd" , +"evtstrm" ,NULL };
arch/arm64/kernel/time.c +0 -10
@@ -61,13 +61,6 @@ unsigned long profile_pc(struct pt_regs *regs)EXPORT_SYMBOL (profile_pc);#endif -static u64 sched_clock_mult__read_mostly ; - -unsigned long long notrace sched_clock (void ) -{ -return arch_timer_read_counter () * sched_clock_mult; -} -void __init time_init (void ) {u32 arch_timer_rate;
@@ -78,9 +71,6 @@ void __init time_init(void)if (!arch_timer_rate)panic ("Unable to initialise architected timer.\n" ); -/* Cache the sched_clock multiplier to save a divide in the hot path. */ - sched_clock_mult =NSEC_PER_SEC / arch_timer_rate; -/* Calibrate the delay loop directly */ lpj_fine = arch_timer_rate /HZ ; }
arch/x86/kernel/rtc.c +8 -0
@@ -192,6 +192,14 @@ static __init int add_rtc_cmos(void)if (mrst_identify_cpu ())return -ENODEV ; +#ifdef CONFIG_ACPI +if (acpi_gbl_FADT.boot_flags &ACPI_FADT_NO_CMOS_RTC ) { +/* This warning can likely go away again in a year or two. */ +pr_info ("ACPI: not registering RTC platform device\n" ); +return -ENODEV ; + } +#endif +platform_device_register (&rtc_device);dev_info (&rtc_device.dev,"registered platform RTC device (no PNP device found)\n" );
drivers/clocksource/Kconfig +24 -0
@@ -34,6 +34,7 @@ config ORION_TIMER bool config SUN4I_TIMER + select CLKSRC_MMIO bool config VT8500_TIMER
@@ -71,10 +72,33 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK help Use the always on PRCMU Timer as sched_clock +config CLKSRC_EFM32 + bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32 + depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST) + default ARCH_EFM32 + help + Support to use the timers of EFM32 SoCs as clock source and clock + event device. + config ARM_ARCH_TIMER bool select CLKSRC_OF if OF +config ARM_ARCH_TIMER_EVTSTREAM + bool "Support for ARM architected timer event stream generation" + default y if ARM_ARCH_TIMER + help + This option enables support for event stream generation based on + the ARM architected timer. It is used for waking up CPUs executing + the wfe instruction at a frequency represented as a power-of-2 + divisor of the clock rate. + The main use of the event stream is wfe-based timeouts of userspace + locking implementations. It might also be useful for imposing timeout + on wfe to safeguard against any programming errors in case an expected + event is not generated. + This must be disabled for hardware validation purposes to detect any + hardware anomalies of missing events. + config ARM_GLOBAL_TIMER bool select CLKSRC_OF if OF
drivers/clocksource/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_VT8500_TIMER) += vt8500_timer.o obj-$(CONFIG_ARCH_NSPIRE) += zevio-timer.o obj-$(CONFIG_ARCH_BCM) += bcm_kona_timer.o obj-$(CONFIG_CADENCE_TTC_TIMER) += cadence_ttc_timer.o +obj-$(CONFIG_CLKSRC_EFM32) += time-efm32.o obj-$(CONFIG_CLKSRC_EXYNOS_MCT) += exynos_mct.o obj-$(CONFIG_CLKSRC_SAMSUNG_PWM) += samsung_pwm_timer.o obj-$(CONFIG_VF_PIT_TIMER) += vf_pit_timer.o
drivers/clocksource/arm_arch_timer.c +54 -1
108 lines not on this page · raw message
drivers/clocksource/arm_global_timer.c +2 -1
@@ -169,7 +169,8 @@ static int gt_clockevents_init(struct clock_event_device *clk)int cpu =smp_processor_id (); clk->name ="arm_global_timer" ; - clk->features =CLOCK_EVT_FEAT_PERIODIC |CLOCK_EVT_FEAT_ONESHOT ; + clk->features =CLOCK_EVT_FEAT_PERIODIC |CLOCK_EVT_FEAT_ONESHOT | +CLOCK_EVT_FEAT_PERCPU ; clk->set_mode = gt_clockevent_set_mode; clk->set_next_event = gt_clockevent_set_next_event; clk->cpumask =cpumask_of (cpu);
drivers/clocksource/bcm2835_timer.c +2 -2
@@ -49,7 +49,7 @@ struct bcm2835_timer {static void __iomem *system_clock__read_mostly ; -static u32 notrace bcm2835_sched_read(void) +static u64 notrace bcm2835_sched_read(void) {return readl_relaxed (system_clock); }
@@ -110,7 +110,7 @@ static void __init bcm2835_timer_init(struct device_node *node)panic ("Can't read clock-frequency" ); system_clock = base +REG_COUNTER_LO ; -setup_sched_clock (bcm2835_sched_read,32 , freq); +sched_clock_register (bcm2835_sched_read,32 , freq);clocksource_mmio_init (base +REG_COUNTER_LO , node->name, freq,300 ,32 , clocksource_mmio_readl_up);
drivers/clocksource/clksrc-dbx500-prcmu.c +2 -3
@@ -53,7 +53,7 @@ static struct clocksource clocksource_dbx500_prcmu = {#ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK -static u32 notrace dbx500_prcmu_sched_clock_read(void) +static u64 notrace dbx500_prcmu_sched_clock_read(void) {if (unlikely (!clksrc_dbx500_timer_base))return 0 ;
@@ -81,8 +81,7 @@ void __init clksrc_dbx500_prcmu_init(void __iomem *base) clksrc_dbx500_timer_base + PRCMU_TIMER_REF); }#ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK -setup_sched_clock (dbx500_prcmu_sched_clock_read, -32 ,RATE_32K ); +sched_clock_register (dbx500_prcmu_sched_clock_read,32 ,RATE_32K );#endif clocksource_register_hz (&clocksource_dbx500_prcmu,RATE_32K ); }
drivers/clocksource/clksrc-of.c +1 -0
@@ -35,5 +35,6 @@ void __init clocksource_of_init(void) init_func = match->data;init_func (np); +of_node_put (np); } }
drivers/clocksource/dw_apb_timer_of.c +7 -9
@@ -23,7 +23,7 @@#include <linux/clk.h> #include <linux/sched_clock.h> -static void timer_get_base_and_rate (struct device_node *np, +static void __init timer_get_base_and_rate (struct device_node *np,void __iomem **base,u32 *rate) {struct clk *timer_clk;
@@ -55,11 +55,11 @@ static void timer_get_base_and_rate(struct device_node *np, try_clock_freq:if (of_property_read_u32 (np,"clock-freq" , rate) && -of_property_read_u32 (np,"clock-frequency" , rate)) +of_property_read_u32 (np,"clock-frequency" , rate))panic ("No clock nor clock-frequency property for %s" , np->name); } -static void add_clockevent (struct device_node *event_timer) +static void __init add_clockevent (struct device_node *event_timer) {void __iomem *iobase;struct dw_apb_clock_event_device *ced;
@@ -82,7 +82,7 @@ static void add_clockevent(struct device_node *event_timer)static void __iomem *sched_io_base;static u32 sched_rate; -static void add_clocksource (struct device_node *source_timer) +static void __init add_clocksource (struct device_node *source_timer) {void __iomem *iobase;struct dw_apb_clocksource *cs;
@@ -106,7 +106,7 @@ static void add_clocksource(struct device_node *source_timer) sched_rate = rate; } -static u32 read_sched_clock (void ) +static u64 read_sched_clock (void ) {return __raw_readl (sched_io_base); }
@@ -117,7 +117,7 @@ static const struct of_device_id sptimer_ids[] __initconst = { { /* Sentinel */ }, }; -static void init_sched_clock (void ) +static void __init init_sched_clock (void ) {struct device_node *sched_timer;
@@ -128,7 +128,7 @@ static void init_sched_clock(void)of_node_put (sched_timer); } -setup_sched_clock (read_sched_clock,32 , sched_rate); +sched_clock_register (read_sched_clock,32 , sched_rate); }static int num_called;
@@ -138,12 +138,10 @@ static void __init dw_apb_timer_init(struct device_node *timer)case 0 :pr_debug ("%s: found clockevent timer\n" , __func__);add_clockevent (timer); -of_node_put (timer);break ;case 1 :pr_debug ("%s: found clocksource timer\n" , __func__);add_clocksource (timer); -of_node_put (timer);init_sched_clock ();break ;default :
drivers/clocksource/em_sti.c +2 -2
@@ -78,7 +78,7 @@ static int em_sti_enable(struct em_sti_priv *p)int ret;/* enable clock */ - ret =clk_enable (p->clk); + ret =clk_prepare_enable (p->clk);if (ret) {dev_err (&p->pdev->dev,"cannot enable clock\n" );return ret;
@@ -107,7 +107,7 @@ static void em_sti_disable(struct em_sti_priv *p)em_sti_write (p,STI_INTENCLR ,3 );/* stop clock */ -clk_disable (p->clk); +clk_disable_unprepare (p->clk); }static cycle_t em_sti_count (struct em_sti_priv *p)
drivers/clocksource/mxs_timer.c +2 -2
@@ -222,7 +222,7 @@ static struct clocksource clocksource_mxs = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; -static u32 notrace mxs_read_sched_clock_v2(void) +static u64 notrace mxs_read_sched_clock_v2(void) {return ~readl_relaxed (mxs_timrot_base +HW_TIMROT_RUNNING_COUNTn (1 )); }
@@ -236,7 +236,7 @@ static int __init mxs_clocksource_init(struct clk *timer_clk)else {clocksource_mmio_init (mxs_timrot_base +HW_TIMROT_RUNNING_COUNTn (1 ),"mxs_timer" , c,200 ,32 , clocksource_mmio_readl_down); -setup_sched_clock (mxs_read_sched_clock_v2,32 , c); +sched_clock_register (mxs_read_sched_clock_v2,32 , c); }return 0 ;
drivers/clocksource/nomadik-mtu.c +2 -2
@@ -76,7 +76,7 @@ static struct delay_timer mtu_delay_timer;* local implementation which uses the clocksource to get some * better resolution when scheduling the kernel. */ -static u32 notrace nomadik_read_sched_clock(void) +static u64 notrace nomadik_read_sched_clock(void) {if (unlikely (!mtu_base))return 0 ;
@@ -231,7 +231,7 @@ static void __init __nmdk_timer_init(void __iomem *base, int irq, "mtu_0");#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK -setup_sched_clock (nomadik_read_sched_clock,32 , rate); +sched_clock_register (nomadik_read_sched_clock,32 , rate);#endif /* Timer 1 is used for events, register irq and clockevents */
drivers/clocksource/samsung_pwm_timer.c +2 -2
@@ -331,7 +331,7 @@ static struct clocksource samsung_clocksource = {* this wraps around for now, since it is just a relative time * stamp. (Inspired by U300 implementation.) */ -static u32 notrace samsung_read_sched_clock(void) +static u64 notrace samsung_read_sched_clock(void) {return samsung_clocksource_read (NULL ); }
@@ -357,7 +357,7 @@ static void __init samsung_clocksource_init(void)else pwm.source_reg = pwm.base + pwm.source_id *0x0c +0x14 ; -setup_sched_clock (samsung_read_sched_clock, +sched_clock_register (samsung_read_sched_clock, pwm.variant.bits, clock_rate); samsung_clocksource.mask =CLOCKSOURCE_MASK (pwm.variant.bits);
drivers/clocksource/sun4i_timer.c +7 -5
@@ -37,6 +37,8 @@#define TIMER_INTVAL_REG (val) (0x10 * (val) + 0x14)#define TIMER_CNTVAL_REG (val) (0x10 * (val) + 0x18) +#define TIMER_SYNC_TICKS 3 +static void __iomem *timer_base;static u32 ticks_per_jiffy;
@@ -50,7 +52,7 @@ static void sun4i_clkevt_sync(void) {u32 old =readl (timer_base +TIMER_CNTVAL_REG (1 )); -while ((old -readl (timer_base +TIMER_CNTVAL_REG (1 ))) <3 ) +while ((old -readl (timer_base +TIMER_CNTVAL_REG (1 ))) <TIMER_SYNC_TICKS )cpu_relax (); }
@@ -104,7 +106,7 @@ static int sun4i_clkevt_next_event(unsigned long evt, struct clock_event_device *unused) {sun4i_clkevt_time_stop (0 ); -sun4i_clkevt_time_setup (0 , evt); +sun4i_clkevt_time_setup (0 , evt -TIMER_SYNC_TICKS );sun4i_clkevt_time_start (0 , false);return 0 ;
@@ -131,7 +133,7 @@ static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id)static struct irqaction sun4i_timer_irq = { .name ="sun4i_timer0" , - .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_IRQPOLL , + .flags =IRQF_TIMER |IRQF_IRQPOLL , .handler = sun4i_timer_interrupt, .dev_id = &sun4i_clockevent, };
@@ -187,8 +189,8 @@ static void __init sun4i_timer_init(struct device_node *node) sun4i_clockevent.cpumask =cpumask_of (0 ); -clockevents_config_and_register (&sun4i_clockevent, rate,0x1 , -0xffffffff ); +clockevents_config_and_register (&sun4i_clockevent, rate, +TIMER_SYNC_TICKS ,0xffffffff ); }CLOCKSOURCE_OF_DECLARE (sun4i,"allwinner,sun4i-timer" , sun4i_timer_init);
drivers/clocksource/tcb_clksrc.c +50 -11
132 lines not on this page · raw message
drivers/clocksource/tegra20_timer.c +2 -6
@@ -98,7 +98,7 @@ static struct clock_event_device tegra_clockevent = { .set_mode = tegra_timer_set_mode, }; -static u32 notrace tegra_read_sched_clock(void) +static u64 notrace tegra_read_sched_clock(void) {return timer_readl (TIMERUS_CNTR_1US ); }
@@ -181,8 +181,6 @@ static void __init tegra20_init_timer(struct device_node *np) rate =clk_get_rate (clk); } -of_node_put (np); -switch (rate) {case 12000000 :timer_writel (0x000b ,TIMERUS_USEC_CFG );
@@ -200,7 +198,7 @@ static void __init tegra20_init_timer(struct device_node *np)WARN (1 ,"Unknown clock rate" ); } -setup_sched_clock (tegra_read_sched_clock,32 ,1000000 ); +sched_clock_register (tegra_read_sched_clock,32 ,1000000 );if (clocksource_mmio_init (timer_reg_base +TIMERUS_CNTR_1US ,"timer_us" ,1000000 ,300 ,32 , clocksource_mmio_readl_up)) {
@@ -241,8 +239,6 @@ static void __init tegra20_init_rtc(struct device_node *np)else clk_prepare_enable (clk); -of_node_put (np); -register_persistent_clock (NULL , tegra_read_persistent_clock); }CLOCKSOURCE_OF_DECLARE (tegra20_rtc,"nvidia,tegra20-rtc" , tegra20_init_rtc);
drivers/clocksource/time-armada-370-xp.c +2 -2
@@ -96,7 +96,7 @@ static void local_timer_ctrl_clrset(u32 clr, u32 set) local_base + TIMER_CTRL_OFF); } -static u32 notrace armada_370_xp_read_sched_clock(void) +static u64 notrace armada_370_xp_read_sched_clock(void) {return ~readl (timer_base +TIMER0_VAL_OFF ); }
@@ -258,7 +258,7 @@ static void __init armada_370_xp_timer_common_init(struct device_node *np)/* * Set scale and timer for sched_clock. */ -setup_sched_clock (armada_370_xp_read_sched_clock,32 , timer_clk); +sched_clock_register (armada_370_xp_read_sched_clock,32 , timer_clk);/* * Setup free-running clocksource timer (interrupts
drivers/clocksource/time-efm32.c new file +275 -0
275 lines not on this page · raw message
drivers/clocksource/timer-prima2.c +3 -3
@@ -165,9 +165,9 @@ static struct irqaction sirfsoc_timer_irq = { };/* Overwrite weak default sched_clock with more precise one */ -static u32 notrace sirfsoc_read_sched_clock(void) +static u64 notrace sirfsoc_read_sched_clock(void) { -return (u32)(sirfsoc_timer_read (NULL ) &0xffffffff ); +return sirfsoc_timer_read (NULL ); }static void __init sirfsoc_clockevent_init (void )
@@ -206,7 +206,7 @@ static void __init sirfsoc_prima2_timer_init(struct device_node *np)BUG_ON (clocksource_register_hz (&sirfsoc_clocksource,CLOCK_TICK_RATE )); -setup_sched_clock (sirfsoc_read_sched_clock,32 ,CLOCK_TICK_RATE ); +sched_clock_register (sirfsoc_read_sched_clock,64 ,CLOCK_TICK_RATE );BUG_ON (setup_irq (sirfsoc_timer_irq.irq, &sirfsoc_timer_irq));
drivers/clocksource/vf_pit_timer.c +2 -2
@@ -52,7 +52,7 @@ static inline void pit_irq_acknowledge(void)__raw_writel (PITTFLG_TIF , clkevt_base +PITTFLG ); } -static unsigned int pit_read_sched_clock (void ) +static u64 pit_read_sched_clock (void ) {return __raw_readl (clksrc_base +PITCVAL ); }
@@ -64,7 +64,7 @@ static int __init pit_clocksource_init(unsigned long rate)__raw_writel (~0UL , clksrc_base +PITLDVAL );__raw_writel (PITTCTRL_TEN , clksrc_base +PITTCTRL ); -setup_sched_clock (pit_read_sched_clock,32 , rate); +sched_clock_register (pit_read_sched_clock,32 , rate);return clocksource_mmio_init (clksrc_base +PITCVAL ,"vf-pit" , rate,300 ,32 , clocksource_mmio_readl_down); }
drivers/clocksource/vt8500_timer.c +0 -2
@@ -137,14 +137,12 @@ static void __init vt8500_timer_init(struct device_node *np)if (!regbase) {pr_err ("%s: Missing iobase description in Device Tree\n" , __func__); -of_node_put (np);return ; } timer_irq =irq_of_parse_and_map (np,0 );if (!timer_irq) {pr_err ("%s: Missing irq description in Device Tree\n" , __func__); -of_node_put (np);return ; }
drivers/rtc/interface.c +9 -4
@@ -72,6 +72,7 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) }else err = -EINVAL ; +pm_stay_awake (rtc->dev.parent);mutex_unlock (&rtc->ops_lock);/* A timer might have just expired */ schedule_work (&rtc->irqwork);
@@ -113,6 +114,7 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) err = -EINVAL ; } +pm_stay_awake (rtc->dev.parent);mutex_unlock (&rtc->ops_lock);/* A timer might have just expired */ schedule_work (&rtc->irqwork);
@@ -771,9 +773,10 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) alarm.time =rtc_ktime_to_tm (timer->node.expires); alarm.enabled =1 ; err =__rtc_set_alarm (rtc, &alarm); -if (err == -ETIME ) +if (err == -ETIME ) { +pm_stay_awake (rtc->dev.parent);schedule_work (&rtc->irqwork); -else if (err) { + }else if (err) {timerqueue_del (&rtc->timerqueue, &timer->node); timer->enabled =0 ;return err;
@@ -818,8 +821,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) alarm.time =rtc_ktime_to_tm (next->expires); alarm.enabled =1 ; err =__rtc_set_alarm (rtc, &alarm); -if (err == -ETIME ) +if (err == -ETIME ) { +pm_stay_awake (rtc->dev.parent);schedule_work (&rtc->irqwork); + } } }
@@ -845,7 +850,6 @@ void rtc_timer_do_work(struct work_struct *work)mutex_lock (&rtc->ops_lock); again: -pm_relax (rtc->dev.parent);__rtc_read_time (rtc, &tm); now =rtc_tm_to_ktime (tm);while ((next =timerqueue_getnext (&rtc->timerqueue))) {
@@ -880,6 +884,7 @@ again: }else rtc_alarm_disable (rtc); +pm_relax (rtc->dev.parent);mutex_unlock (&rtc->ops_lock); }
drivers/rtc/rtc-pl031.c +1 -2
@@ -371,6 +371,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) } } +device_init_wakeup (&adev->dev,1 ); ldata->rtc =rtc_device_register ("pl031" , &adev->dev, ops,THIS_MODULE );if (IS_ERR (ldata->rtc)) {
@@ -384,8 +385,6 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) goto out_no_irq; } -device_init_wakeup (&adev->dev,1 ); -return 0 ; out_no_irq:
include/clocksource/arm_arch_timer.h +10 -0
@@ -33,6 +33,16 @@ enum arch_timer_reg {#define ARCH_TIMER_MEM_PHYS_ACCESS 2#define ARCH_TIMER_MEM_VIRT_ACCESS 3 +#define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0)/* physical counter */ +#define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1)/* virtual counter */ +#define ARCH_TIMER_VIRT_EVT_EN (1 << 2) +#define ARCH_TIMER_EVT_TRIGGER_SHIFT (4) +#define ARCH_TIMER_EVT_TRIGGER_MASK (0xF << ARCH_TIMER_EVT_TRIGGER_SHIFT) +#define ARCH_TIMER_USR_VT_ACCESS_EN (1 << 8)/* virtual timer registers */ +#define ARCH_TIMER_USR_PT_ACCESS_EN (1 << 9)/* physical timer registers */ + +#define ARCH_TIMER_EVT_STREAM_FREQ 10000/* 100us */ +#ifdef CONFIG_ARM_ARCH_TIMER extern u32 arch_timer_get_rate (void );
include/linux/clockchips.h +1 -0
@@ -60,6 +60,7 @@ enum clock_event_mode {* Core shall set the interrupt affinity dynamically in broadcast mode */ #define CLOCK_EVT_FEAT_DYNIRQ 0x000020 +#define CLOCK_EVT_FEAT_PERCPU 0x000040/** * struct clock_event_device - clock event device descriptor
include/linux/clocksource.h +2 -0
@@ -292,6 +292,8 @@ extern void clocksource_resume(void);extern struct clocksource *__init __weak clocksource_default_clock (void );extern void clocksource_mark_unstable (struct clocksource *cs); +extern u64 +clocks_calc_max_nsecs (u32 mult,u32 shift,u32 maxadj,u64 mask);extern void clocks_calc_mult_shift (u32 *mult,u32 *shift,u32 from,u32 to,u32 minsec);
include/linux/sched_clock.h +2 -2
@@ -15,7 +15,7 @@ static inline void sched_clock_postinit(void) { }#endif extern void setup_sched_clock (u32 (*read)(void ),int bits,unsigned long rate); - -extern unsigned long long (*sched_clock_func)(void ); +extern void sched_clock_register (u64 (*read)(void ),int bits, +unsigned long rate);#endif
init/Kconfig +2 -1
@@ -354,7 +354,8 @@ config VIRT_CPU_ACCOUNTING_NATIVE config VIRT_CPU_ACCOUNTING_GEN bool "Full dynticks CPU time accounting" - depends on HAVE_CONTEXT_TRACKING && 64BIT + depends on HAVE_CONTEXT_TRACKING + depends on HAVE_VIRT_CPU_ACCOUNTING_GEN select VIRT_CPU_ACCOUNTING select CONTEXT_TRACKING help
kernel/time/Kconfig +1 -1
@@ -100,7 +100,7 @@ config NO_HZ_FULL # RCU_USER_QS dependency depends on HAVE_CONTEXT_TRACKING # VIRT_CPU_ACCOUNTING_GEN dependency - depends on 64BIT + depends on HAVE_VIRT_CPU_ACCOUNTING_GEN select NO_HZ_COMMON select RCU_USER_QS select RCU_NOCB_CPU
kernel/time/alarmtimer.c +2 -2
@@ -490,7 +490,7 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)clockid_t baseid = alarm_bases[clock2alarm (which_clock)].base_clockid;if (!alarmtimer_get_rtcdev ()) -return -ENOTSUPP ; +return -EINVAL ;return hrtimer_get_res (baseid, tp); }
@@ -507,7 +507,7 @@ static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)struct alarm_base *base = &alarm_bases[clock2alarm (which_clock)];if (!alarmtimer_get_rtcdev ()) -return -ENOTSUPP ; +return -EINVAL ; *tp =ktime_to_timespec (base->gettime ());return 0 ;
kernel/time/clockevents.c +1 -1
@@ -584,7 +584,7 @@ static ssize_t sysfs_unbind_tick_dev(struct device *dev, const char *buf, size_t count) { char name[CS_NAME_LEN]; -size_t ret =sysfs_get_uname (buf, name, count); +ssize_t ret =sysfs_get_uname (buf, name, count);struct clock_event_device *ce;if (ret <0 )
kernel/time/clocksource.c +34 -18
101 lines not on this page · raw message
kernel/time/ntp.c +2 -1
@@ -475,6 +475,7 @@ static void sync_cmos_clock(struct work_struct *work)* called as close as possible to 500 ms before the new second starts. * This code is run on a timer. If the clock is set, that timer * may not expire at the correct time. Thus, we adjust... +* We want the clock to be within a couple of ticks from the target. */ if (!ntp_synced ()) {/*
@@ -485,7 +486,7 @@ static void sync_cmos_clock(struct work_struct *work) }getnstimeofday (&now); -if (abs (now.tv_nsec - (NSEC_PER_SEC /2 )) <= tick_nsec /2 ) { +if (abs (now.tv_nsec - (NSEC_PER_SEC /2 )) <= tick_nsec *5 ) {struct timespec adjust = now; fail = -ENODEV ;
kernel/time/sched_clock.c +59 -55
227 lines not on this page · raw message
kernel/time/tick-broadcast.c +1 -0
@@ -70,6 +70,7 @@ static bool tick_check_broadcast_device(struct clock_event_device *curdev, struct clock_event_device *newdev) {if ((newdev->features &CLOCK_EVT_FEAT_DUMMY ) || + (newdev->features &CLOCK_EVT_FEAT_PERCPU ) || (newdev->features &CLOCK_EVT_FEAT_C3STOP ))return false;
kernel/time/tick-internal.h +1 -1
@@ -31,7 +31,7 @@ extern void tick_install_replacement(struct clock_event_device *dev);extern void clockevents_shutdown (struct clock_event_device *dev); -extern size_t sysfs_get_uname (const char *buf,char *dst,size_t cnt); +extern ssize_t sysfs_get_uname (const char *buf,char *dst,size_t cnt);/* * NO_HZ / high resolution timer shared code
kernel/time/timekeeping.c +2 -1
@@ -1613,9 +1613,10 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,* ktime_get_update_offsets - hrtimer helper * @offs_real: pointer to storage for monotonic -> realtime offset * @offs_boot: pointer to storage for monotonic -> boottime offset +* @offs_tai: pointer to storage for monotonic -> clock tai offset * * Returns current monotonic time and updates the offsets -* Called from hrtimer_interupt() or retrigger_next_event() +* Called from hrtimer_interrupt() or retrigger_next_event() */ ktime_t ktime_get_update_offsets (ktime_t *offs_real,ktime_t *offs_boot,ktime_t *offs_tai)
kernel/time/timer_stats.c +4 -4
@@ -298,15 +298,15 @@ static int tstats_show(struct seq_file *m, void *v) period =ktime_to_timespec (time); ms = period.tv_nsec /1000000 ; -seq_puts (m,"Timer Stats Version: v0.2\n" ); +seq_puts (m,"Timer Stats Version: v0.3\n" );seq_printf (m,"Sample period: %ld.%03ld s\n" , period.tv_sec, ms);if (atomic_read (&overflow_count)) -seq_printf (m,"Overflow: %d entries\n" , -atomic_read (&overflow_count)); +seq_printf (m,"Overflow: %d entries\n" ,atomic_read (&overflow_count)); +seq_printf (m,"Collection: %s\n" , timer_stats_active ?"active" :"inactive" );for (i =0 ; i < nr_entries; i++) { entry = entries + i; -if (entry->timer_flag &TIMER_STATS_FLAG_DEFERRABLE ) { +if (entry->timer_flag &TIMER_STATS_FLAG_DEFERRABLE ) {seq_printf (m,"%4luD, %5d %-16s " , entry->count, entry->pid, entry->comm); }else {