aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/linux/log.c
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-09-25 16:09:09 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2024-09-25 16:09:09 -0400
commitf347fde22f1297e4f022600d201780d5ead78114 (patch)
tree76be305d6187003a1e0486ff6e91efb1062ae118 /include/os/linux/log.c
parent8340d234d78a7d0f46c11a584de538148b78b7cb (diff)
Delete no-longer-needed nvgpu headersHEADmasterjbakita-wip
The dependency on these was removed in commit 8340d234.
Diffstat (limited to 'include/os/linux/log.c')
-rw-r--r--include/os/linux/log.c132
1 files changed, 0 insertions, 132 deletions
diff --git a/include/os/linux/log.c b/include/os/linux/log.c
deleted file mode 100644
index bd9f67d..0000000
--- a/include/os/linux/log.c
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * Copyright (c) 2017-2018, 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#include <nvgpu/gk20a.h>
22
23#include "platform_gk20a.h"
24#include "os_linux.h"
25
26/*
27 * Define a length for log buffers. This is the buffer that the 'fmt, ...' part
28 * of __nvgpu_do_log_print() prints into. This buffer lives on the stack so it
29 * needs to not be overly sized since we have limited kernel stack space. But at
30 * the same time we don't want it to be restrictive either.
31 */
32#define LOG_BUFFER_LENGTH 160
33
34/*
35 * Annoying quirk of Linux: this has to be a string literal since the printk()
36 * function and friends use the preprocessor to concatenate stuff to the start
37 * of this string when printing.
38 */
39#define LOG_FMT "nvgpu: %s %33s:%-4d [%s] %s\n"
40
41static const char *log_types[] = {
42 "ERR",
43 "WRN",
44 "DBG",
45 "INFO",
46};
47
48int nvgpu_log_mask_enabled(struct gk20a *g, u64 log_mask)
49{
50 return !!(g->log_mask & log_mask);
51}
52
53static inline const char *nvgpu_log_name(struct gk20a *g)
54{
55 return dev_name(dev_from_gk20a(g));
56}
57
58#ifdef CONFIG_GK20A_TRACE_PRINTK
59static void __nvgpu_trace_printk_log(u32 trace, const char *gpu_name,
60 const char *func_name, int line,
61 const char *log_type, const char *log)
62{
63 trace_printk(LOG_FMT, gpu_name, func_name, line, log_type, log);
64}
65#endif
66
67static void __nvgpu_really_print_log(u32 trace, const char *gpu_name,
68 const char *func_name, int line,
69 enum nvgpu_log_type type, const char *log)
70{
71 const char *name = gpu_name ? gpu_name : "";
72 const char *log_type = log_types[type];
73
74#ifdef CONFIG_GK20A_TRACE_PRINTK
75 if (trace)
76 return __nvgpu_trace_printk_log(trace, name, func_name,
77 line, log_type, log);
78#endif
79 switch (type) {
80 case NVGPU_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 NVGPU_INFO:
89 pr_info(LOG_FMT, name, func_name, line, log_type, log);
90 break;
91 case NVGPU_WARNING:
92 pr_warn(LOG_FMT, name, func_name, line, log_type, log);
93 break;
94 case NVGPU_ERROR:
95 pr_err(LOG_FMT, name, func_name, line, log_type, log);
96 break;
97 }
98}
99
100__attribute__((format (printf, 5, 6)))
101void __nvgpu_log_msg(struct gk20a *g, const char *func_name, int line,
102 enum nvgpu_log_type type, const char *fmt, ...)
103{
104 char log[LOG_BUFFER_LENGTH];
105 va_list args;
106
107 va_start(args, fmt);
108 vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args);
109 va_end(args);
110
111 __nvgpu_really_print_log(0, g ? nvgpu_log_name(g) : "",
112 func_name, line, type, log);
113}
114
115__attribute__((format (printf, 5, 6)))
116void __nvgpu_log_dbg(struct gk20a *g, u64 log_mask,
117 const char *func_name, int line,
118 const char *fmt, ...)
119{
120 char log[LOG_BUFFER_LENGTH];
121 va_list args;
122
123 if ((log_mask & g->log_mask) == 0)
124 return;
125
126 va_start(args, fmt);
127 vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args);
128 va_end(args);
129
130 __nvgpu_really_print_log(g->log_trace, nvgpu_log_name(g),
131 func_name, line, NVGPU_DEBUG, log);
132}