drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / riscv / include / asm / vdso / gettimeofday.h
blobba3283cf7accaa93a38512d2c17eda0eefde0612
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
3 #define __ASM_VDSO_GETTIMEOFDAY_H
5 #ifndef __ASSEMBLY__
7 #include <asm/barrier.h>
8 #include <asm/unistd.h>
9 #include <asm/csr.h>
10 #include <uapi/linux/time.h>
13 * 32-bit land is lacking generic time vsyscalls as well as the legacy 32-bit
14 * time syscalls like gettimeofday. Skip these definitions since on 32-bit.
16 #ifdef CONFIG_GENERIC_TIME_VSYSCALL
18 #define VDSO_HAS_CLOCK_GETRES 1
20 static __always_inline
21 int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
22 struct timezone *_tz)
24 register struct __kernel_old_timeval *tv asm("a0") = _tv;
25 register struct timezone *tz asm("a1") = _tz;
26 register long ret asm("a0");
27 register long nr asm("a7") = __NR_gettimeofday;
29 asm volatile ("ecall\n"
30 : "=r" (ret)
31 : "r"(tv), "r"(tz), "r"(nr)
32 : "memory");
34 return ret;
37 static __always_inline
38 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
40 register clockid_t clkid asm("a0") = _clkid;
41 register struct __kernel_timespec *ts asm("a1") = _ts;
42 register long ret asm("a0");
43 register long nr asm("a7") = __NR_clock_gettime;
45 asm volatile ("ecall\n"
46 : "=r" (ret)
47 : "r"(clkid), "r"(ts), "r"(nr)
48 : "memory");
50 return ret;
53 static __always_inline
54 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
56 register clockid_t clkid asm("a0") = _clkid;
57 register struct __kernel_timespec *ts asm("a1") = _ts;
58 register long ret asm("a0");
59 register long nr asm("a7") = __NR_clock_getres;
61 asm volatile ("ecall\n"
62 : "=r" (ret)
63 : "r"(clkid), "r"(ts), "r"(nr)
64 : "memory");
66 return ret;
69 #endif /* CONFIG_GENERIC_TIME_VSYSCALL */
71 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
72 const struct vdso_data *vd)
75 * The purpose of csr_read(CSR_TIME) is to trap the system into
76 * M-mode to obtain the value of CSR_TIME. Hence, unlike other
77 * architecture, no fence instructions surround the csr_read()
79 return csr_read(CSR_TIME);
82 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
84 return _vdso_data;
87 #ifdef CONFIG_TIME_NS
88 static __always_inline
89 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
91 return _timens_data;
93 #endif
94 #endif /* !__ASSEMBLY__ */
96 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */