Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / nouveau / include / nvif / timer.h
blob57587a985c4bb13b83270d84c5097ba3f5a60d05
1 #ifndef __NVIF_TIMER_H__
2 #define __NVIF_TIMER_H__
3 #include <nvif/os.h>
5 struct nvif_timer_wait {
6 struct nvif_device *device;
7 u64 limit;
8 u64 time0;
9 u64 time1;
10 int reads;
13 void nvif_timer_wait_init(struct nvif_device *, u64 nsec,
14 struct nvif_timer_wait *);
15 s64 nvif_timer_wait_test(struct nvif_timer_wait *);
17 /* Delay based on GPU time (ie. PTIMER).
19 * Will return -ETIMEDOUT unless the loop was terminated with 'break',
20 * where it will return the number of nanoseconds taken instead.
22 #define nvif_nsec(d,n,cond...) ({ \
23 struct nvif_timer_wait _wait; \
24 s64 _taken = 0; \
26 nvif_timer_wait_init((d), (n), &_wait); \
27 do { \
28 cond \
29 } while ((_taken = nvif_timer_wait_test(&_wait)) >= 0); \
31 _taken; \
33 #define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond)
34 #define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond)
35 #endif