diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator.h | 33 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c | 2 |
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 | */ |
88 | int __gk20a_alloc_common_init(struct gk20a_allocator *a, | 88 | int __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, | |||
124 | void gk20a_init_alloc_debug(struct gk20a_allocator *a); | 125 | void gk20a_init_alloc_debug(struct gk20a_allocator *a); |
125 | void gk20a_fini_alloc_debug(struct gk20a_allocator *a); | 126 | void gk20a_fini_alloc_debug(struct gk20a_allocator *a); |
126 | int __gk20a_alloc_common_init(struct gk20a_allocator *a, | 127 | int __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 | ||
131 | static inline void gk20a_alloc_enable_dbg(struct gk20a_allocator *a) | ||
132 | { | ||
133 | a->debug = true; | ||
134 | } | ||
135 | |||
136 | static 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 | ||