diff options
| -rw-r--r-- | arch/arm64/include/asm/arch_timer.h | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index c3762ffcc933..4a06d46def7e 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h | |||
| @@ -77,23 +77,37 @@ struct arch_timer_erratum_workaround { | |||
| 77 | DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *, | 77 | DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *, |
| 78 | timer_unstable_counter_workaround); | 78 | timer_unstable_counter_workaround); |
| 79 | 79 | ||
| 80 | /* inline sysreg accessors that make erratum_handler() work */ | ||
| 81 | static inline notrace u32 arch_timer_read_cntp_tval_el0(void) | ||
| 82 | { | ||
| 83 | return read_sysreg(cntp_tval_el0); | ||
| 84 | } | ||
| 85 | |||
| 86 | static inline notrace u32 arch_timer_read_cntv_tval_el0(void) | ||
| 87 | { | ||
| 88 | return read_sysreg(cntv_tval_el0); | ||
| 89 | } | ||
| 90 | |||
| 91 | static inline notrace u64 arch_timer_read_cntpct_el0(void) | ||
| 92 | { | ||
| 93 | return read_sysreg(cntpct_el0); | ||
| 94 | } | ||
| 95 | |||
| 96 | static inline notrace u64 arch_timer_read_cntvct_el0(void) | ||
| 97 | { | ||
| 98 | return read_sysreg(cntvct_el0); | ||
| 99 | } | ||
| 100 | |||
| 80 | #define arch_timer_reg_read_stable(reg) \ | 101 | #define arch_timer_reg_read_stable(reg) \ |
| 81 | ({ \ | 102 | ({ \ |
| 82 | u64 _val; \ | 103 | u64 _val; \ |
| 83 | if (needs_unstable_timer_counter_workaround()) { \ | 104 | \ |
| 84 | const struct arch_timer_erratum_workaround *wa; \ | ||
| 85 | preempt_disable_notrace(); \ | 105 | preempt_disable_notrace(); \ |
| 86 | wa = __this_cpu_read(timer_unstable_counter_workaround); \ | 106 | _val = erratum_handler(read_ ## reg)(); \ |
| 87 | if (wa && wa->read_##reg) \ | ||
| 88 | _val = wa->read_##reg(); \ | ||
| 89 | else \ | ||
| 90 | _val = read_sysreg(reg); \ | ||
| 91 | preempt_enable_notrace(); \ | 107 | preempt_enable_notrace(); \ |
| 92 | } else { \ | 108 | \ |
| 93 | _val = read_sysreg(reg); \ | 109 | _val; \ |
| 94 | } \ | 110 | }) |
| 95 | _val; \ | ||
| 96 | }) | ||
| 97 | 111 | ||
| 98 | /* | 112 | /* |
| 99 | * These register accessors are marked inline so the compiler can | 113 | * These register accessors are marked inline so the compiler can |
