Skip to content

Commit a8da61c

Browse files
committed
Merge tag 'timers-v5.16-rc1' into timers/core
Pull timers update for v5.16 from Daniel Lezcano: - Fix redefined macro in the arc timer () - Big cleanup for ARM arch timer clocksource in order to set the scene for ARMv8.6 and provide support for higher frequencies with longer roll up (Marc Zyngier) - Make arch dependant the Exynos MCT and Samsung PWM timers (Krzysztof Kozlowski) - Select the TIMER_OF option for the timer TI DM (Kees Cook) Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Borislav Petkov <[email protected]>
2 parents d25a025 + eda9a4f commit a8da61c

File tree

7 files changed

+201
-146
lines changed

7 files changed

+201
-146
lines changed

arch/arm/include/asm/arch_timer.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <asm/hwcap.h>
88
#include <linux/clocksource.h>
99
#include <linux/init.h>
10+
#include <linux/io-64-nonatomic-lo-hi.h>
1011
#include <linux/types.h>
1112

1213
#include <clocksource/arm_arch_timer.h>
@@ -24,29 +25,35 @@ int arch_timer_arch_init(void);
2425
* the code. At least it does so with a recent GCC (4.6.3).
2526
*/
2627
static __always_inline
27-
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val)
28+
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u64 val)
2829
{
2930
if (access == ARCH_TIMER_PHYS_ACCESS) {
3031
switch (reg) {
3132
case ARCH_TIMER_REG_CTRL:
32-
asm volatile("mcr p15, 0, %0, c14, c2, 1" : : "r" (val));
33+
asm volatile("mcr p15, 0, %0, c14, c2, 1" : : "r" ((u32)val));
34+
isb();
3335
break;
34-
case ARCH_TIMER_REG_TVAL:
35-
asm volatile("mcr p15, 0, %0, c14, c2, 0" : : "r" (val));
36+
case ARCH_TIMER_REG_CVAL:
37+
asm volatile("mcrr p15, 2, %Q0, %R0, c14" : : "r" (val));
3638
break;
39+
default:
40+
BUILD_BUG();
3741
}
3842
} else if (access == ARCH_TIMER_VIRT_ACCESS) {
3943
switch (reg) {
4044
case ARCH_TIMER_REG_CTRL:
41-
asm volatile("mcr p15, 0, %0, c14, c3, 1" : : "r" (val));
45+
asm volatile("mcr p15, 0, %0, c14, c3, 1" : : "r" ((u32)val));
46+
isb();
4247
break;
43-
case ARCH_TIMER_REG_TVAL:
44-
asm volatile("mcr p15, 0, %0, c14, c3, 0" : : "r" (val));
48+
case ARCH_TIMER_REG_CVAL:
49+
asm volatile("mcrr p15, 3, %Q0, %R0, c14" : : "r" (val));
4550
break;
51+
default:
52+
BUILD_BUG();
4653
}
54+
} else {
55+
BUILD_BUG();
4756
}
48-
49-
isb();
5057
}
5158

5259
static __always_inline
@@ -59,19 +66,19 @@ u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
5966
case ARCH_TIMER_REG_CTRL:
6067
asm volatile("mrc p15, 0, %0, c14, c2, 1" : "=r" (val));
6168
break;
62-
case ARCH_TIMER_REG_TVAL:
63-
asm volatile("mrc p15, 0, %0, c14, c2, 0" : "=r" (val));
64-
break;
69+
default:
70+
BUILD_BUG();
6571
}
6672
} else if (access == ARCH_TIMER_VIRT_ACCESS) {
6773
switch (reg) {
6874
case ARCH_TIMER_REG_CTRL:
6975
asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r" (val));
7076
break;
71-
case ARCH_TIMER_REG_TVAL:
72-
asm volatile("mrc p15, 0, %0, c14, c3, 0" : "=r" (val));
73-
break;
77+
default:
78+
BUILD_BUG();
7479
}
80+
} else {
81+
BUILD_BUG();
7582
}
7683

