aboutsummaryrefslogtreecommitdiffstats
path: root/include/nvgpu/timers.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/nvgpu/timers.h')
-rw-r--r--include/nvgpu/timers.h116
1 files changed, 0 insertions, 116 deletions
diff --git a/include/nvgpu/timers.h b/include/nvgpu/timers.h
deleted file mode 100644
index f69e234..0000000
--- a/include/nvgpu/timers.h
+++ /dev/null
@@ -1,116 +0,0 @@
1/*
2 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef NVGPU_TIMERS_H
24#define NVGPU_TIMERS_H
25
26#include <nvgpu/types.h>
27#include <nvgpu/utils.h>
28
29struct gk20a;
30
31/*
32 * struct nvgpu_timeout - define a timeout.
33 *
34 * There are two types of timer suported:
35 *
36 * o NVGPU_TIMER_CPU_TIMER
37 * Timer uses the CPU to measure the timeout.
38 *
39 * o NVGPU_TIMER_RETRY_TIMER
40 * Instead of measuring a time limit keep track of the number of times
41 * something has been attempted. After said limit, "expire" the timer.
42 *
43 * Available flags:
44 *
45 * o NVGPU_TIMER_NO_PRE_SI
46 * By default when the system is not running on silicon the timeout
47 * code will ignore the requested timeout. Specifying this flag will
48 * override that behavior and honor the timeout regardless of platform.
49 *
50 * o NVGPU_TIMER_SILENT_TIMEOUT
51 * Do not print any messages on timeout. Normally a simple message is
52 * printed that specifies where the timeout occurred.
53 */
54struct nvgpu_timeout {
55 struct gk20a *g;
56
57 unsigned int flags;
58
59 union {
60 s64 time;
61 struct {
62 u32 max;
63 u32 attempted;
64 } retries;
65 };
66};
67
68/*
69 * Bit 0 specifies the type of timer: CPU or retry.
70 */
71#define NVGPU_TIMER_CPU_TIMER (0x0)
72#define NVGPU_TIMER_RETRY_TIMER (0x1)
73
74/*
75 * Bits 1 through 7 are reserved; bits 8 and up are flags:
76 */
77#define NVGPU_TIMER_NO_PRE_SI (0x1 << 8)
78#define NVGPU_TIMER_SILENT_TIMEOUT (0x1 << 9)
79
80#define NVGPU_TIMER_FLAG_MASK (NVGPU_TIMER_RETRY_TIMER | \
81 NVGPU_TIMER_NO_PRE_SI | \
82 NVGPU_TIMER_SILENT_TIMEOUT)
83
84int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
85 u32 duration, unsigned long flags);
86int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout);
87
88#define nvgpu_timeout_expired(__timeout) \
89 __nvgpu_timeout_expired_msg(__timeout, _NVGPU_GET_IP_, "")
90
91#define nvgpu_timeout_expired_msg(__timeout, fmt, args...) \
92 __nvgpu_timeout_expired_msg(__timeout, _NVGPU_GET_IP_, \
93 fmt, ##args)
94
95/*
96 * Don't use this directly.
97 */
98int __nvgpu_timeout_expired_msg(struct nvgpu_timeout *timeout,
99 void *caller, const char *fmt, ...);
100
101
102/*
103 * Waits and delays.
104 */
105void nvgpu_msleep(unsigned int msecs);
106void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us);
107void nvgpu_udelay(unsigned int usecs);
108
109/*
110 * Timekeeping.
111 */
112s64 nvgpu_current_time_ms(void);
113s64 nvgpu_current_time_ns(void);
114u64 nvgpu_hr_timestamp(void);
115
116#endif /* NVGPU_TIMERS_H */