aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincenzo Frascino <vincenzo.frascino@arm.com>2019-04-01 07:51:51 -0400
committerGreentime Hu <greentime@andestech.com>2019-05-16 03:07:08 -0400
commitaf9abd65983cf3602c03ef3d16fe549ba1f3eeed (patch)
tree165b6a5c5fa21f59a9d89724ae24573d16f106f7
parent63e07e202997ca01336ac93bf45dfd2c3a6ec512 (diff)
nds32: Fix vDSO clock_getres()
clock_getres in the vDSO library has to preserve the same behaviour of posix_get_hrtimer_res(). In particular, posix_get_hrtimer_res() does: sec = 0; ns = hrtimer_resolution; and hrtimer_resolution depends on the enablement of the high resolution timers that can happen either at compile or at run time. Fix the nds32 vdso implementation of clock_getres keeping a copy of hrtimer_resolution in vdso data and using that directly. Cc: Greentime Hu <green.hu@gmail.com> Cc: Vincent Chen <deanbo422@gmail.com> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com> Signed-off-by: Greentime Hu <greentime@andestech.com>
-rw-r--r--arch/nds32/include/asm/vdso_datapage.h1
-rw-r--r--arch/nds32/kernel/vdso.c1
-rw-r--r--arch/nds32/kernel/vdso/gettimeofday.c4
3 files changed, 5 insertions, 1 deletions
diff --git a/arch/nds32/include/asm/vdso_datapage.h b/arch/nds32/include/asm/vdso_datapage.h
index cd1dda3da0f9..74c68802021e 100644
--- a/arch/nds32/include/asm/vdso_datapage.h
+++ b/arch/nds32/include/asm/vdso_datapage.h
@@ -20,6 +20,7 @@ struct vdso_data {
20 u32 xtime_clock_sec; /* CLOCK_REALTIME - seconds */ 20 u32 xtime_clock_sec; /* CLOCK_REALTIME - seconds */
21 u32 cs_mult; /* clocksource multiplier */ 21 u32 cs_mult; /* clocksource multiplier */
22 u32 cs_shift; /* Cycle to nanosecond divisor (power of two) */ 22 u32 cs_shift; /* Cycle to nanosecond divisor (power of two) */
23 u32 hrtimer_res; /* hrtimer resolution */
23 24
24 u64 cs_cycle_last; /* last cycle value */ 25 u64 cs_cycle_last; /* last cycle value */
25 u64 cs_mask; /* clocksource mask */ 26 u64 cs_mask; /* clocksource mask */
diff --git a/arch/nds32/kernel/vdso.c b/arch/nds32/kernel/vdso.c
index 016f15891f6d..90bcae6f8554 100644
--- a/arch/nds32/kernel/vdso.c
+++ b/arch/nds32/kernel/vdso.c
@@ -220,6 +220,7 @@ void update_vsyscall(struct timekeeper *tk)
220 vdso_data->xtime_coarse_sec = tk->xtime_sec; 220 vdso_data->xtime_coarse_sec = tk->xtime_sec;
221 vdso_data->xtime_coarse_nsec = tk->tkr_mono.xtime_nsec >> 221 vdso_data->xtime_coarse_nsec = tk->tkr_mono.xtime_nsec >>
222 tk->tkr_mono.shift; 222 tk->tkr_mono.shift;
223 vdso_data->hrtimer_res = hrtimer_resolution;
223 vdso_write_end(vdso_data); 224 vdso_write_end(vdso_data);
224} 225}
225 226
diff --git a/arch/nds32/kernel/vdso/gettimeofday.c b/arch/nds32/kernel/vdso/gettimeofday.c
index 038721af40e3..b02581891c33 100644
--- a/arch/nds32/kernel/vdso/gettimeofday.c
+++ b/arch/nds32/kernel/vdso/gettimeofday.c
@@ -208,6 +208,8 @@ static notrace int clock_getres_fallback(clockid_t _clk_id,
208 208
209notrace int __vdso_clock_getres(clockid_t clk_id, struct timespec *res) 209notrace int __vdso_clock_getres(clockid_t clk_id, struct timespec *res)
210{ 210{
211 struct vdso_data *vdata = __get_datapage();
212
211 if (res == NULL) 213 if (res == NULL)
212 return 0; 214 return 0;
213 switch (clk_id) { 215 switch (clk_id) {
@@ -215,7 +217,7 @@ notrace int __vdso_clock_getres(clockid_t clk_id, struct timespec *res)
215 case CLOCK_MONOTONIC: 217 case CLOCK_MONOTONIC:
216 case CLOCK_MONOTONIC_RAW: 218 case CLOCK_MONOTONIC_RAW:
217 res->tv_sec = 0; 219 res->tv_sec = 0;
218 res->tv_nsec = CLOCK_REALTIME_RES; 220 res->tv_nsec = vdata->hrtimer_res;
219 break; 221 break;
220 case CLOCK_REALTIME_COARSE: 222 case CLOCK_REALTIME_COARSE:
221 case CLOCK_MONOTONIC_COARSE: 223 case CLOCK_MONOTONIC_COARSE: