diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
| commit | 01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch) | |
| tree | 4ef34501728a087be24f4ba0af90f91486bf780b /include/nvgpu/log.h | |
| parent | 306a03d18b305e4e573be3b2931978fa10679eb9 (diff) | |
Include nvgpu headers
These are needed to build on NVIDIA's Jetson boards for the time
being. Only a couple structs are required, so it should be fairly
easy to remove this dependency at some point in the future.
Diffstat (limited to 'include/nvgpu/log.h')
| -rw-r--r-- | include/nvgpu/log.h | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/include/nvgpu/log.h b/include/nvgpu/log.h new file mode 100644 index 0000000..70a1676 --- /dev/null +++ b/include/nvgpu/log.h | |||
| @@ -0,0 +1,183 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017-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_LOG_H | ||
| 24 | #define NVGPU_LOG_H | ||
| 25 | |||
| 26 | #include <nvgpu/types.h> | ||
| 27 | #include <nvgpu/bitops.h> | ||
| 28 | |||
| 29 | struct gk20a; | ||
| 30 | |||
| 31 | enum 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))) | ||
| 43 | void __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))) | ||
| 47 | void __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_mem BIT(31) /* memory accesses; very verbose. */ | ||
| 84 | |||
| 85 | /** | ||
| 86 | * nvgpu_log_mask_enabled - Check if logging is enabled | ||
| 87 | * | ||
| 88 | * @g - The GPU. | ||
| 89 | * @log_mask - The mask the check against. | ||
| 90 | * | ||
| 91 | * Check if, given the passed mask, logging would actually happen. This is | ||
| 92 | * useful for avoiding calling the logging function many times when we know that | ||
| 93 | * said prints would not happen. For example for-loops of log statements in | ||
| 94 | * critical paths. | ||
| 95 | */ | ||
| 96 | int nvgpu_log_mask_enabled(struct gk20a *g, u64 log_mask); | ||
| 97 | |||
| 98 | /** | ||
| 99 | * nvgpu_log - Print a debug message | ||
| 100 | * | ||
| 101 | * @g - The GPU. | ||
| 102 | * @log_mask - A mask defining when the print should happen. See enum | ||
| 103 | * %nvgpu_log_categories. | ||
| 104 | * @fmt - A format string (printf style). | ||
| 105 | * @arg... - Arguments for the format string. | ||
| 106 | * | ||
| 107 | * Print a message if the log_mask matches the enabled debugging. | ||
| 108 | */ | ||
| 109 | #define nvgpu_log(g, log_mask, fmt, arg...) \ | ||
| 110 | __nvgpu_log_dbg(g, (u32)log_mask, __func__, __LINE__, fmt, ##arg) | ||
| 111 | |||
| 112 | /** | ||
| 113 | * nvgpu_err - Print an error | ||
| 114 | * | ||
| 115 | * @g - The GPU. | ||
| 116 | * @fmt - A format string (printf style). | ||
| 117 | * @arg... - Arguments for the format string. | ||
| 118 | * | ||
| 119 | * Uncondtionally print an error message. | ||
| 120 | */ | ||
| 121 | #define nvgpu_err(g, fmt, arg...) \ | ||
| 122 | __nvgpu_log_msg(g, __func__, __LINE__, NVGPU_ERROR, fmt, ##arg) | ||
| 123 | |||
| 124 | /** | ||
| 125 | * nvgpu_err - Print a warning | ||
| 126 | * | ||
| 127 | * @g - The GPU. | ||
| 128 | * @fmt - A format string (printf style). | ||
| 129 | * @arg... - Arguments for the format string. | ||
| 130 | * | ||
| 131 | * Uncondtionally print a warming message. | ||
| 132 | */ | ||
| 133 | #define nvgpu_warn(g, fmt, arg...) \ | ||
| 134 | __nvgpu_log_msg(g, __func__, __LINE__, NVGPU_WARNING, fmt, ##arg) | ||
| 135 | |||
| 136 | /** | ||
| 137 | * nvgpu_info - Print an info message | ||
| 138 | * | ||
| 139 | * @g - The GPU. | ||
| 140 | * @fmt - A format string (printf style). | ||
| 141 | * @arg... - Arguments for the format string. | ||
| 142 | * | ||
| 143 | * Unconditionally print an information message. | ||
| 144 | */ | ||
| 145 | #define nvgpu_info(g, fmt, arg...) \ | ||
| 146 | __nvgpu_log_msg(g, __func__, __LINE__, NVGPU_INFO, fmt, ##arg) | ||
| 147 | |||
| 148 | /* | ||
| 149 | * Some convenience macros. | ||
| 150 | */ | ||
| 151 | #define nvgpu_log_fn(g, fmt, arg...) nvgpu_log(g, gpu_dbg_fn, fmt, ##arg) | ||
| 152 | #define nvgpu_log_info(g, fmt, arg...) nvgpu_log(g, gpu_dbg_info, fmt, ##arg) | ||
| 153 | |||
| 154 | /****************************************************************************** | ||
| 155 | * The old legacy debugging API minus some parts that are unnecessary. * | ||
| 156 | * Please, please, please do not use this!!! This is still around to aid * | ||
| 157 | * transitioning to the new API. * | ||
| 158 | * * | ||
| 159 | * This changes up the print formats to be closer to the new APIs formats. * | ||
| 160 | * Also it removes the dev_warn() and dev_err() usage. Those arguments are * | ||
| 161 | * ignored now. * | ||
| 162 | ******************************************************************************/ | ||
| 163 | |||
| 164 | /* | ||
| 165 | * This exist for backwards compatibility with the old debug/logging API. If you | ||
| 166 | * want ftrace support use the new API! | ||
| 167 | */ | ||
| 168 | extern u64 nvgpu_dbg_mask; | ||
| 169 | |||
| 170 | #define gk20a_dbg(log_mask, fmt, arg...) \ | ||
| 171 | do { \ | ||
| 172 | if (((log_mask) & nvgpu_dbg_mask) != 0) \ | ||
| 173 | __nvgpu_log_msg(NULL, __func__, __LINE__, \ | ||
| 174 | NVGPU_DEBUG, fmt "\n", ##arg); \ | ||
| 175 | } while (0) | ||
| 176 | |||
| 177 | /* | ||
| 178 | * Some convenience macros. | ||
| 179 | */ | ||
| 180 | #define gk20a_dbg_fn(fmt, arg...) gk20a_dbg(gpu_dbg_fn, fmt, ##arg) | ||
| 181 | #define gk20a_dbg_info(fmt, arg...) gk20a_dbg(gpu_dbg_info, fmt, ##arg) | ||
| 182 | |||
| 183 | #endif /* NVGPU_LOG_H */ | ||
