Skip to content

Commit ae12e08

Browse files
chleroyKAGA-KOKO
authored andcommitted
lib/vdso: Allow fixed clock mode
Some architectures have a fixed clocksource which is known at compile time and cannot be replaced or disabled at runtime, e.g. timebase on PowerPC. For such cases the clock mode check in the VDSO code is pointless. Move the check for a VDSO capable clocksource into an inline function and allow architectures to redefine it via a macro. [ tglx: Removed the #ifdef mess ] Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> 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.748756829@linutronix.de
1 parent 2d6b01b commit ae12e08

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎lib/vdso/gettimeofday.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ static inline bool __arch_vdso_hres_capable(void)
4646
}
4747
#endif
4848

49+
#ifndef vdso_clocksource_ok
50+
static inline bool vdso_clocksource_ok(const struct vdso_data *vd)
51+
{
52+
return vd->clock_mode != VDSO_CLOCKMODE_NONE;
53+
}
54+
#endif
55+
4956
#ifdef CONFIG_TIME_NS
5057
static int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
5158
struct __kernel_timespec *ts)
@@ -66,7 +73,7 @@ static int do_hres_timens(const struct vdso_data *vdns, clockid_t clk,
6673
do {
6774
seq = vdso_read_begin(vd);
6875

69-
if (unlikely(vd->clock_mode == VDSO_CLOCKMODE_NONE))
76+
if (unlikely(!vdso_clocksource_ok(vd)))
7077
return -1;
7178

7279
cycles = __arch_get_hw_counter(vd->clock_mode);
@@ -134,7 +141,7 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk,
134141
}
135142
smp_rmb();
136143

137-
if (unlikely(vd->clock_mode == VDSO_CLOCKMODE_NONE))
144+
if (unlikely(!vdso_clocksource_ok(vd)))
138145
return -1;
139146

140147
cycles = __arch_get_hw_counter(vd->clock_mode);

0 commit comments

Comments
 (0)