diff options
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/timers.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h new file mode 100644 index 00000000..e46982c9 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef __NVGPU_TIMERS_H__ | ||
18 | #define __NVGPU_TIMERS_H__ | ||
19 | |||
20 | struct gk20a; | ||
21 | |||
22 | /* | ||
23 | * struct nvgpu_timeout - define a timeout. | ||
24 | * | ||
25 | * There are two types of timer suported: | ||
26 | * | ||
27 | * o NVGPU_TIMER_CPU_TIMER | ||
28 | * Timer uses the CPU to measure the timeout. | ||
29 | * | ||
30 | * o NVGPU_TIMER_RETRY_TIMER | ||
31 | * Instead of measuring a time limit keep track of the number of times | ||
32 | * something has been attempted. After said limit, "expire" the timer. | ||
33 | * | ||
34 | * Available flags: | ||
35 | * | ||
36 | * o NVGPU_TIMER_NO_PRE_SI | ||
37 | * By default when the system is not running on silicon the timeout | ||
38 | * code will ignore the requested timeout. Specifying this flag will | ||
39 | * override that behavior and honor the timeout regardless of platform. | ||
40 | * | ||
41 | * o NVGPU_TIMER_SILENT_TIMEOUT | ||
42 | * Do not print any messages on timeout. Normally a simple message is | ||
43 | * printed that specifies where the timeout occurred. | ||
44 | */ | ||
45 | struct nvgpu_timeout { | ||
46 | struct gk20a *g; | ||
47 | |||
48 | unsigned int flags; | ||
49 | |||
50 | union { | ||
51 | unsigned long time; | ||
52 | struct { | ||
53 | int max; | ||
54 | int attempted; | ||
55 | } retries; | ||
56 | }; | ||
57 | }; | ||
58 | |||
59 | /* | ||
60 | * Bit 0 specifies the type of timer: CPU or retry. | ||
61 | */ | ||
62 | #define NVGPU_TIMER_CPU_TIMER (0x0) | ||
63 | #define NVGPU_TIMER_RETRY_TIMER (0x1) | ||
64 | |||
65 | /* | ||
66 | * Bits 1 through 7 are reserved; bits 8 and up are flags: | ||
67 | */ | ||
68 | #define NVGPU_TIMER_NO_PRE_SI (0x1 << 8) | ||
69 | #define NVGPU_TIMER_SILENT_TIMEOUT (0x1 << 9) | ||
70 | |||
71 | #define NVGPU_TIMER_FLAG_MASK (NVGPU_TIMER_RETRY_TIMER | \ | ||
72 | NVGPU_TIMER_NO_PRE_SI | \ | ||
73 | NVGPU_TIMER_SILENT_TIMEOUT) | ||
74 | |||
75 | int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, | ||
76 | int duration, unsigned long flags); | ||
77 | int nvgpu_timeout_peek(struct nvgpu_timeout *timeout); | ||
78 | |||
79 | #define nvgpu_timeout_check(__timeout) \ | ||
80 | __nvgpu_timeout_check_msg(__timeout, \ | ||
81 | __builtin_return_address(0), "") | ||
82 | |||
83 | #define nvgpu_timeout_check_msg(__timeout, fmt, args...) \ | ||
84 | __nvgpu_timeout_check_msg(__timeout, \ | ||
85 | __builtin_return_address(0), \ | ||
86 | fmt, ##args) | ||
87 | |||
88 | /* | ||
89 | * Don't use this directly. | ||
90 | */ | ||
91 | int __nvgpu_timeout_check_msg(struct nvgpu_timeout *timeout, | ||
92 | void *caller, const char *fmt, ...); | ||
93 | |||
94 | #endif | ||