mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
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>
This commit is contained in:
@@ -69,6 +69,7 @@ struct gk20a_allocator {
|
||||
const struct gk20a_allocator_ops *ops;
|
||||
|
||||
struct dentry *debugfs_entry;
|
||||
bool debug; /* Control for debug msgs. */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -124,9 +125,19 @@ void gk20a_alloc_print_stats(struct gk20a_allocator *a,
|
||||
void gk20a_init_alloc_debug(struct gk20a_allocator *a);
|
||||
void gk20a_fini_alloc_debug(struct gk20a_allocator *a);
|
||||
int __gk20a_alloc_common_init(struct gk20a_allocator *a,
|
||||
const char *name, void *priv,
|
||||
const char *name, void *priv, bool dbg,
|
||||
const struct gk20a_allocator_ops *ops);
|
||||
|
||||
static inline void gk20a_alloc_enable_dbg(struct gk20a_allocator *a)
|
||||
{
|
||||
a->debug = true;
|
||||
}
|
||||
|
||||
static inline void gk20a_alloc_disable_dbg(struct gk20a_allocator *a)
|
||||
{
|
||||
a->debug = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Debug stuff.
|
||||
*/
|
||||
@@ -154,12 +165,24 @@ void gk20a_alloc_debugfs_init(struct platform_device *pdev);
|
||||
alloc_dbg(allocator, fmt, ##arg); \
|
||||
} while (0)
|
||||
|
||||
#define __alloc_dbg(a, fmt, arg...) \
|
||||
pr_info("%-25s %25s() " fmt, (a)->name, __func__, ##arg)
|
||||
|
||||
#if defined(ALLOCATOR_DEBUG)
|
||||
#define alloc_dbg(allocator, format, arg...) \
|
||||
pr_info("%-25s %25s() " format, \
|
||||
allocator->name, __func__, ##arg)
|
||||
/*
|
||||
* Always print the debug messages...
|
||||
*/
|
||||
#define alloc_dbg(a, fmt, arg...) __alloc_dbg(a, fmt, ##arg)
|
||||
#else
|
||||
#define alloc_dbg(allocator, format, arg...)
|
||||
/*
|
||||
* Only print debug messages if debug is enabled for a given allocator.
|
||||
*/
|
||||
#define alloc_dbg(a, fmt, arg...) \
|
||||
do { \
|
||||
if ((a)->debug) \
|
||||
__alloc_dbg((a), fmt, ##arg); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* GK20A_ALLOCATOR_H */
|
||||
|
||||
Reference in New Issue
Block a user