Skip to content

Commit 8709382

Browse files
committed
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer changes from Ingo Molnar: "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" * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (50 commits) x86/time: Honor ACPI FADT flag indicating absence of a CMOS RTC clocksource: sun4i: remove IRQF_DISABLED clocksource: sun4i: Report the minimum tick that we can program clocksource: sun4i: Select CLKSRC_MMIO clocksource: Provide timekeeping for efm32 SoCs clocksource: em_sti: convert to clk_prepare/unprepare time: Fix signedness bug in sysfs_get_uname() and its callers timekeeping: Fix some trivial typos in comments alarmtimer: return EINVAL instead of ENOTSUPP if rtcdev doesn't exist clocksource: arch_timer: Do not register arch_sys_counter twice timer stats: Add a 'Collection: active/inactive' line to timer usage statistics sched_clock: Remove sched_clock_func() hook arch_timer: Move to generic sched_clock framework clocksource: tcb_clksrc: Remove IRQF_DISABLED clocksource: tcb_clksrc: Improve driver robustness clocksource: tcb_clksrc: Replace clk_enable/disable with clk_prepare_enable/disable_unprepare clocksource: arm_arch_timer: Use clocksource for suspend timekeeping clocksource: dw_apb_timer_of: Mark a few more functions as __init clocksource: Put nodes passed to CLOCKSOURCE_OF_DECLARE callbacks centrally arm: zynq: Enable arm_global_timer ...
2 parents 39cf275 + ee5872b commit 8709382

54 files changed

Lines changed: 717 additions & 189 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
* EFM32 timer hardware
2+
3+
The efm32 Giant Gecko SoCs come with four 16 bit timers. Two counters can be
4+
connected to form a 32 bit counter. Each timer has three Compare/Capture
5+
channels and can be used as PWM or Quadrature Decoder. Available clock sources
6+
are the cpu's HFPERCLK (with a 10-bit prescaler) or an external pin.
7+
8+
Required properties:
9+
- compatible : Should be efm32,timer
10+
- reg : Address and length of the register set
11+
- clocks : Should contain a reference to the HFPERCLK
12+
13+
Optional properties:
14+
- interrupts : Reference to the timer interrupt
15+
16+
Example:
17+
18+
timer@40010c00 {
19+
compatible = "efm32,timer";
20+
reg = <0x40010c00 0x400>;
21+
interrupts = <14>;
22+
clocks = <&cmu clk_HFPERCLKTIMER3>;
23+
};

arch/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,18 @@ config HAVE_CONTEXT_TRACKING
353353
config HAVE_VIRT_CPU_ACCOUNTING
354354
bool
355355

356+
config HAVE_VIRT_CPU_ACCOUNTING_GEN
357+
bool
358+
default y if 64BIT
359+
help
360+
With VIRT_CPU_ACCOUNTING_GEN, cputime_t becomes 64-bit.
361+
Before enabling this option, arch code must be audited
362+
to ensure there are no races in concurrent read/write of
363+
cputime_t. For example, reading/writing 64-bit cputime_t on
364+
some 32-bit arches may require multiple accesses, so proper
365+
locking is needed to protect against concurrent accesses.
366+
367+
356368
config HAVE_IRQ_TIME_ACCOUNTING
357369
bool
358370
help

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ config ARM
5454
select HAVE_REGS_AND_STACK_ACCESS_API
5555
select HAVE_SYSCALL_TRACEPOINTS
5656
select HAVE_UID16
57+
select HAVE_VIRT_CPU_ACCOUNTING_GEN
5758
select IRQ_FORCED_THREADING
5859
select KTIME_SCALAR
5960
select MODULES_USE_ELF_REL

arch/arm/boot/dts/zynq-7000.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@
9292
};
9393
};
9494

95+
global_timer: timer@f8f00200 {
96+
compatible = "arm,cortex-a9-global-timer";
97+
reg = <0xf8f00200 0x20>;
98+
interrupts = <1 11 0x301>;
99+
interrupt-parent = <&intc>;
100+
clocks = <&clkc 4>;
101+
};
102+
95103
ttc0: ttc0@f8001000 {
96104
interrupt-parent = <&intc>;
97105
interrupts = < 0 10 4 0 11 4 0 12 4 >;

arch/arm/include/asm/arch_timer.h

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,43 @@ static inline u64 arch_counter_get_cntvct(void)
8787
return cval;
8888
}
8989

90-
static inline void arch_counter_set_user_access(void)
90+
static inline u32 arch_timer_get_cntkctl(void)
9191
{
9292
u32 cntkctl;
93-
9493
asm volatile("mrc p15, 0, %0, c14, c1, 0" : "=r" (cntkctl));
94+
return cntkctl;
95+
}
9596

96-
/* disable user access to everything */
97-
cntkctl &= ~((3 << 8) | (7 << 0));
98-
97+
static inline void arch_timer_set_cntkctl(u32 cntkctl)
98+
{
9999
asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
100100
}
101+
102+
static inline void arch_counter_set_user_access(void)
103+
{
104+
u32 cntkctl = arch_timer_get_cntkctl();
105+
106+
/* Disable user access to both physical/virtual counters/timers */
107+
/* Also disable virtual event stream */
108+
cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
109+
| ARCH_TIMER_USR_VT_ACCESS_EN
110+
| ARCH_TIMER_VIRT_EVT_EN
111+
| ARCH_TIMER_USR_VCT_ACCESS_EN
112+
| ARCH_TIMER_USR_PCT_ACCESS_EN);
113+
arch_timer_set_cntkctl(cntkctl);
114+
}
115+
116+
static inline void arch_timer_evtstrm_enable(int divider)
117+
{
118+
u32 cntkctl = arch_timer_get_cntkctl();
119+
cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
120+
/* Set the divider and enable virtual event stream */
121+
cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
122+
| ARCH_TIMER_VIRT_EVT_EN;
123+
arch_timer_set_cntkctl(cntkctl);
124+
elf_hwcap |= HWCAP_EVTSTRM;
125+
}
126+
101127
#endif
102128

103129
#endif

arch/arm/include/uapi/asm/hwcap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
#define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */
2727
#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
2828
#define HWCAP_LPAE (1 << 20)
29+
#define HWCAP_EVTSTRM (1 << 21)
2930

3031
#endif /* _UAPI__ASMARM_HWCAP_H */

arch/arm/kernel/arch_timer.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/init.h>
1212
#include <linux/types.h>
1313
#include <linux/errno.h>
14-
#include <linux/sched_clock.h>
1514

1615
#include <asm/delay.h>
1716

@@ -22,13 +21,6 @@ static unsigned long arch_timer_read_counter_long(void)
2221
return arch_timer_read_counter();
2322
}
2423

25-
static u32 sched_clock_mult __read_mostly;
26-
27-
static unsigned long long notrace arch_timer_sched_clock(void)
28-
{
29-
return arch_timer_read_counter() * sched_clock_mult;
30-
}
31-
3224
static struct delay_timer arch_delay_timer;
3325

3426
static void __init arch_timer_delay_timer_register(void)
@@ -48,11 +40,5 @@ int __init arch_timer_arch_init(void)
4840

4941
arch_timer_delay_timer_register();
5042

51-
/* Cache the sched_clock multiplier to save a divide in the hot path. */
52-
sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
53-
sched_clock_func = arch_timer_sched_clock;
54-
pr_info("sched_clock: ARM arch timer >56 bits at %ukHz, resolution %uns\n",
55-
arch_timer_rate / 1000, sched_clock_mult);
56-
5743
return 0;
5844
}

arch/arm/kernel/setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ static const char *hwcap_str[] = {
975975
"idivt",
976976
"vfpd32",
977977
"lpae",
978+
"evtstrm",
978979
NULL
979980
};
980981

arch/arm/mach-msm/timer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ static void __init msm_dt_timer_init(struct device_node *np)
274274
pr_err("Unknown frequency\n");
275275
return;
276276
}
277-
of_node_put(np);
278277

279278
event_base = base + 0x4;
280279
sts_base = base + 0x88;

arch/arm/mach-zynq/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ config ARCH_ZYNQ
1313
select HAVE_SMP
1414
select SPARSE_IRQ
1515
select CADENCE_TTC_TIMER
16+
select ARM_GLOBAL_TIMER
1617
help
1718
Support for Xilinx Zynq ARM Cortex A9 Platform

0 commit comments

Comments
 (0)