drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / arch / loongarch / include / asm / vdso / gettimeofday.h
blob7eb3f041af764d141b005f821593a358096874ba
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Author: Huacai Chen <chenhuacai@loongson.cn>
5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 */
7 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
8 #define __ASM_VDSO_GETTIMEOFDAY_H
10 #ifndef __ASSEMBLY__
12 #include <asm/unistd.h>
13 #include <asm/vdso/vdso.h>
15 #define VDSO_HAS_CLOCK_GETRES 1
17 static __always_inline long gettimeofday_fallback(
18 struct __kernel_old_timeval *_tv,
19 struct timezone *_tz)
21 register struct __kernel_old_timeval *tv asm("a0") = _tv;
22 register struct timezone *tz asm("a1") = _tz;
23 register long nr asm("a7") = __NR_gettimeofday;
24 register long ret asm("a0");
26 asm volatile(
27 " syscall 0\n"
28 : "+r" (ret)
29 : "r" (nr), "r" (tv), "r" (tz)
30 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7",
31 "$t8", "memory");
33 return ret;
36 static __always_inline long clock_gettime_fallback(
37 clockid_t _clkid,
38 struct __kernel_timespec *_ts)
40 register clockid_t clkid asm("a0") = _clkid;
41 register struct __kernel_timespec *ts asm("a1") = _ts;
42 register long nr asm("a7") = __NR_clock_gettime;
43 register long ret asm("a0");
45 asm volatile(
46 " syscall 0\n"
47 : "+r" (ret)
48 : "r" (nr), "r" (clkid), "r" (ts)
49 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7",
50 "$t8", "memory");
52 return ret;
55 static __always_inline int clock_getres_fallback(
56 clockid_t _clkid,
57 struct __kernel_timespec *_ts)
59 register clockid_t clkid asm("a0") = _clkid;
60 register struct __kernel_timespec *ts asm("a1") = _ts;
61 register long nr asm("a7") = __NR_clock_getres;
62 register long ret asm("a0");
64 asm volatile(
65 " syscall 0\n"
66 : "+r" (ret)
67 : "r" (nr), "r" (clkid), "r" (ts)
68 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7",
69 "$t8", "memory");
71 return ret;
74 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
75 const struct vdso_data *vd)
77 uint64_t count;
79 __asm__ __volatile__(
80 " rdtime.d %0, $zero\n"
81 : "=r" (count));
83 return count;
86 static inline bool loongarch_vdso_hres_capable(void)
88 return true;
90 #define __arch_vdso_hres_capable loongarch_vdso_hres_capable
92 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
94 return _vdso_data;
97 #ifdef CONFIG_TIME_NS
98 static __always_inline
99 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
101 return _timens_data;
103 #endif
104 #endif /* !__ASSEMBLY__ */
106 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */