1 #ifndef __NVIF_TIMER_H__ 2 #define __NVIF_TIMER_H__ 3 #include <nvif/os.h> 4 5 struct nvif_timer_wait { 6 struct nvif_device *device; 7 u64 limit; 8 u64 time0; 9 u64 time1; 10 int reads; 11 }; 12 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 *); 16 17 /* Delay based on GPU time (ie. PTIMER). 18 * 19 * Will return -ETIMEDOUT unless the loop was terminated with 'break', 20 * where it will return the number of nanoseconds taken instead. 21 */ 22 #define nvif_nsec(d,n,cond...) ({ \ 23 struct nvif_timer_wait _wait; \ 24 s64 _taken = 0; \ 25 \ 26 nvif_timer_wait_init((d), (n), &_wait); \ 27 do { \ 28 cond \ 29 } while ((_taken = nvif_timer_wait_test(&_wait)) >= 0); \ 30 \ 31 _taken; \ 32 }) 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 36