hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/nouveau/include/nvkm/subdev/timer.h
....@@ -1,4 +1,4 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
1
+/* SPDX-License-Identifier: MIT */
22 #ifndef __NVKM_TIMER_H__
33 #define __NVKM_TIMER_H__
44 #include <core/subdev.h>
....@@ -28,6 +28,18 @@
2828 u64 nvkm_timer_read(struct nvkm_timer *);
2929 void nvkm_timer_alarm(struct nvkm_timer *, u32 nsec, struct nvkm_alarm *);
3030
31
+struct nvkm_timer_wait {
32
+ struct nvkm_timer *tmr;
33
+ u64 limit;
34
+ u64 time0;
35
+ u64 time1;
36
+ int reads;
37
+};
38
+
39
+void nvkm_timer_wait_init(struct nvkm_device *, u64 nsec,
40
+ struct nvkm_timer_wait *);
41
+s64 nvkm_timer_wait_test(struct nvkm_timer_wait *);
42
+
3143 /* Delay based on GPU time (ie. PTIMER).
3244 *
3345 * Will return -ETIMEDOUT unless the loop was terminated with 'break',
....@@ -38,25 +50,21 @@
3850 */
3951 #define NVKM_DELAY _warn = false;
4052 #define nvkm_nsec(d,n,cond...) ({ \
41
- struct nvkm_device *_device = (d); \
42
- struct nvkm_timer *_tmr = _device->timer; \
43
- u64 _nsecs = (n), _time0 = nvkm_timer_read(_tmr); \
44
- s64 _taken = 0; \
53
+ struct nvkm_timer_wait _wait; \
4554 bool _warn = true; \
55
+ s64 _taken = 0; \
4656 \
57
+ nvkm_timer_wait_init((d), (n), &_wait); \
4758 do { \
4859 cond \
49
- } while (_taken = nvkm_timer_read(_tmr) - _time0, _taken < _nsecs); \
60
+ } while ((_taken = nvkm_timer_wait_test(&_wait)) >= 0); \
5061 \
51
- if (_taken >= _nsecs) { \
52
- if (_warn) \
53
- dev_WARN(_device->dev, "timeout\n"); \
54
- _taken = -ETIMEDOUT; \
55
- } \
62
+ if (_warn && _taken < 0) \
63
+ dev_WARN(_wait.tmr->subdev.device->dev, "timeout\n"); \
5664 _taken; \
5765 })
58
-#define nvkm_usec(d,u,cond...) nvkm_nsec((d), (u) * 1000, ##cond)
59
-#define nvkm_msec(d,m,cond...) nvkm_usec((d), (m) * 1000, ##cond)
66
+#define nvkm_usec(d, u, cond...) nvkm_nsec((d), (u) * 1000ULL, ##cond)
67
+#define nvkm_msec(d, m, cond...) nvkm_usec((d), (m) * 1000ULL, ##cond)
6068
6169 #define nvkm_wait_nsec(d,n,addr,mask,data) \
6270 nvkm_nsec(d, n, \