7784
return val;

arch/arm64/include/asm/arch_timer.h

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
({ \
3333
const struct arch_timer_erratum_workaround *__wa; \
3434
__wa = __this_cpu_read(timer_unstable_counter_workaround); \
35-
(__wa && __wa->h) ? __wa->h : arch_timer_##h; \
35+
(__wa && __wa->h) ? ({ isb(); __wa->h;}) : arch_timer_##h; \
3636
})
3737

3838
#else
@@ -52,8 +52,6 @@ struct arch_timer_erratum_workaround {
5252
enum arch_timer_erratum_match_type match_type;
5353
const void *id;
5454
const char *desc;
55-
u32 (*read_cntp_tval_el0)(void);
56-
u32 (*read_cntv_tval_el0)(void);
5755
u64 (*read_cntpct_el0)(void);
5856
u64 (*read_cntvct_el0)(void);
5957
int (*set_next_event_phys)(unsigned long, struct clock_event_device *);
@@ -64,24 +62,15 @@ struct arch_timer_erratum_workaround {
6462
DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
6563
timer_unstable_counter_workaround);
6664

67-
/* inline sysreg accessors that make erratum_handler() work */
68-
static inline notrace u32 arch_timer_read_cntp_tval_el0(void)
69-
{
70-
return read_sysreg(cntp_tval_el0);
71-
}
72-
73-
static inline notrace u32 arch_timer_read_cntv_tval_el0(void)
74-
{
75-
return read_sysreg(cntv_tval_el0);
76-
}
77-
7865
static inline notrace u64 arch_timer_read_cntpct_el0(void)
7966
{
67+
isb();
8068
return read_sysreg(cntpct_el0);
8169
}
8270

8371
static inline notrace u64 arch_timer_read_cntvct_el0(void)
8472
{
73+
isb();
8574
return read_sysreg(cntvct_el0);
8675
}
8776

@@ -102,51 +91,58 @@ static inline notrace u64 arch_timer_read_cntvct_el0(void)
10291
* the code.
10392
*/
10493
static __always_inline
105-
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val)
94+
void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u64 val)
10695
{
10796
if (access == ARCH_TIMER_PHYS_ACCESS) {
10897
switch (reg) {
10998
case ARCH_TIMER_REG_CTRL:
11099
write_sysreg(val, cntp_ctl_el0);
100+
isb();
111101
break;
112-
case ARCH_TIMER_REG_TVAL:
113-
write_sysreg(val, cntp_tval_el0);
102+
case ARCH_TIMER_REG_CVAL:
103+
write_sysreg(val, cntp_cval_el0);
114104
break;
105+
default:
106+
BUILD_BUG();
115107
}
116108
} else if (access == ARCH_TIMER_VIRT_ACCESS) {
117109
switch (reg) {
118110
case ARCH_TIMER_REG_CTRL:
119111
write_sysreg(val, cntv_ctl_el0);
112+
isb();
120113
break;
121-
case ARCH_TIMER_REG_TVAL:
122-
write_sysreg(val, cntv_tval_el0);
114+
case ARCH_TIMER_REG_CVAL:
115+
write_sysreg(val, cntv_cval_el0);
123116
break;
117+
default:
118+
BUILD_BUG();
124119
}
120+
} else {
121+
BUILD_BUG();
125122
}
126-
127-
isb();
128123
}
129124

