summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2016-11-11 17:35:54 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2016-12-05 19:16:16 -0500
commitd8fd0e64678997b535c3208ce8cc081b1cac7fa9 (patch)
tree25b93f0c10de6bfe2450b9e189bb4ee5bff28182 /drivers/gpu/nvgpu/include
parent37d4b649d43e1024859d56becfaaa25a0a41868c (diff)
gpu: nvgpu: Add timeout API
Add a timeout API to nvgpu since this is a common operation done all across the nvgpu driver. Also add two new directories for this common code: drivers/gpu/nvgpu/common drivers/gpu/nvgpu/include/nvgpu The common directory is for common C code. The include directory is for common include files. Bug 1799159 Change-Id: I8b710eecaa75c0707df83f859fb28484525185a6 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1255864 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/timers.h94
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
20struct 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 */
45struct 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
75int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
76 int duration, unsigned long flags);
77int 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 */
91int __nvgpu_timeout_check_msg(struct nvgpu_timeout *timeout,
92 void *caller, const char *fmt, ...);
93
94#endif