forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/arch/mips/include/asm/vdso/gettimeofday.h
....@@ -20,7 +20,11 @@
2020
2121 #define VDSO_HAS_CLOCK_GETRES 1
2222
23
-#define __VDSO_USE_SYSCALL ULLONG_MAX
23
+#if MIPS_ISA_REV < 6
24
+#define VDSO_SYSCALL_CLOBBERS "hi", "lo",
25
+#else
26
+#define VDSO_SYSCALL_CLOBBERS
27
+#endif
2428
2529 static __always_inline long gettimeofday_fallback(
2630 struct __kernel_old_timeval *_tv,
....@@ -37,7 +41,9 @@
3741 : "=r" (ret), "=r" (error)
3842 : "r" (tv), "r" (tz), "r" (nr)
3943 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
40
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
44
+ "$14", "$15", "$24", "$25",
45
+ VDSO_SYSCALL_CLOBBERS
46
+ "memory");
4147
4248 return error ? -ret : ret;
4349 }
....@@ -61,7 +67,9 @@
6167 : "=r" (ret), "=r" (error)
6268 : "r" (clkid), "r" (ts), "r" (nr)
6369 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
64
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
70
+ "$14", "$15", "$24", "$25",
71
+ VDSO_SYSCALL_CLOBBERS
72
+ "memory");
6573
6674 return error ? -ret : ret;
6775 }
....@@ -85,14 +93,14 @@
8593 : "=r" (ret), "=r" (error)
8694 : "r" (clkid), "r" (ts), "r" (nr)
8795 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
88
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
96
+ "$14", "$15", "$24", "$25",
97
+ VDSO_SYSCALL_CLOBBERS
98
+ "memory");
8999
90100 return error ? -ret : ret;
91101 }
92102
93103 #if _MIPS_SIM != _MIPS_SIM_ABI64
94
-
95
-#define VDSO_HAS_32BIT_FALLBACK 1
96104
97105 static __always_inline long clock_gettime32_fallback(
98106 clockid_t _clkid,
....@@ -109,7 +117,9 @@
109117 : "=r" (ret), "=r" (error)
110118 : "r" (clkid), "r" (ts), "r" (nr)
111119 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
112
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
120
+ "$14", "$15", "$24", "$25",
121
+ VDSO_SYSCALL_CLOBBERS
122
+ "memory");
113123
114124 return error ? -ret : ret;
115125 }
....@@ -129,7 +139,9 @@
129139 : "=r" (ret), "=r" (error)
130140 : "r" (clkid), "r" (ts), "r" (nr)
131141 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
132
- "$14", "$15", "$24", "$25", "hi", "lo", "memory");
142
+ "$14", "$15", "$24", "$25",
143
+ VDSO_SYSCALL_CLOBBERS
144
+ "memory");
133145
134146 return error ? -ret : ret;
135147 }
....@@ -171,32 +183,32 @@
171183
172184 #endif
173185
174
-static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
186
+static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
187
+ const struct vdso_data *vd)
175188 {
176
-#ifdef CONFIG_CLKSRC_MIPS_GIC
177
- const struct vdso_data *data = get_vdso_data();
178
-#endif
179
- u64 cycle_now;
180
-
181
- switch (clock_mode) {
182189 #ifdef CONFIG_CSRC_R4K
183
- case VDSO_CLOCK_R4K:
184
- cycle_now = read_r4k_count();
185
- break;
190
+ if (clock_mode == VDSO_CLOCKMODE_R4K)
191
+ return read_r4k_count();
186192 #endif
187193 #ifdef CONFIG_CLKSRC_MIPS_GIC
188
- case VDSO_CLOCK_GIC:
189
- cycle_now = read_gic_count(data);
190
- break;
194
+ if (clock_mode == VDSO_CLOCKMODE_GIC)
195
+ return read_gic_count(vd);
191196 #endif
192
- default:
193
- cycle_now = __VDSO_USE_SYSCALL;
194
- break;
195
- }
196
-
197
- return cycle_now;
197
+ /*
198
+ * Core checks mode already. So this raced against a concurrent
199
+ * update. Return something. Core will do another round see the
200
+ * change and fallback to syscall.
201
+ */
202
+ return 0;
198203 }
199204
205
+static inline bool mips_vdso_hres_capable(void)
206
+{
207
+ return IS_ENABLED(CONFIG_CSRC_R4K) ||
208
+ IS_ENABLED(CONFIG_CLKSRC_MIPS_GIC);
209
+}
210
+#define __arch_vdso_hres_capable mips_vdso_hres_capable
211
+
200212 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
201213 {
202214 return get_vdso_data();