aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/arm_arch_timer.c
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2017-01-27 05:27:09 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2017-04-07 06:22:09 -0400
commit01d3e3ff26080040cb02ec4989a0da36d069f1e9 (patch)
tree0a4601c57b7fd7557ec320ba7bb77de14b87a1dc /drivers/clocksource/arm_arch_timer.c
parent8328089f0aeba39173eee3fc109b5c77efd64747 (diff)
arm64: arch_timer: Rework the set_next_event workarounds
The way we work around errata affecting set_next_event is not very nice, at it imposes this workaround on errata that do not need it. Add new workaround hooks and let the existing workarounds use them. Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'drivers/clocksource/arm_arch_timer.c')
-rw-r--r--drivers/clocksource/arm_arch_timer.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 2c02e25d1475..a0c9ee80147e 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -282,6 +282,8 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
282 .read_cntp_tval_el0 = fsl_a008585_read_cntp_tval_el0, 282 .read_cntp_tval_el0 = fsl_a008585_read_cntp_tval_el0,
283 .read_cntv_tval_el0 = fsl_a008585_read_cntv_tval_el0, 283 .read_cntv_tval_el0 = fsl_a008585_read_cntv_tval_el0,
284 .read_cntvct_el0 = fsl_a008585_read_cntvct_el0, 284 .read_cntvct_el0 = fsl_a008585_read_cntvct_el0,
285 .set_next_event_phys = erratum_set_next_event_tval_phys,
286 .set_next_event_virt = erratum_set_next_event_tval_virt,
285 }, 287 },
286#endif 288#endif
287#ifdef CONFIG_HISILICON_ERRATUM_161010101 289#ifdef CONFIG_HISILICON_ERRATUM_161010101
@@ -292,6 +294,8 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
292 .read_cntp_tval_el0 = hisi_161010101_read_cntp_tval_el0, 294 .read_cntp_tval_el0 = hisi_161010101_read_cntp_tval_el0,
293 .read_cntv_tval_el0 = hisi_161010101_read_cntv_tval_el0, 295 .read_cntv_tval_el0 = hisi_161010101_read_cntv_tval_el0,
294 .read_cntvct_el0 = hisi_161010101_read_cntvct_el0, 296 .read_cntvct_el0 = hisi_161010101_read_cntvct_el0,
297 .set_next_event_phys = erratum_set_next_event_tval_phys,
298 .set_next_event_virt = erratum_set_next_event_tval_virt,
295 }, 299 },
296#endif 300#endif
297}; 301};
@@ -377,11 +381,24 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_type t
377 local ? "local" : "global", wa->desc); 381 local ? "local" : "global", wa->desc);
378} 382}
379 383
384#define erratum_handler(fn, r, ...) \
385({ \
386 bool __val; \
387 if (needs_unstable_timer_counter_workaround() && \
388 timer_unstable_counter_workaround->fn) { \
389 r = timer_unstable_counter_workaround->fn(__VA_ARGS__); \
390 __val = true; \
391 } else { \
392 __val = false; \
393 } \
394 __val; \
395})
396
380#else 397#else
381#define arch_timer_check_ool_workaround(t,a) do { } while(0) 398#define arch_timer_check_ool_workaround(t,a) do { } while(0)
382#define erratum_set_next_event_tval_virt(...) ({BUG(); 0;}) 399#define erratum_set_next_event_tval_virt(...) ({BUG(); 0;})
383#define erratum_set_next_event_tval_phys(...) ({BUG(); 0;}) 400#define erratum_set_next_event_tval_phys(...) ({BUG(); 0;})
384#define needs_unstable_timer_counter_workaround() ({false;}) 401#define erratum_handler(fn, r, ...) ({false;})
385#endif /* CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND */ 402#endif /* CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND */
386 403
387static __always_inline irqreturn_t timer_handler(const int access, 404static __always_inline irqreturn_t timer_handler(const int access,
@@ -474,8 +491,10 @@ static __always_inline void set_next_event(const int access, unsigned long evt,
474static int arch_timer_set_next_event_virt(unsigned long evt, 491static int arch_timer_set_next_event_virt(unsigned long evt,
475 struct clock_event_device *clk) 492 struct clock_event_device *clk)
476{ 493{
477 if (needs_unstable_timer_counter_workaround()) 494 int ret;
478 return erratum_set_next_event_tval_virt(evt, clk); 495
496 if (erratum_handler(set_next_event_virt, ret, evt, clk))
497 return ret;
479 498
480 set_next_event(ARCH_TIMER_VIRT_ACCESS, evt, clk); 499 set_next_event(ARCH_TIMER_VIRT_ACCESS, evt, clk);
481 return 0; 500 return 0;
@@ -484,8 +503,10 @@ static int arch_timer_set_next_event_virt(unsigned long evt,
484static int arch_timer_set_next_event_phys(unsigned long evt, 503static int arch_timer_set_next_event_phys(unsigned long evt,
485 struct clock_event_device *clk) 504 struct clock_event_device *clk)
486{ 505{
487 if (needs_unstable_timer_counter_workaround()) 506 int ret;
488 return erratum_set_next_event_tval_phys(evt, clk); 507
508 if (erratum_handler(set_next_event_phys, ret, evt, clk))
509 return ret;
489 510
490 set_next_event(ARCH_TIMER_PHYS_ACCESS, evt, clk); 511 set_next_event(ARCH_TIMER_PHYS_ACCESS, evt, clk);
491 return 0; 512 return 0;