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