drm/nouveau: create module debugfs root

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
This commit is contained in:
Danilo Krummrich 2024-11-25 15:25:49 +01:00
parent c6eabbab35
commit 97118a1816
3 changed files with 51 additions and 3 deletions

View 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);
}

View 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

View 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 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
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);