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

Configure Feed

Select the types of activity you want to include in your feed.

ARM/arm64: vdso: Use common vdso clock mode storage

Convert ARM/ARM64 to the generic VDSO clock mode storage. This needs to
happen in one go as they share the clocksource driver.

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



+29 -57
-1
arch/arm/Kconfig
··· 3 3 bool 4 4 default y 5 5 select ARCH_32BIT_OFF_T 6 - select ARCH_CLOCKSOURCE_DATA 7 6 select ARCH_HAS_BINFMT_FLAT 8 7 select ARCH_HAS_DEBUG_VIRTUAL if MMU 9 8 select ARCH_HAS_DEVMEM_IS_ALLOWED
+2 -3
arch/arm/include/asm/clocksource.h
··· 1 1 #ifndef _ASM_CLOCKSOURCE_H 2 2 #define _ASM_CLOCKSOURCE_H 3 3 4 - struct arch_clocksource_data { 5 - bool vdso_direct; /* Usable for direct VDSO access? */ 6 - }; 4 + #define VDSO_ARCH_CLOCKMODES \ 5 + VDSO_CLOCKMODE_ARCHTIMER 7 6 8 7 #endif
+9 -3
arch/arm/include/asm/vdso/gettimeofday.h
··· 117 117 #ifdef CONFIG_ARM_ARCH_TIMER 118 118 u64 cycle_now; 119 119 120 - if (!clock_mode) 121 - return -EINVAL; 120 + /* 121 + * Core checks for mode already, so this raced against a concurrent 122 + * update. Return something. Core will do another round and then 123 + * see the mode change and fallback to the syscall. 124 + */ 125 + if (clock_mode == VDSO_CLOCKMODE_NONE) 126 + return 0; 122 127 123 128 isb(); 124 129 cycle_now = read_sysreg(CNTVCT); 125 130 126 131 return cycle_now; 127 132 #else 128 - return -EINVAL; /* use fallback */ 133 + /* Make GCC happy. This is compiled out anyway */ 134 + return 0; 129 135 #endif 130 136 } 131 137
-21
arch/arm/include/asm/vdso/vsyscall.h
··· 11 11 extern struct vdso_data *vdso_data; 12 12 extern bool cntvct_ok; 13 13 14 - static __always_inline 15 - bool tk_is_cntvct(const struct timekeeper *tk) 16 - { 17 - if (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) 18 - return false; 19 - 20 - if (!tk->tkr_mono.clock->archdata.vdso_direct) 21 - return false; 22 - 23 - return true; 24 - } 25 - 26 14 /* 27 15 * Update the vDSO data page to keep in sync with kernel timekeeping. 28 16 */ ··· 27 39 return cntvct_ok; 28 40 } 29 41 #define __arch_update_vdso_data __arm_update_vdso_data 30 - 31 - static __always_inline 32 - int __arm_get_clock_mode(struct timekeeper *tk) 33 - { 34 - u32 __tk_is_cntvct = tk_is_cntvct(tk); 35 - 36 - return __tk_is_cntvct; 37 - } 38 - #define __arch_get_clock_mode __arm_get_clock_mode 39 42 40 43 static __always_inline 41 44 void __arm_sync_vdso_data(struct vdso_data *vdata)
+1
arch/arm/mm/Kconfig
··· 900 900 select GENERIC_TIME_VSYSCALL 901 901 select GENERIC_VDSO_32 902 902 select GENERIC_GETTIMEOFDAY 903 + select GENERIC_VDSO_CLOCK_MODE 903 904 help 904 905 Place in the process address space an ELF shared object 905 906 providing fast implementations of gettimeofday and
+1 -1
arch/arm64/Kconfig
··· 9 9 select ACPI_MCFG if (ACPI && PCI) 10 10 select ACPI_SPCR_TABLE if ACPI 11 11 select ACPI_PPTT if ACPI 12 - select ARCH_CLOCKSOURCE_DATA 13 12 select ARCH_HAS_DEBUG_VIRTUAL 14 13 select ARCH_HAS_DEVMEM_IS_ALLOWED 15 14 select ARCH_HAS_DMA_PREP_COHERENT ··· 110 111 select GENERIC_STRNLEN_USER 111 112 select GENERIC_TIME_VSYSCALL 112 113 select GENERIC_GETTIMEOFDAY 114 + select GENERIC_VDSO_CLOCK_MODE 113 115 select HANDLE_DOMAIN_IRQ 114 116 select HARDIRQS_SW_RESEND 115 117 select HAVE_PCI
+2 -3
arch/arm64/include/asm/clocksource.h
··· 2 2 #ifndef _ASM_CLOCKSOURCE_H 3 3 #define _ASM_CLOCKSOURCE_H 4 4 5 - struct arch_clocksource_data { 6 - bool vdso_direct; /* Usable for direct VDSO access? */ 7 - }; 5 + #define VDSO_ARCH_CLOCKMODES \ 6 + VDSO_CLOCKMODE_ARCHTIMER 8 7 9 8 #endif
+5 -6
arch/arm64/include/asm/vdso/compat_gettimeofday.h
··· 12 12 13 13 #include <asm/vdso/compat_barrier.h> 14 14 15 - #define __VDSO_USE_SYSCALL ULLONG_MAX 16 - 17 15 #define VDSO_HAS_CLOCK_GETRES 1 18 16 19 17 #define BUILD_VDSO32 1 ··· 115 117 u64 res; 116 118 117 119 /* 118 - * clock_mode == 0 implies that vDSO are enabled otherwise 119 - * fallback on syscall. 120 + * Core checks for mode already, so this raced against a concurrent 121 + * update. Return something. Core will do another round and then 122 + * see the mode change and fallback to the syscall. 120 123 */ 121 - if (clock_mode) 122 - return __VDSO_USE_SYSCALL; 124 + if (clock_mode == VDSO_CLOCKMODE_NONE) 125 + return 0; 123 126 124 127 /* 125 128 * This isb() is required to prevent that the counter value
+5 -6
arch/arm64/include/asm/vdso/gettimeofday.h
··· 10 10 #include <asm/unistd.h> 11 11 #include <uapi/linux/time.h> 12 12 13 - #define __VDSO_USE_SYSCALL ULLONG_MAX 14 - 15 13 #define VDSO_HAS_CLOCK_GETRES 1 16 14 17 15 static __always_inline ··· 69 71 u64 res; 70 72 71 73 /* 72 - * clock_mode == 0 implies that vDSO are enabled otherwise 73 - * fallback on syscall. 74 + * Core checks for mode already, so this raced against a concurrent 75 + * update. Return something. Core will do another round and then 76 + * see the mode change and fallback to the syscall. 74 77 */ 75 - if (clock_mode) 76 - return __VDSO_USE_SYSCALL; 78 + if (clock_mode == VDSO_CLOCKMODE_NONE) 79 + return 0; 77 80 78 81 /* 79 82 * This isb() is required to prevent that the counter value
-9
arch/arm64/include/asm/vdso/vsyscall.h
··· 22 22 #define __arch_get_k_vdso_data __arm64_get_k_vdso_data 23 23 24 24 static __always_inline 25 - int __arm64_get_clock_mode(struct timekeeper *tk) 26 - { 27 - u32 use_syscall = !tk->tkr_mono.clock->archdata.vdso_direct; 28 - 29 - return use_syscall; 30 - } 31 - #define __arch_get_clock_mode __arm64_get_clock_mode 32 - 33 - static __always_inline 34 25 void __arm64_update_vsyscall(struct vdso_data *vdata, struct timekeeper *tk) 35 26 { 36 27 vdata[CS_HRES_COARSE].mask = VDSO_PRECISION_MASK;
+4 -4
drivers/clocksource/arm_arch_timer.c
··· 69 69 static bool arch_timer_c3stop; 70 70 static bool arch_timer_mem_use_virtual; 71 71 static bool arch_counter_suspend_stop; 72 - static bool vdso_default = true; 72 + static enum vdso_clock_mode vdso_default = VDSO_CLOCKMODE_ARCHTIMER; 73 73 74 74 static cpumask_t evtstrm_available = CPU_MASK_NONE; 75 75 static bool evtstrm_enable = IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM); ··· 560 560 * change both the default value and the vdso itself. 561 561 */ 562 562 if (wa->read_cntvct_el0) { 563 - clocksource_counter.archdata.vdso_direct = false; 564 - vdso_default = false; 563 + clocksource_counter.vdso_clock_mode = VDSO_CLOCKMODE_NONE; 564 + vdso_default = VDSO_CLOCKMODE_NONE; 565 565 } 566 566 } 567 567 ··· 979 979 } 980 980 981 981 arch_timer_read_counter = rd; 982 - clocksource_counter.archdata.vdso_direct = vdso_default; 982 + clocksource_counter.vdso_clock_mode = vdso_default; 983 983 } else { 984 984 arch_timer_read_counter = arch_counter_get_cntvct_mem; 985 985 }