summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/log.h170
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/semaphore.h1
2 files changed, 171 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/log.h b/drivers/gpu/nvgpu/include/nvgpu/log.h
new file mode 100644
index 00000000..26738993
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/log.h
@@ -0,0 +1,170 @@
1/*
2 * Copyright (c) 2017, 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_DEBUGGING_H__
18#define __NVGPU_DEBUGGING_H__
19
20struct gk20a;
21
22enum nvgpu_log_type {
23 ERROR,
24 WARNING,
25 DEBUG
26};
27
28/*
29 * Each OS must implement these functions. They handle the OS specific nuances
30 * of printing data to a UART, log, whatever.
31 */
32__attribute__((format (printf, 5, 6)))
33void __nvgpu_log_msg(struct gk20a *g, const char *func_name, int line,
34 enum nvgpu_log_type type, const char *fmt, ...);
35
36__attribute__((format (printf, 5, 6)))
37void __nvgpu_log_dbg(struct gk20a *g, u32 log_mask,
38 const char *func_name, int line,
39 const char *fmt, ...);
40
41/*
42 * Use this define to set a default mask.
43 */
44#define NVGPU_DEFAULT_DBG_MASK (0)
45
46enum nvgpu_log_categories {
47 gpu_dbg_info = BIT(0), /* Lightly verbose info. */
48 gpu_dbg_fn = BIT(1), /* Function name tracing. */
49 gpu_dbg_reg = BIT(2), /* Register accesses; very verbose. */
50 gpu_dbg_pte = BIT(3), /* GMMU PTEs. */
51 gpu_dbg_intr = BIT(4), /* Interrupts. */
52 gpu_dbg_pmu = BIT(5), /* gk20a pmu. */
53 gpu_dbg_clk = BIT(6), /* gk20a clk. */
54 gpu_dbg_map = BIT(7), /* Memory mappings. */
55 gpu_dbg_map_v = BIT(8), /* Verbose mem mappings. */
56 gpu_dbg_gpu_dbg = BIT(9), /* GPU debugger/profiler. */
57 gpu_dbg_cde = BIT(10), /* cde info messages. */
58 gpu_dbg_cde_ctx = BIT(11), /* cde context usage messages. */
59 gpu_dbg_ctxsw = BIT(12), /* ctxsw tracing. */
60 gpu_dbg_sched = BIT(13), /* Sched control tracing. */
61 gpu_dbg_sema = BIT(14), /* Semaphore debugging. */
62 gpu_dbg_sema_v = BIT(15), /* Verbose semaphore debugging. */
63 gpu_dbg_pmu_pstate = BIT(16), /* p state controlled by pmu. */
64 gpu_dbg_xv = BIT(17), /* XVE debugging. */
65 gpu_dbg_shutdown = BIT(18), /* GPU shutdown tracing. */
66 gpu_dbg_kmem = BIT(19), /* Kmem tracking debugging. */
67 gpu_dbg_mem = BIT(31), /* memory accesses; very verbose. */
68};
69
70/**
71 * nvgpu_log_mask_enabled - Check if logging is enabled
72 *
73 * @g - The GPU.
74 * @log_mask - The mask the check against.
75 *
76 * Check if, given the passed mask, logging would actually happen. This is
77 * useful for avoiding calling the logging function many times when we know that
78 * said prints would not happen. For example for-loops of log statements in
79 * critical paths.
80 */
81int nvgpu_log_mask_enabled(struct gk20a *g, u32 log_mask);
82
83/**
84 * nvgpu_log - Print a debug message
85 *
86 * @g - The GPU.
87 * @log_mask - A mask defining when the print should happen. See enum
88 * %nvgpu_log_categories.
89 * @fmt - A format string (printf style).
90 * @arg... - Arguments for the format string.
91 *
92 * Print a message if the log_mask matches the enabled debugging.
93 */
94#define nvgpu_log(g, log_mask, fmt, arg...) \
95 __nvgpu_log_dbg(g, log_mask, __func__, __LINE__, fmt, ##arg); \
96
97/**
98 * nvgpu_err - Print an error
99 *
100 * @g - The GPU.
101 * @fmt - A format string (printf style).
102 * @arg... - Arguments for the format string.
103 *
104 * Uncondtionally print an error message.
105 */
106#define nvgpu_err(g, fmt, arg...) \
107 __nvgpu_log_msg(g, __func__, __LINE__, ERROR, fmt, ##arg)
108
109/**
110 * nvgpu_err - Print a warning
111 *
112 * @g - The GPU.
113 * @fmt - A format string (printf style).
114 * @arg... - Arguments for the format string.
115 *
116 * Uncondtionally print a warming message.
117 */
118#define nvgpu_warn(g, fmt, arg...) \
119 __nvgpu_log_msg(g, __func__, __LINE__, WARNING, fmt, ##arg)
120
121/*
122 * Some convenience macros.
123 */
124#define nvgpu_log_fn(g, fmt, arg...) nvgpu_log(g, gpu_dbg_fn, fmt, ##arg)
125#define nvgpu_log_info(g, fmt, arg...) nvgpu_log(g, gpu_dbg_info, fmt, ##arg)
126
127/******************************************************************************
128 * The old legacy debugging API minus some parts that are unnecessary. *
129 * Please, please, please do not use this!!! This is still around to aid *
130 * transitioning to the new API. *
131 * *
132 * This changes up the print formats to be closer to the new APIs formats. *
133 * Also it removes the dev_warn() and dev_err() usage. Those arguments are *
134 * ignored now. *
135 ******************************************************************************/
136
137/*
138 * This exist for backwards compatibility with the old debug/logging API. If you
139 * want ftrace support use the new API!
140 */
141extern u32 nvgpu_dbg_mask;
142
143#define gk20a_dbg(log_mask, fmt, arg...) \
144 do { \
145 if (((log_mask) & nvgpu_dbg_mask) != 0) \
146 __nvgpu_log_msg(NULL, __func__, __LINE__, \
147 DEBUG, fmt "\n", ##arg); \
148 } while (0)
149
150#define gk20a_err(d, fmt, arg...) \
151 do { \
152 __nvgpu_log_msg(NULL, __func__, __LINE__, ERROR, \
153 fmt "\n", ##arg); \
154 (void)(d); \
155 } while (0)
156
157#define gk20a_warn(d, fmt, arg...) \
158 do { \
159 __nvgpu_log_msg(NULL, __func__, __LINE__, WARNING, \
160 fmt "\n", ##arg); \
161 (void)(d); \
162 } while (0)
163
164/*
165 * Some convenience macros.
166 */
167#define gk20a_dbg_fn(fmt, arg...) gk20a_dbg(gpu_dbg_fn, fmt, ##arg)
168#define gk20a_dbg_info(fmt, arg...) gk20a_dbg(gpu_dbg_info, fmt, ##arg)
169
170#endif
diff --git a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h
index 6c9b8118..ade48178 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h
@@ -18,6 +18,7 @@
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20 20
21#include <nvgpu/log.h>
21#include <nvgpu/allocator.h> 22#include <nvgpu/allocator.h>
22 23
23#include "gk20a/gk20a.h" 24#include "gk20a/gk20a.h"