]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/nouveau: create module debugfs root
authorDanilo Krummrich <dakr@kernel.org>
Mon, 25 Nov 2024 14:25:49 +0000 (15:25 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Wed, 4 Dec 2024 20:43:46 +0000 (21:43 +0100)
Typically DRM drivers use the DRM debugfs root entry. However, since
Nouveau is heading towards a split into a core and a DRM driver, create
a module specific debugfs root directory.

Subsequent patches make use of this new debugfs root in order to store
GSP-RM log bufferes (optionally beyond a device driver binding).

Acked-by: Timur Tabi <ttabi@nvidia.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241125142639.9126-1-dakr@kernel.org
drivers/gpu/drm/nouveau/nouveau_debugfs.c
drivers/gpu/drm/nouveau/nouveau_debugfs.h
drivers/gpu/drm/nouveau/nouveau_drm.c

index e83db051e8515a0b4624cedbac432ef905d611ed..200e65a7cefc4ec19e0be7eb3a51bfa5847bd0c3 100644 (file)
@@ -313,3 +313,19 @@ nouveau_debugfs_fini(struct nouveau_drm *drm)
        kfree(drm->debugfs);
        drm->debugfs = NULL;
 }
+
+int
+nouveau_module_debugfs_init(void)
+{
+       nouveau_debugfs_root = debugfs_create_dir("nouveau", NULL);
+       if (IS_ERR(nouveau_debugfs_root))
+               return PTR_ERR(nouveau_debugfs_root);
+
+       return 0;
+}
+
+void
+nouveau_module_debugfs_fini(void)
+{
+       debugfs_remove(nouveau_debugfs_root);
+}
index 77f0323b38ba8cb7b20822a3b98866509e60c46f..b7617b344ee26dbe5ea3724ba3bb6091c606bd1d 100644 (file)
@@ -21,6 +21,11 @@ nouveau_debugfs(struct drm_device *dev)
 extern void  nouveau_drm_debugfs_init(struct drm_minor *);
 extern int  nouveau_debugfs_init(struct nouveau_drm *);
 extern void nouveau_debugfs_fini(struct nouveau_drm *);
+
+extern struct dentry *nouveau_debugfs_root;
+
+int  nouveau_module_debugfs_init(void);
+void nouveau_module_debugfs_fini(void);
 #else
 static inline void
 nouveau_drm_debugfs_init(struct drm_minor *minor)
@@ -37,6 +42,17 @@ nouveau_debugfs_fini(struct nouveau_drm *drm)
 {
 }
 
+static inline int
+nouveau_module_debugfs_init(void)
+{
+       return 0;
+}
+
+static inline void
+nouveau_module_debugfs_fini(void)
+{
+}
+
 #endif
 
 #endif
index a99c1d9855c944d5472eff2c64d70b8d14b9d6a0..911c57a0654ef5e6822a9829e18334bd40ccacd8 100644 (file)
@@ -113,6 +113,10 @@ static struct drm_driver driver_stub;
 static struct drm_driver driver_pci;
 static struct drm_driver driver_platform;
 
+#ifdef CONFIG_DEBUG_FS
+struct dentry *nouveau_debugfs_root;
+#endif
+
 static u64
 nouveau_pci_name(struct pci_dev *pdev)
 {
@@ -1423,6 +1427,8 @@ err_free:
 static int __init
 nouveau_drm_init(void)
 {
+       int ret;
+
        driver_pci = driver_stub;
        driver_platform = driver_stub;
 
@@ -1436,6 +1442,10 @@ nouveau_drm_init(void)
        if (!nouveau_modeset)
                return 0;
 
+       ret = nouveau_module_debugfs_init();
+       if (ret)
+               return ret;
+
 #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
        platform_driver_register(&nouveau_platform_driver);
 #endif
@@ -1444,10 +1454,14 @@ nouveau_drm_init(void)
        nouveau_backlight_ctor();
 
 #ifdef CONFIG_PCI
-       return pci_register_driver(&nouveau_drm_pci_driver);
-#else
-       return 0;
+       ret = pci_register_driver(&nouveau_drm_pci_driver);
+       if (ret) {
+               nouveau_module_debugfs_fini();
+               return ret;
+       }
 #endif
+
+       return 0;
 }
 
 static void __exit
@@ -1467,6 +1481,8 @@ nouveau_drm_exit(void)
 #endif
        if (IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM))
                mmu_notifier_synchronize();
+
+       nouveau_module_debugfs_fini();
 }
 
 module_init(nouveau_drm_init);