summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2016-07-08 15:15:59 -0400
committerAlex Waterman <alexw@nvidia.com>2016-07-19 14:32:30 -0400
commitf99e05006f9f60b6d0bb5c05a5cdddf5fea4cc81 (patch)
treed91e0c31a2c347044f051e60f32cde6f37bebc8b /drivers/gpu/nvgpu/gk20a/gk20a_allocator.h
parent0793de62b28bf8dcc655628129fd664862ac9909 (diff)
gpu: nvgpu: smarter debugging for allocators
Allow individual allocacators to be debugged without enabling debugging on all allocators. The ALLOCATOR_DEBUG define will still work as expected and enable debugging for all allocators that see this define. Change-Id: I0d59fa29affeaac15381e65d4128e7bef2f15bd5 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1178689 Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_allocator.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h
index a25f9850..5d6b9426 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.h
@@ -69,6 +69,7 @@ struct gk20a_allocator {
69 const struct gk20a_allocator_ops *ops; 69 const struct gk20a_allocator_ops *ops;
70 70
71 struct dentry *debugfs_entry; 71 struct dentry *debugfs_entry;
72 bool debug; /* Control for debug msgs. */
72}; 73};
73 74
74/* 75/*
@@ -124,9 +125,19 @@ void gk20a_alloc_print_stats(struct gk20a_allocator *a,
124void gk20a_init_alloc_debug(struct gk20a_allocator *a); 125void gk20a_init_alloc_debug(struct gk20a_allocator *a);
125void gk20a_fini_alloc_debug(struct gk20a_allocator *a); 126void gk20a_fini_alloc_debug(struct gk20a_allocator *a);
126int __gk20a_alloc_common_init(struct gk20a_allocator *a, 127int __gk20a_alloc_common_init(struct gk20a_allocator *a,
127 const char *name, void *priv, 128 const char *name, void *priv, bool dbg,
128 const struct gk20a_allocator_ops *ops); 129 const struct gk20a_allocator_ops *ops);
129 130
131static inline void gk20a_alloc_enable_dbg(struct gk20a_allocator *a)
132{
133 a->debug = true;
134}
135
136static inline void gk20a_alloc_disable_dbg(struct gk20a_allocator *a)
137{
138 a->debug = false;
139}
140
130/* 141/*
131 * Debug stuff. 142 * Debug stuff.
132 */ 143 */
@@ -154,12 +165,24 @@ void gk20a_alloc_debugfs_init(struct platform_device *pdev);
154 alloc_dbg(allocator, fmt, ##arg); \ 165 alloc_dbg(allocator, fmt, ##arg); \
155 } while (0) 166 } while (0)
156 167
168#define __alloc_dbg(a, fmt, arg...) \
169 pr_info("%-25s %25s() " fmt, (a)->name, __func__, ##arg)
170
157#if defined(ALLOCATOR_DEBUG) 171#if defined(ALLOCATOR_DEBUG)
158#define alloc_dbg(allocator, format, arg...) \ 172/*
159 pr_info("%-25s %25s() " format, \ 173 * Always print the debug messages...
160 allocator->name, __func__, ##arg) 174 */
175#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg)
161#else 176#else
162#define alloc_dbg(allocator, format, arg...) 177/*
178 * Only print debug messages if debug is enabled for a given allocator.
179 */
180#define alloc_dbg(a, fmt, arg...) \
181 do { \
182 if ((a)->debug) \
183 __alloc_dbg((a), fmt, ##arg); \
184 } while (0)
185
163#endif 186#endif
164 187
165#endif /* GK20A_ALLOCATOR_H */ 188#endif /* GK20A_ALLOCATOR_H */