summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-03-27 13:41:53 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-04-04 19:04:31 -0400
commite3bd4ae2a59fef37a85fbca168fc479dd5514023 (patch)
tree17668f10101a756d02e695d2aa2f652129514d3b
parent0778d7f33181e4f945083e8e051d5f9476fe5968 (diff)
gpu: nvgpu: debugging API update
Update the debugging APIs in nvgpu to be more coherent and less dependent on Linux kernel APIs and data structures. The old API is maintained for backwards compatibility but the prints themselves are changed. The old API now prints stuff like this: [ 46.376077] nvgpu: gk20a_channel_suspend:3430 [DBG] suspend channel 508 [ 46.376242] nvgpu: gk20a_channel_suspend:3430 [DBG] suspend channel 509 [ 46.376359] nvgpu: gk20a_channel_suspend:3430 [DBG] suspend channel 510 [ 46.376466] nvgpu: gk20a_channel_suspend:3430 [DBG] suspend channel 511 [ 46.376604] nvgpu: gk20a_fifo_update_runlist_locked:3090 [DBG] runlist_id : 0, switch to new buffer 0x 4003a0000 [ 46.378348] nvgpu: gk20a_mm_l2_flush:5259 [DBG] l2_flush_dirty 0x2 [ 46.378562] nvgpu: clk_config_pll:170 [DBG] low_PL 1(div1), high_PL 2(div2) [ 46.378684] nvgpu: clk_config_pll:170 [DBG] low_PL 8(div8), high_PL 17(div17) Each line starts with 'nvgpu:' since this is the nvgpu driver. Then there's the function name which is is right justified and post-fixed with a line number. This keeps all statements lined up so long as the function name does not exceed the length of characters alloted for function names (33 currently). Lines are also left justified with 4 available spaces since there are currently no source files with over 9999 lines. The type of message (DBG, WRN, ERR) is then printed in brackets. Finally there's whatever message is to be printed. The new API will be largely the same except there will be an additional print of the GPU that the message has originated from in order to help debug cases where both an iGPU and dGPU are active. Also the implicit newline added in the legacy API has been removed. This is inline with essentially every other print function in the C world. There are numerous places where '\n' is added despite it not being needed which results in log files being littered with blank lines. This makes the logs much harder to read. Bug ... Change-Id: I7bc87f2dbbaebf6eb6c9de1a629a0e2963e1804c Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1329487 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/Makefile.nvgpu1
-rw-r--r--drivers/gpu/nvgpu/common/linux/log.c130
-rw-r--r--drivers/gpu/nvgpu/gk20a/debug_gk20a.c17
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c5
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h83
-rw-r--r--drivers/gpu/nvgpu/gp10b/cde_gp10b.c4
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/log.h170
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/semaphore.h1
8 files changed, 318 insertions, 93 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu
index 8a608ca4..b8a3f033 100644
--- a/drivers/gpu/nvgpu/Makefile.nvgpu
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu
@@ -30,6 +30,7 @@ nvgpu-y := \
30 common/linux/ioctl_as.o \ 30 common/linux/ioctl_as.o \
31 common/linux/ioctl_channel.o \ 31 common/linux/ioctl_channel.o \
32 common/linux/ioctl_tsg.o \ 32 common/linux/ioctl_tsg.o \
33 common/linux/log.o \
33 common/mm/nvgpu_allocator.o \ 34 common/mm/nvgpu_allocator.o \
34 common/mm/bitmap_allocator.o \ 35 common/mm/bitmap_allocator.o \
35 common/mm/buddy_allocator.o \ 36 common/mm/buddy_allocator.o \
diff --git a/drivers/gpu/nvgpu/common/linux/log.c b/drivers/gpu/nvgpu/common/linux/log.c
new file mode 100644
index 00000000..9dd965ec
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/log.c
@@ -0,0 +1,130 @@
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#include <linux/kernel.h>
18#include <linux/device.h>
19
20#include <nvgpu/log.h>
21
22#include "gk20a/gk20a.h"
23
24/*
25 * Define a length for log buffers. This is the buffer that the 'fmt, ...' part
26 * of __nvgpu_do_log_print() prints into. This buffer lives on the stack so it
27 * needs to not be overly sized since we have limited kernel stack space. But at
28 * the same time we don't want it to be restrictive either.
29 */
30#define LOG_BUFFER_LENGTH 160
31
32/*
33 * Annoying quirk of Linux: this has to be a string literal since the printk()
34 * function and friends use the preprocessor to concatenate stuff to the start
35 * of this string when printing.
36 */
37#define LOG_FMT "nvgpu: %s %33s:%-4d [%s] %s"
38
39u32 nvgpu_dbg_mask = NVGPU_DEFAULT_DBG_MASK;
40
41static const char *log_types[] = {
42 "ERR",
43 "WRN",
44 "DBG"
45};
46
47int nvgpu_log_mask_enabled(struct gk20a *g, u32 log_mask)
48{
49 return !!(g->log_mask & log_mask);
50}
51
52static inline const char *nvgpu_log_name(struct gk20a *g)
53{
54 return dev_name(g->dev);
55}
56
57#ifdef CONFIG_GK20A_TRACE_PRINTK
58static void __nvgpu_trace_printk_log(u32 trace, const char *gpu_name,
59 const char *func_name, int line,
60 enum nvgpu_log_type type, const char *log)
61{
62 trace_printk(LOG_FMT, gpu_name, func_name, line, type, log);
63}
64#endif
65
66static void __nvgpu_really_print_log(u32 trace, const char *gpu_name,
67 const char *func_name, int line,
68 enum nvgpu_log_type type, const char *log)
69{
70 const char *name = gpu_name ? gpu_name : "";
71
72#ifdef CONFIG_GK20A_TRACE_PRINTK
73 if (trace)
74 return __nvgpu_trace_printk_log(trace, name, func_name,
75 line, type, log);
76#else
77 const char *log_type = log_types[type];
78
79 switch (type) {
80 case DEBUG:
81 /*
82 * We could use pr_debug() here but we control debug enablement
83 * separately from the Linux kernel. Perhaps this is a bug in
84 * nvgpu.
85 */
86 pr_info(LOG_FMT, name, func_name, line, log_type, log);
87 break;
88 case WARNING:
89 pr_warn(LOG_FMT, name, func_name, line, log_type, log);
90 break;
91 case ERROR:
92 pr_err(LOG_FMT, name, func_name, line, log_type, log);
93 break;
94 }
95#endif
96}
97
98__attribute__((format (printf, 5, 6)))
99void __nvgpu_log_msg(struct gk20a *g, const char *func_name, int line,
100 enum nvgpu_log_type type, const char *fmt, ...)
101{
102 char log[LOG_BUFFER_LENGTH];
103 va_list args;
104
105 va_start(args, fmt);
106 vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args);
107 va_end(args);
108
109 __nvgpu_really_print_log(0, g ? nvgpu_log_name(g) : "",
110 func_name, line, type, log);
111}
112
113__attribute__((format (printf, 5, 6)))
114void __nvgpu_log_dbg(struct gk20a *g, u32 log_mask,
115 const char *func_name, int line,
116 const char *fmt, ...)
117{
118 char log[LOG_BUFFER_LENGTH];
119 va_list args;
120
121 if ((log_mask & g->log_mask) == 0)
122 return;
123
124 va_start(args, fmt);
125 vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args);
126 va_end(args);
127
128 __nvgpu_really_print_log(g->log_trace, nvgpu_log_name(g),
129 func_name, line, DEBUG, log);
130}
diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
index b666bb16..a8b9c5fb 100644
--- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c
@@ -16,8 +16,9 @@
16#include <linux/seq_file.h> 16#include <linux/seq_file.h>
17#include <linux/io.h> 17#include <linux/io.h>
18 18
19#include <nvgpu/semaphore.h> 19#include <nvgpu/log.h>
20#include <nvgpu/kmem.h> 20#include <nvgpu/kmem.h>
21#include <nvgpu/semaphore.h>
21 22
22#include "gk20a.h" 23#include "gk20a.h"
23#include "debug_gk20a.h" 24#include "debug_gk20a.h"
@@ -232,7 +233,6 @@ void gk20a_debug_init(struct device *dev, const char *debugfs_symlink)
232 struct gk20a_platform *platform = dev_get_drvdata(dev); 233 struct gk20a_platform *platform = dev_get_drvdata(dev);
233#ifdef CONFIG_DEBUG_FS 234#ifdef CONFIG_DEBUG_FS
234 struct gk20a *g = platform->g; 235 struct gk20a *g = platform->g;
235#endif
236 236
237 platform->debugfs = debugfs_create_dir(dev_name(dev), NULL); 237 platform->debugfs = debugfs_create_dir(dev_name(dev), NULL);
238 if (!platform->debugfs) 238 if (!platform->debugfs)
@@ -256,15 +256,16 @@ void gk20a_debug_init(struct device *dev, const char *debugfs_symlink)
256 debugfs_create_bool("disable_syncpoints", S_IRUGO|S_IWUSR, 256 debugfs_create_bool("disable_syncpoints", S_IRUGO|S_IWUSR,
257 platform->debugfs, &platform->disable_syncpoints); 257 platform->debugfs, &platform->disable_syncpoints);
258 258
259 /* Legacy debugging API. */
259 debugfs_create_u32("dbg_mask", S_IRUGO|S_IWUSR, 260 debugfs_create_u32("dbg_mask", S_IRUGO|S_IWUSR,
260 platform->debugfs, &gk20a_dbg_mask); 261 platform->debugfs, &nvgpu_dbg_mask);
261 262
262#ifdef CONFIG_GK20A_TRACE_PRINTK 263 /* New debug logging API. */
263 debugfs_create_u32("dbg_ftrace", S_IRUGO|S_IWUSR, 264 debugfs_create_u32("log_mask", S_IRUGO|S_IWUSR,
264 platform->debugfs, &gk20a_dbg_ftrace); 265 platform->debugfs, &g->log_mask);
265#endif 266 debugfs_create_u32("log_trace", S_IRUGO|S_IWUSR,
267 platform->debugfs, &g->log_trace);
266 268
267#ifdef CONFIG_DEBUG_FS
268 nvgpu_spinlock_init(&g->debugfs_lock); 269 nvgpu_spinlock_init(&g->debugfs_lock);
269 270
270 g->mm.ltc_enabled = true; 271 g->mm.ltc_enabled = true;
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 6d80f3ba..c8acf6f7 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -82,11 +82,6 @@
82 82
83#define GK20A_NUM_CDEVS 7 83#define GK20A_NUM_CDEVS 7
84 84
85u32 gk20a_dbg_mask = GK20A_DEFAULT_DBG_MASK;
86#ifdef CONFIG_GK20A_TRACE_PRINTK
87u32 gk20a_dbg_ftrace;
88#endif
89
90#define GK20A_WAIT_FOR_IDLE_MS 2000 85#define GK20A_WAIT_FOR_IDLE_MS 2000
91 86
92static int gk20a_pm_prepare_poweroff(struct device *dev); 87static int gk20a_pm_prepare_poweroff(struct device *dev);
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index ec27ed77..2a9f8a06 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -41,9 +41,10 @@ struct dbg_profiler_object_data;
41 41
42#include "../../../arch/arm/mach-tegra/iomap.h" 42#include "../../../arch/arm/mach-tegra/iomap.h"
43 43
44#include <nvgpu/as.h>
45#include <nvgpu/log.h>
44#include <nvgpu/pramin.h> 46#include <nvgpu/pramin.h>
45#include <nvgpu/acr/nvgpu_acr.h> 47#include <nvgpu/acr/nvgpu_acr.h>
46#include <nvgpu/as.h>
47 48
48#include "clk_gk20a.h" 49#include "clk_gk20a.h"
49#include "ce2_gk20a.h" 50#include "ce2_gk20a.h"
@@ -927,6 +928,9 @@ struct gk20a {
927 bool power_on; 928 bool power_on;
928 bool suspended; 929 bool suspended;
929 930
931 u32 log_mask;
932 u32 log_trace;
933
930 struct rw_semaphore busy_lock; 934 struct rw_semaphore busy_lock;
931 935
932 struct clk_gk20a clk; 936 struct clk_gk20a clk;
@@ -1193,89 +1197,12 @@ struct gk20a_cyclestate_buffer_elem {
1193 u64 data; 1197 u64 data;
1194}; 1198};
1195 1199
1196/* debug accessories */
1197
1198#ifdef CONFIG_DEBUG_FS
1199 /* debug info, default is compiled-in but effectively disabled (0 mask) */
1200 /*e.g: echo 1 > /d/gk20a.0/dbg_mask */
1201 #define GK20A_DEFAULT_DBG_MASK 0
1202#else
1203 /* manually enable and turn it on the mask */
1204 #define GK20A_DEFAULT_DBG_MASK (dbg_info)
1205#endif
1206
1207enum gk20a_dbg_categories {
1208 gpu_dbg_info = BIT(0), /* lightly verbose info */
1209 gpu_dbg_fn = BIT(2), /* fn name tracing */
1210 gpu_dbg_reg = BIT(3), /* register accesses, very verbose */
1211 gpu_dbg_pte = BIT(4), /* gmmu ptes */
1212 gpu_dbg_intr = BIT(5), /* interrupts */
1213 gpu_dbg_pmu = BIT(6), /* gk20a pmu */
1214 gpu_dbg_clk = BIT(7), /* gk20a clk */
1215 gpu_dbg_map = BIT(8), /* mem mappings */
1216 gpu_dbg_gpu_dbg = BIT(9), /* gpu debugger/profiler */
1217 gpu_dbg_cde = BIT(10), /* cde info messages */
1218 gpu_dbg_cde_ctx = BIT(11), /* cde context usage messages */
1219 gpu_dbg_ctxsw = BIT(12), /* ctxsw tracing */
1220 gpu_dbg_sched = BIT(13), /* sched control tracing */
1221 gpu_dbg_map_v = BIT(14), /* verbose mem mappings */
1222 gpu_dbg_sema = BIT(15), /* semaphore debugging */
1223 gpu_dbg_sema_v = BIT(16), /* verbose semaphore debugging */
1224 gpu_dbg_pmu_pstate = BIT(17), /* p state controlled by pmu */
1225 gpu_dbg_xv = BIT(18), /* XVE debugging */
1226 gpu_dbg_shutdown = BIT(19), /* GPU shutdown tracing */
1227 gpu_dbg_kmem = BIT(20), /* Kmem tracking debugging */
1228 gpu_dbg_mem = BIT(31), /* memory accesses, very verbose */
1229};
1230
1231/* operations that will need to be executed on non stall workqueue */ 1200/* operations that will need to be executed on non stall workqueue */
1232enum gk20a_nonstall_ops { 1201enum gk20a_nonstall_ops {
1233 gk20a_nonstall_ops_wakeup_semaphore = BIT(0), /* wake up semaphore */ 1202 gk20a_nonstall_ops_wakeup_semaphore = BIT(0), /* wake up semaphore */
1234 gk20a_nonstall_ops_post_events = BIT(1), 1203 gk20a_nonstall_ops_post_events = BIT(1),
1235}; 1204};
1236 1205
1237extern u32 gk20a_dbg_mask;
1238#ifdef CONFIG_GK20A_TRACE_PRINTK
1239extern u32 gk20a_dbg_ftrace;
1240#define gk20a_dbg(dbg_mask, format, arg...) \
1241do { \
1242 if (unlikely((dbg_mask) & gk20a_dbg_mask)) { \
1243 if (gk20a_dbg_ftrace) \
1244 trace_printk(format "\n", ##arg); \
1245 else \
1246 pr_info("gk20a %s: " format "\n", \
1247 __func__, ##arg); \
1248 } \
1249} while (0)
1250#else
1251#define gk20a_dbg(dbg_mask, format, arg...) \
1252do { \
1253 if (unlikely((dbg_mask) & gk20a_dbg_mask)) { \
1254 pr_info("gk20a %s: " format "\n", \
1255 __func__, ##arg); \
1256 } \
1257} while (0)
1258#endif
1259
1260#define gk20a_err(d, fmt, arg...) \
1261 do { \
1262 if (d) \
1263 dev_err(d, "%s: " fmt "\n", __func__, ##arg); \
1264 } while (0)
1265
1266#define gk20a_warn(d, fmt, arg...) \
1267 do { \
1268 if (d) \
1269 dev_warn(d, "%s: " fmt "\n", __func__, ##arg); \
1270 } while (0)
1271
1272
1273#define gk20a_dbg_fn(fmt, arg...) \
1274 gk20a_dbg(gpu_dbg_fn, fmt, ##arg)
1275
1276#define gk20a_dbg_info(fmt, arg...) \
1277 gk20a_dbg(gpu_dbg_info, fmt, ##arg)
1278
1279void gk20a_init_clk_ops(struct gpu_ops *gops); 1206void gk20a_init_clk_ops(struct gpu_ops *gops);
1280 1207
1281/* register accessors */ 1208/* register accessors */
diff --git a/drivers/gpu/nvgpu/gp10b/cde_gp10b.c b/drivers/gpu/nvgpu/gp10b/cde_gp10b.c
index 56700211..5f68de5a 100644
--- a/drivers/gpu/nvgpu/gp10b/cde_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/cde_gp10b.c
@@ -129,9 +129,9 @@ static int gp10b_populate_scatter_buffer(struct gk20a *g,
129 if ((page & 7) != 0) 129 if ((page & 7) != 0)
130 scatter_buffer[page >> 3] = d; 130 scatter_buffer[page >> 3] = d;
131 131
132 if (unlikely(gpu_dbg_cde & gk20a_dbg_mask)) { 132 if (nvgpu_log_mask_enabled(g, gpu_dbg_cde)) {
133 gk20a_dbg(gpu_dbg_cde, "scatterBuffer content:"); 133 gk20a_dbg(gpu_dbg_cde, "scatterBuffer content:");
134 for (i=0; i < page>>3; i++) { 134 for (i = 0; i < page >> 3; i++) {
135 gk20a_dbg(gpu_dbg_cde, " %x", scatter_buffer[i]); 135 gk20a_dbg(gpu_dbg_cde, " %x", scatter_buffer[i]);
136 } 136 }
137 } 137 }
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"