Skip to content

Commit 97118a1

Browse files
author
Danilo Krummrich
committed
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 <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c6eabba commit 97118a1

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

drivers/gpu/drm/nouveau/nouveau_debugfs.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,19 @@ nouveau_debugfs_fini(struct nouveau_drm *drm)
313313
kfree(drm->debugfs);
314314
drm->debugfs = NULL;
315315
}
316+
317+
int
318+
nouveau_module_debugfs_init(void)
319+
{
320+
nouveau_debugfs_root = debugfs_create_dir("nouveau", NULL);
321+
if (IS_ERR(nouveau_debugfs_root))
322+
return PTR_ERR(nouveau_debugfs_root);
323+
324+
return 0;
325+
}
326+
327+
void
328+
nouveau_module_debugfs_fini(void)
329+
{
330+
debugfs_remove(nouveau_debugfs_root);
331+
}

drivers/gpu/drm/nouveau/nouveau_debugfs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ nouveau_debugfs(struct drm_device *dev)
2121
extern void nouveau_drm_debugfs_init(struct drm_minor *);
2222
extern int nouveau_debugfs_init(struct nouveau_drm *);
2323
extern void nouveau_debugfs_fini(struct nouveau_drm *);
24+
25+
extern struct dentry *nouveau_debugfs_root;
26+
27+
int nouveau_module_debugfs_init(void);
28+
void nouveau_module_debugfs_fini(void);
2429
#else
2530
static inline void
2631
nouveau_drm_debugfs_init(struct drm_minor *minor)
@@ -37,6 +42,17 @@ nouveau_debugfs_fini(struct nouveau_drm *drm)
3742
{
3843
}
3944

45+
static inline int
46+
nouveau_module_debugfs_init(void)
47+
{
48+
return 0;
49+
}
50+
51+
static inline void
52+
nouveau_module_debugfs_fini(void)
53+
{
54+
}
55+
4056
#endif
4157

4258
#endif

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ static struct drm_driver driver_stub;
113113
static struct drm_driver driver_pci;
114114
static struct drm_driver driver_platform;
115115

116+
#ifdef CONFIG_DEBUG_FS
117+
struct dentry *nouveau_debugfs_root;
118+
#endif
119+
116120
static u64
117121
nouveau_pci_name(struct pci_dev *pdev)
118122
{
@@ -1423,6 +1427,8 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
14231427
static int __init
14241428
nouveau_drm_init(void)
14251429
{
1430+
int ret;
1431+
14261432
driver_pci = driver_stub;
14271433
driver_platform = driver_stub;
14281434

@@ -1436,6 +1442,10 @@ nouveau_drm_init(void)
14361442
if (!nouveau_modeset)
14371443
return 0;
14381444

1445+
ret = nouveau_module_debugfs_init();
1446+
if (ret)
1447+
return ret;
1448+
14391449
#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
14401450
platform_driver_register(&nouveau_platform_driver);
14411451
#endif
@@ -1444,10 +1454,14 @@ nouveau_drm_init(void)
14441454
nouveau_backlight_ctor();
14451455

14461456
#ifdef CONFIG_PCI
1447-
return pci_register_driver(&nouveau_drm_pci_driver);
1448-
#else
1449-
return 0;
1457+
ret = pci_register_driver(&nouveau_drm_pci_driver);
1458+
if (ret) {
1459+
nouveau_module_debugfs_fini();
1460+
return ret;
1461+
}
14501462
#endif
1463+
1464+
return 0;
14511465
}
14521466

14531467
static void __exit
@@ -1467,6 +1481,8 @@ nouveau_drm_exit(void)
14671481
#endif
14681482
if (IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM))
14691483
mmu_notifier_synchronize();
1484+
1485+
nouveau_module_debugfs_fini();
14701486
}
14711487

14721488
module_init(nouveau_drm_init);

0 commit comments

Comments
 (0)