[PATCH v10 03/10] amdgpu: use dyndbg.BITGRPS to control existing pr_debugs
From: Jim Cromie
Date: Fri Nov 05 2021 - 15:27:19 EST
logger_types.h defines many DC_LOG_*() categorized debug wrappers.
Most of these already use DRM debug API, so are controllable using
drm.debug, but others use a bare pr_debug("$prefix: .."), with 1 of 13
different class-prefixes matching [:uppercase:]
Use DEFINE_DYNAMIC_DEBUG_BITGRPS to create a sysfs location which maps
from bits to these 13 sets of categorized pr_debugs to en/disable.
Makefile adds -DDYNAMIC_DEBUG_MODULE for CONFIG_DYNAMIC_DEBUG_CORE,
otherwise BUILD_BUG_ON triggers (obvious errors on subtle misuse is
better than mysterious ones).
Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/Makefile | 2 +
.../gpu/drm/amd/display/dc/core/dc_debug.c | 47 ++++++++++++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index 653726588956..077342ca803f 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -38,6 +38,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
-I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
-I$(FULL_AMD_PATH)/amdkfd
+ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DYNAMIC_DEBUG_MODULE
+
amdgpu-y := amdgpu_drv.o
# add KMS driver
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_debug.c b/drivers/gpu/drm/amd/display/dc/core/dc_debug.c
index 21be2a684393..e49a755c6a69 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_debug.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_debug.c
@@ -36,8 +36,53 @@
#include "resource.h"
-#define DC_LOGGER_INIT(logger)
+#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG)
+#include <linux/dynamic_debug.h>
+
+unsigned long __debug_dc;
+EXPORT_SYMBOL(__debug_dc);
+
+#define help_(_N, _cat) "\t Bit-" #_N "\t" _cat "\n"
+
+#define DC_DYNDBG_BITMAP_DESC(name) \
+ "Control pr_debugs via /sys/module/amdgpu/parameters/" #name \
+ ", where each bit controls a debug category.\n" \
+ help_(0, "[SURFACE]:") \
+ help_(1, "[CURSOR]:") \
+ help_(2, "[PFLIP]:") \
+ help_(3, "[VBLANK]:") \
+ help_(4, "[HW_LINK_TRAINING]:") \
+ help_(5, "[HW_AUDIO]:") \
+ help_(6, "[SCALER]:") \
+ help_(7, "[BIOS]:") \
+ help_(8, "[BANDWIDTH_CALCS]:") \
+ help_(9, "[DML]:") \
+ help_(10, "[IF_TRACE]:") \
+ help_(11, "[GAMMA]:") \
+ help_(12, "[SMU_MSG]:")
+
+static struct dyndbg_bitdesc amdgpu_bitmap[] = {
+ [0] = { "[CURSOR]:" },
+ [1] = { "[PFLIP]:" },
+ [2] = { "[VBLANK]:" },
+ [3] = { "[HW_LINK_TRAINING]:" },
+ [4] = { "[HW_AUDIO]:" },
+ [5] = { "[SCALER]:" },
+ [6] = { "[BIOS]:" },
+ [7] = { "[BANDWIDTH_CALCS]:" },
+ [8] = { "[DML]:" },
+ [9] = { "[IF_TRACE]:" },
+ [10] = { "[GAMMA]:" },
+ [11] = { "[SMU_MSG]:" }
+};
+
+DEFINE_DYNAMIC_DEBUG_LOG_GROUPS(debug_dc, __debug_dc,
+ DC_DYNDBG_BITMAP_DESC(debug_dc),
+ amdgpu_bitmap);
+
+#endif
+#define DC_LOGGER_INIT(logger)
#define SURFACE_TRACE(...) do {\
if (dc->debug.surface_trace) \
--
2.31.1