summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-08-21 16:29:46 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-08-28 11:54:36 -0400
commit8f2f979428e1e5a4ff71d91e30ba17813e6ee7be (patch)
treedd7ce212363bea8b3547811109f01b2397804613 /drivers/gpu/nvgpu/include
parentc49160127acfa5a9f550ecfa2d61c054060dbab3 (diff)
gpu: nvgpu: cleanup allocator debugging
Remove debugging features that did not really get used and make the debugging code use the nvgpu_log() functionality. This ties the allocator debugging into the larger nvgpu debug framework. Also modify many of the places CONFIG_DEBUG_FS was used to conditionally compile allocator debug code to use __KERNEL__ instead. This is because that debug code can still be called even when debugfs is not present in Linux. Change-Id: I112ebe1cae22d6f8db96d023993498093e18d74a Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1544439 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/allocator.h49
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/log.h1
2 files changed, 30 insertions, 20 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/allocator.h b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
index 30bfa750..ac8a0645 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/allocator.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/allocator.h
@@ -17,8 +17,16 @@
17#ifndef __NVGPU_ALLOCATOR_H__ 17#ifndef __NVGPU_ALLOCATOR_H__
18#define __NVGPU_ALLOCATOR_H__ 18#define __NVGPU_ALLOCATOR_H__
19 19
20#ifdef __KERNEL__
21/*
22 * The Linux kernel has this notion of seq_files for printing info to userspace.
23 * One of the allocator function pointers takes advantage of this and allows the
24 * debug output to be directed either to nvgpu_log() or a seq_file.
25 */
20#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#endif
21 28
29#include <nvgpu/log.h>
22#include <nvgpu/lock.h> 30#include <nvgpu/lock.h>
23#include <nvgpu/list.h> 31#include <nvgpu/list.h>
24 32
@@ -72,7 +80,7 @@ struct nvgpu_allocator_ops {
72 /* Destructor. */ 80 /* Destructor. */
73 void (*fini)(struct nvgpu_allocator *allocator); 81 void (*fini)(struct nvgpu_allocator *allocator);
74 82
75#ifdef CONFIG_DEBUG_FS 83#ifdef __KERNEL__
76 /* Debugging. */ 84 /* Debugging. */
77 void (*print_stats)(struct nvgpu_allocator *allocator, 85 void (*print_stats)(struct nvgpu_allocator *allocator,
78 struct seq_file *s, int lock); 86 struct seq_file *s, int lock);
@@ -246,7 +254,7 @@ u64 nvgpu_alloc_space(struct nvgpu_allocator *a);
246 254
247void nvgpu_alloc_destroy(struct nvgpu_allocator *allocator); 255void nvgpu_alloc_destroy(struct nvgpu_allocator *allocator);
248 256
249#ifdef CONFIG_DEBUG_FS 257#ifdef __KERNEL__
250void nvgpu_alloc_print_stats(struct nvgpu_allocator *a, 258void nvgpu_alloc_print_stats(struct nvgpu_allocator *a,
251 struct seq_file *s, int lock); 259 struct seq_file *s, int lock);
252#endif 260#endif
@@ -281,35 +289,36 @@ static inline void nvgpu_alloc_disable_dbg(struct nvgpu_allocator *a)
281/* 289/*
282 * Debug stuff. 290 * Debug stuff.
283 */ 291 */
292#ifdef __KERNEL__
284#define __alloc_pstat(seq, allocator, fmt, arg...) \ 293#define __alloc_pstat(seq, allocator, fmt, arg...) \
285 do { \ 294 do { \
286 if (s) \ 295 if (seq) \
287 seq_printf(seq, fmt, ##arg); \ 296 seq_printf(seq, fmt, ##arg); \
288 else \ 297 else \
289 alloc_dbg(allocator, fmt, ##arg); \ 298 alloc_dbg(allocator, fmt, ##arg); \
290 } while (0) 299 } while (0)
300#endif
291 301
292#define __alloc_dbg(a, fmt, arg...) \ 302#define __alloc_dbg(a, fmt, arg...) \
293 pr_info("%-25s %25s() " fmt, (a)->name, __func__, ##arg) 303 nvgpu_log((a)->g, gpu_dbg_alloc, "%25s " fmt, (a)->name, ##arg)
294 304
295#if defined(ALLOCATOR_DEBUG)
296/* 305/*
297 * Always print the debug messages... 306 * This gives finer control over debugging messages. By defining the
298 */ 307 * ALLOCATOR_DEBUG macro prints for an allocator will only get made if
299#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg) 308 * that allocator's debug flag is set.
300#else 309 *
301/* 310 * Otherwise debugging is as normal: debug statements for all allocators
302 * Only print debug messages if debug is enabled for a given allocator. 311 * if the GPU debugging mask bit is set. Note: even when ALLOCATOR_DEBUG
312 * is set gpu_dbg_alloc must still also be set to true.
303 */ 313 */
304#define alloc_dbg(a, fmt, arg...) \ 314#if defined(ALLOCATOR_DEBUG)
305 do { \ 315#define alloc_dbg(a, fmt, arg...) \
306 if ((a)->debug) \ 316 do { \
307 __alloc_dbg((a), fmt, ##arg); \ 317 if ((a)->debug) \
318 __alloc_dbg((a), fmt, ##arg); \
308 } while (0) 319 } while (0)
309 320#else
321#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg)
310#endif 322#endif
311#define balloc_pr(alloctor, format, arg...) \
312 pr_info("%-25s %25s() " format, \
313 alloctor->name, __func__, ##arg)
314 323
315#endif /* NVGPU_ALLOCATOR_H */ 324#endif /* NVGPU_ALLOCATOR_H */
diff --git a/drivers/gpu/nvgpu/include/nvgpu/log.h b/drivers/gpu/nvgpu/include/nvgpu/log.h
index a1110a59..11e6dacb 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/log.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/log.h
@@ -69,6 +69,7 @@ enum nvgpu_log_categories {
69 gpu_dbg_shutdown = BIT(18), /* GPU shutdown tracing. */ 69 gpu_dbg_shutdown = BIT(18), /* GPU shutdown tracing. */
70 gpu_dbg_kmem = BIT(19), /* Kmem tracking debugging. */ 70 gpu_dbg_kmem = BIT(19), /* Kmem tracking debugging. */
71 gpu_dbg_pd_cache = BIT(20), /* PD cache traces. */ 71 gpu_dbg_pd_cache = BIT(20), /* PD cache traces. */
72 gpu_dbg_alloc = BIT(21), /* Allocator debugging. */
72 gpu_dbg_mem = BIT(31), /* memory accesses; very verbose. */ 73 gpu_dbg_mem = BIT(31), /* memory accesses; very verbose. */
73}; 74};
74 75