summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
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
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')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator.h33
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c2
3 files changed, 31 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c
index b7e9a5e4..25d15d0f 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c
@@ -86,7 +86,7 @@ void gk20a_alloc_destroy(struct gk20a_allocator *a)
86 * Handle the common init stuff for a gk20a_allocator. 86 * Handle the common init stuff for a gk20a_allocator.
87 */ 87 */
88int __gk20a_alloc_common_init(struct gk20a_allocator *a, 88int __gk20a_alloc_common_init(struct gk20a_allocator *a,
89 const char *name, void *priv, 89 const char *name, void *priv, bool dbg,
90 const struct gk20a_allocator_ops *ops) 90 const struct gk20a_allocator_ops *ops)
91{ 91{
92 if (!ops) 92 if (!ops)
@@ -94,6 +94,7 @@ int __gk20a_alloc_common_init(struct gk20a_allocator *a,
94 94
95 a->ops = ops; 95 a->ops = ops;
96 a->priv = priv; 96 a->priv = priv;
97 a->debug = dbg;
97 98
98 mutex_init(&a->lock); 99 mutex_init(&a->lock);
99 100
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 */
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c
index c006480b..97605800 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c
@@ -1119,7 +1119,7 @@ int __gk20a_buddy_allocator_init(struct gk20a_allocator *__a,
1119 if (!a) 1119 if (!a)
1120 return -ENOMEM; 1120 return -ENOMEM;
1121 1121
1122 err = __gk20a_alloc_common_init(__a, name, a, &buddy_ops); 1122 err = __gk20a_alloc_common_init(__a, name, a, false, &buddy_ops);
1123 if (err) 1123 if (err)
1124 goto fail; 1124 goto fail;
1125 1125