130125
static __always_inline
131-
u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
126+
u64 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)
132127
{
133128
if (access == ARCH_TIMER_PHYS_ACCESS) {
134129
switch (reg) {
135130
case ARCH_TIMER_REG_CTRL:
136131
return read_sysreg(cntp_ctl_el0);
137-
case ARCH_TIMER_REG_TVAL:
138-
return arch_timer_reg_read_stable(cntp_tval_el0);
132+
default:
133+
BUILD_BUG();
139134
}
140135
} else if (access == ARCH_TIMER_VIRT_ACCESS) {
141136
switch (reg) {
142137
case ARCH_TIMER_REG_CTRL:
143138
return read_sysreg(cntv_ctl_el0);
144-
case ARCH_TIMER_REG_TVAL:
145-
return arch_timer_reg_read_stable(cntv_tval_el0);
139+
default:
140+
BUILD_BUG();
146141
}
147142
}
148143

149-
BUG();
144+
BUILD_BUG();
145+
unreachable();
150146
}
151147

152148
static inline u32 arch_timer_get_cntfrq(void)
@@ -169,7 +165,6 @@ static __always_inline u64 __arch_counter_get_cntpct_stable(void)
169165
{
170166
u64 cnt;
171167

172-
isb();
173168
cnt = arch_timer_reg_read_stable(cntpct_el0);
174169
arch_counter_enforce_ordering(cnt);
175170
return cnt;
@@ -189,7 +184,6 @@ static __always_inline u64 __arch_counter_get_cntvct_stable(void)
189184
{
190185
u64 cnt;
191186

192-
isb();
193187
cnt = arch_timer_reg_read_stable(cntvct_el0);
194188
arch_counter_enforce_ordering(cnt);
195189
return cnt;

drivers/clocksource/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config I8253_LOCK
2424

2525
config OMAP_DM_TIMER
2626
bool
27+
select TIMER_OF
2728

2829
config CLKBLD_I8253
2930
def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK
@@ -417,12 +418,14 @@ config ATMEL_TCB_CLKSRC
417418
config CLKSRC_EXYNOS_MCT
418419
bool "Exynos multi core timer driver" if COMPILE_TEST
419420
depends on ARM || ARM64
421+
depends on ARCH_EXYNOS || COMPILE_TEST
420422
help
421423
Support for Multi Core Timer controller on Exynos SoCs.
422424

423425
config CLKSRC_SAMSUNG_PWM
424426
bool "PWM timer driver for Samsung S3C, S5P" if COMPILE_TEST
425427
depends on HAS_IOMEM
428+
depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 || COMPILE_TEST
426429
help
427430
This is a new clocksource driver for the PWM timer found in
428431
Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver

drivers/clocksource/arc_timer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static int __init arc_cs_setup_timer1(struct device_node *node)
225225

226226
write_aux_reg(ARC_REG_TIMER1_LIMIT, ARC_TIMERN_MAX);
227227
write_aux_reg(ARC_REG_TIMER1_CNT, 0);
228-
write_aux_reg(ARC_REG_TIMER1_CTRL, TIMER_CTRL_NH);
228+
write_aux_reg(ARC_REG_TIMER1_CTRL, ARC_TIMER_CTRL_NH);
229229

230230
sched_clock_register(arc_timer1_clock_read, 32, arc_timer_freq);
231231

@@ -245,7 +245,7 @@ static void arc_timer_event_setup(unsigned int cycles)
245245
write_aux_reg(ARC_REG_TIMER0_LIMIT, cycles);
246246
write_aux_reg(ARC_REG_TIMER0_CNT, 0); /* start from 0 */
247247

248-
write_aux_reg(ARC_REG_TIMER0_CTRL, TIMER_CTRL_IE | TIMER_CTRL_NH);
248+
write_aux_reg(ARC_REG_TIMER0_CTRL, ARC_TIMER_CTRL_IE | ARC_TIMER_CTRL_NH);
249249
}
250250

251251

@@ -294,7 +294,7 @@ static irqreturn_t timer_irq_handler(int irq, void *dev_id)
294294
* explicitly clears IP bit
295295
* 2. Re-arm interrupt if periodic by writing to IE bit [0]
296296
*/
297-
write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | TIMER_CTRL_NH);
297+
write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | ARC_TIMER_CTRL_NH);
298298

299299
evt->event_handler(evt);
300300

0 commit comments

Comments
 (0)