@@ -2765,6 +2765,8 @@ static int __init amdgpu_init(void)
if (r)
goto error_fence;
+ dynamic_debug_register_classes(&drm_debug_classes);
+
DRM_INFO("amdgpu kernel modesetting enabled.\n");
amdgpu_register_atpx_handler();
amdgpu_acpi_detect();
@@ -2787,6 +2789,7 @@ static void __exit amdgpu_exit(void)
amdgpu_amdkfd_fini();
pci_unregister_driver(&amdgpu_kms_pci_driver);
amdgpu_unregister_atpx_handler();
+ dynamic_debug_unregister_classes(&drm_debug_classes);
amdgpu_sync_fini();
amdgpu_fence_slab_fini();
mmu_notifier_synchronize();
@@ -1045,6 +1045,8 @@ static int __init drm_core_init(void)
{
int ret;
+ dynamic_debug_register_classes(&drm_debug_classes);
+
drm_connector_ida_init();
idr_init(&drm_minors_idr);
drm_memcpy_init_early();
@@ -44,10 +44,21 @@ static int i915_check_nomodeset(void)
return 0;
}
+static int i915_ddebug_classes_register(void)
+{
+ return dynamic_debug_register_classes(&drm_debug_classes);
+}
+static void i915_ddebug_classes_unregister(void)
+{
+ dynamic_debug_unregister_classes(&drm_debug_classes);
+}
+
static const struct {
int (*init)(void);
void (*exit)(void);
} init_funcs[] = {
+ { .init = i915_ddebug_classes_register,
+ .exit = i915_ddebug_classes_unregister },
{ .init = i915_check_nomodeset },
{ .init = i915_active_module_init,
.exit = i915_active_module_exit },
@@ -1355,6 +1355,8 @@ nouveau_drm_init(void)
driver_pci = driver_stub;
driver_platform = driver_stub;
+ dynamic_debug_register_classes(&drm_debug_classes);
+
nouveau_display_options();
if (nouveau_modeset == -1) {
@@ -1391,6 +1393,8 @@ nouveau_drm_exit(void)
nouveau_backlight_dtor();
nouveau_unregister_dsm_handler();
+ dynamic_debug_unregister_classes(&drm_debug_classes);
+
#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
platform_driver_unregister(&nouveau_platform_driver);
#endif
@@ -29,6 +29,7 @@
#include <linux/list.h>
#include <linux/irqreturn.h>
+#include <linux/dynamic_debug.h>
#include <drm/drm_device.h>
@@ -43,6 +44,19 @@ struct drm_mode_create_dumb;
struct drm_printer;
struct sg_table;
+/* these must comport with enum drm_debug_category values */
+DYNAMIC_DEBUG_CLASSES(drm_debug_classes, "*", 0,
+ "DRM_UT_CORE",
+ "DRM_UT_DRIVER",
+ "DRM_UT_KMS",
+ "DRM_UT_PRIME",
+ "DRM_UT_ATOMIC",
+ "DRM_UT_VBL",
+ "DRM_UT_STATE",
+ "DRM_UT_LEASE",
+ "DRM_UT_DP",
+ "DRM_UT_DRMRES");
+
/**
* enum drm_driver_feature - feature flags
*
@@ -274,6 +274,10 @@ static inline struct drm_printer drm_err_printer(const char *prefix)
* # echo 0xf > /sys/module/drm/parameters/debug
*
*/
+/*
+ * These must be kept in sync with the class-names given in drm_drv.h
+ * DYNAMIC_DEBUG_CLASSES
+ */
enum drm_debug_category {
/**
* @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c,
Invoke DYNAMIC_DEBUG_CLASSES from drm_drv.h. This declares a maybe-unused struct ddebug_known_classes_map var, initialized with: . var: passed to dynamic_debug_register_classes() . class-names: "DRM_UT_CORE", "DRM_UT_DRIVER", "DRM_UT_KMS", etc. These names map to .class_id's by their index, ie: 0-30. Then in 4 test-case drm-drivers (drm, i915, amdgpu, nouveau); call dynamic_debug_register_classes(var). i915 also gets an adaptor func, and calls it 1st in the array of initialization helpers, since early logging might be valuable for diagnosing setup problems. Since these modules all use the same class-names, they all will respond together to class FOO changes: #> echo class DRM_UT_KMS +p > /proc/dynamic_debug/control NOTES: DRM uses enum drm_debug_category across modules and common core, so our class-names => index map must apply across them too, hence drm_drv.h invokes the macro once for everyone. DRM's enum drm_debug_category values need to sync with the index of their respective class-names here. Then .class_id == category, and dyndbg's class FOO mechanisms will work. Once enum drm_debug_category is naturalized (value inits dropped, yielding 0..N), then this condition holds true: assert(!strcmp(classes[DRM_UT_KMS],"DRM_UT_KMS")); Though DRM needs consistent categories across all modules, thats not generally needed; modules X and Y could define FOO differently (ie different corresponding .class_id) and things would work. No callsites are actually selected here, since none are class'd yet. bash-5.1# dmesg | grep register_class [ 7.095579] dyndbg: register_classes: drm [ 7.557109] dyndbg: register_classes: i915 [ 8.096818] dyndbg: register_classes: amdgpu Signed-off-by: Jim Cromie <jim.cromie@gmail.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +++ drivers/gpu/drm/drm_drv.c | 2 ++ drivers/gpu/drm/i915/i915_module.c | 11 +++++++++++ drivers/gpu/drm/nouveau/nouveau_drm.c | 4 ++++ include/drm/drm_drv.h | 14 ++++++++++++++ include/drm/drm_print.h | 4 ++++ 6 files changed, 38 insertions(+)