Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mips: vdso: Use generic VDSO clock mode storage

Switch to the generic VDSO clock mode storage.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lkml.kernel.org/r/20200207124403.244684017@linutronix.de



+19 -50
+1 -1
arch/mips/Kconfig
··· 4 4 default y 5 5 select ARCH_32BIT_OFF_T if !64BIT 6 6 select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT 7 - select ARCH_CLOCKSOURCE_DATA 8 7 select ARCH_HAS_FORTIFY_SOURCE 9 8 select ARCH_HAS_KCOV 10 9 select ARCH_HAS_PTE_SPECIAL if !(32BIT && CPU_HAS_RIXI) ··· 37 38 select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC 38 39 select GENERIC_SMP_IDLE_THREAD 39 40 select GENERIC_TIME_VSYSCALL 41 + select GENERIC_VDSO_CLOCK_MODE 40 42 select GUP_GET_PTE_LOW_HIGH if CPU_MIPS32 && PHYS_ADDR_T_64BIT 41 43 select HANDLE_DOMAIN_IRQ 42 44 select HAVE_ARCH_COMPILER_H
+3 -15
arch/mips/include/asm/clocksource.h
··· 3 3 * Copyright (C) 2015 Imagination Technologies 4 4 * Author: Alex Smith <alex.smith@imgtec.com> 5 5 */ 6 - 7 6 #ifndef __ASM_CLOCKSOURCE_H 8 7 #define __ASM_CLOCKSOURCE_H 9 8 10 - #include <linux/types.h> 11 - 12 - /* VDSO clocksources. */ 13 - #define VDSO_CLOCK_NONE 0 /* No suitable clocksource. */ 14 - #define VDSO_CLOCK_R4K 1 /* Use the coprocessor 0 count. */ 15 - #define VDSO_CLOCK_GIC 2 /* Use the GIC. */ 16 - 17 - /** 18 - * struct arch_clocksource_data - Architecture-specific clocksource information. 19 - * @vdso_clock_mode: Method the VDSO should use to access the clocksource. 20 - */ 21 - struct arch_clocksource_data { 22 - u8 vdso_clock_mode; 23 - }; 9 + #define VDSO_ARCH_CLOCKMODES \ 10 + VDSO_CLOCKMODE_R4K, \ 11 + VDSO_CLOCKMODE_GIC 24 12 25 13 #endif /* __ASM_CLOCKSOURCE_H */
+10 -20
arch/mips/include/asm/vdso/gettimeofday.h
··· 24 24 25 25 #define VDSO_HAS_CLOCK_GETRES 1 26 26 27 - #define __VDSO_USE_SYSCALL ULLONG_MAX 28 - 29 27 static __always_inline long gettimeofday_fallback( 30 28 struct __kernel_old_timeval *_tv, 31 29 struct timezone *_tz) ··· 173 175 174 176 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) 175 177 { 176 - #ifdef CONFIG_CLKSRC_MIPS_GIC 177 - const struct vdso_data *data = get_vdso_data(); 178 - #endif 179 - u64 cycle_now; 180 - 181 - switch (clock_mode) { 182 178 #ifdef CONFIG_CSRC_R4K 183 - case VDSO_CLOCK_R4K: 184 - cycle_now = read_r4k_count(); 185 - break; 179 + if (clock_mode == VDSO_CLOCKMODE_R4K) 180 + return read_r4k_count(); 186 181 #endif 187 182 #ifdef CONFIG_CLKSRC_MIPS_GIC 188 - case VDSO_CLOCK_GIC: 189 - cycle_now = read_gic_count(data); 190 - break; 183 + if (clock_mode == VDSO_CLOCKMODE_GIC) 184 + return read_gic_count(get_vdso_data()); 191 185 #endif 192 - default: 193 - cycle_now = __VDSO_USE_SYSCALL; 194 - break; 195 - } 196 - 197 - return cycle_now; 186 + /* 187 + * Core checks mode already. So this raced against a concurrent 188 + * update. Return something. Core will do another round see the 189 + * change and fallback to syscall. 190 + */ 191 + return 0; 198 192 } 199 193 200 194 static inline bool mips_vdso_hres_capable(void)
-9
arch/mips/include/asm/vdso/vsyscall.h
··· 19 19 } 20 20 #define __arch_get_k_vdso_data __mips_get_k_vdso_data 21 21 22 - static __always_inline 23 - int __mips_get_clock_mode(struct timekeeper *tk) 24 - { 25 - u32 clock_mode = tk->tkr_mono.clock->archdata.vdso_clock_mode; 26 - 27 - return clock_mode; 28 - } 29 - #define __arch_get_clock_mode __mips_get_clock_mode 30 - 31 22 /* The asm-generic header needs to be included after the definitions above */ 32 23 #include <asm-generic/vdso/vsyscall.h> 33 24
+1 -1
arch/mips/kernel/csrc-r4k.c
··· 78 78 * by the VDSO (HWREna is configured by configure_hwrena()). 79 79 */ 80 80 if (cpu_has_mips_r2_r6 && rdhwr_count_usable()) 81 - clocksource_mips.archdata.vdso_clock_mode = VDSO_CLOCK_R4K; 81 + clocksource_mips.vdso_clock_mode = VDSO_CLOCKMODE_R4K; 82 82 83 83 clocksource_register_hz(&clocksource_mips, mips_hpt_frequency); 84 84
+4 -4
drivers/clocksource/mips-gic-timer.c
··· 155 155 } 156 156 157 157 static struct clocksource gic_clocksource = { 158 - .name = "GIC", 159 - .read = gic_hpt_read, 160 - .flags = CLOCK_SOURCE_IS_CONTINUOUS, 161 - .archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC }, 158 + .name = "GIC", 159 + .read = gic_hpt_read, 160 + .flags = CLOCK_SOURCE_IS_CONTINUOUS, 161 + .vdso_clock_mode = VDSO_CLOCKMODE_GIC, 162 162 }; 163 163 164 164 static int __init __gic_clocksource_init(void)