drm/ttm: fix debugfs node create failed
Subsystems (3)
PATCH 1/1 drm/ttm: fix debugfs node create failed
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu
Error log:
[ 54.396807] debugfs: File 'page_pool' in directory 'amdttm' already present!
[ 54.396833] debugfs: File 'page_pool_shrink' in directory 'amdttm' already present!
[ 54.396848] debugfs: File 'buffer_objects' in directory 'amdttm' already present!Reason:
page_pool, page_pool_shrink and buffer_objects can be removed when rmmod amdttm, in the above test scenario only rmmod amdgpu, so those debugfs node will not be removed, this caused file create failed.
Soultion:
create ttm_page directory under ttm_root directory when insmod amdgpu, page_pool, page_pool_shrink and buffer_objects are stored in ttm_page directiry, remove ttm_page directory when do rmmod amdgpu, this can fix above issue.
--- drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_device.c +11 -1
@@ -55,6 +55,10 @@ static void ttm_global_release(void)ttm_pool_mgr_fini (); +#ifdef CONFIG_DEBUG_FS +debugfs_remove (ttm_debugfs_page); +#endif +__free_page (glob->dummy_read_page);memset (glob,0 ,sizeof (*glob)); out:
@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 =min (num_dma32,2UL << (30 -PAGE_SHIFT )); +#ifdef CONFIG_DEBUG_FS + ttm_debugfs_page =debugfs_create_dir ("ttm_page" , ttm_debugfs_root); +#endif +ttm_pool_mgr_init (num_pages);ttm_tt_mgr_init (num_pages, num_dma32);
@@ -98,8 +106,10 @@ static int ttm_global_init(void)INIT_LIST_HEAD (&glob->device_list);atomic_set (&glob->bo_count,0 ); -debugfs_create_atomic_t ("buffer_objects" ,0444 , ttm_debugfs_root, +#ifdef CONFIG_DEBUG_FS +debugfs_create_atomic_t ("buffer_objects" ,0444 , ttm_debugfs_page, &glob->bo_count); +#endif out:mutex_unlock (&ttm_global_mutex);return ret;
drivers/gpu/drm/ttm/ttm_module.c +1 -0
@@ -38,6 +38,7 @@#include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page;static int __init ttm_init (void ) {
drivers/gpu/drm/ttm/ttm_module.h +1 -0
@@ -36,5 +36,6 @@struct dentry ;extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page;#endif /* _TTM_MODULE_H_ */
drivers/gpu/drm/ttm/ttm_pool.c +2 -2
@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long num_pages) }#ifdef CONFIG_DEBUG_FS -debugfs_create_file ("page_pool" ,0444 , ttm_debugfs_root,NULL , +debugfs_create_file ("page_pool" ,0444 , ttm_debugfs_page,NULL , &ttm_pool_debugfs_globals_fops); -debugfs_create_file ("page_pool_shrink" ,0400 , ttm_debugfs_root,NULL , +debugfs_create_file ("page_pool_shrink" ,0400 , ttm_debugfs_page,NULL , &ttm_pool_debugfs_shrink_fops);#endif
Signature · 1 line
2.17.1
Quoted 6 lines · Stanley.Yang
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu Error log: [ 54.396807] debugfs: File 'page_pool' in directory 'amdttm' already present! [ 54.396833] debugfs: File 'page_pool_shrink' in directory 'amdttm' already present! [ 54.396848] debugfs: File 'buffer_objects' in directory 'amdttm' already present!
We should instead add a check if those debugfs files already exist/created in ttm debugfs dir using debugfs_lookup() before creating.
Regards,
Nirmoy
Quoted 94 lines
Reason:
page_pool,page_pool_shrinkandbuffer_objectscan be removed when rmmod amdttm, in the above test scenario only rmmod amdgpu, so those debugfs node will not be removed, this caused file create failed.
Soultion:
createttm_pagedirectory underttm_rootdirectory when insmod amdgpu,page_pool,page_pool_shrinkandbuffer_objectsare stored inttm_pagedirectiry, removettm_pagedirectory when do rmmod amdgpu, this can fix above issue.Signed-off-by Stanley.Yang <[email protected]>--- drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +11
-1@@ -55,6 +55,10 @@ static void ttm_global_release(void)ttm_pool_mgr_fini (); +#ifdef CONFIG_DEBUG_FS +debugfs_remove (ttm_debugfs_page); +#endif +__free_page (glob->dummy_read_page);memset (glob,0 ,sizeof (*glob)); out:@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 =min (num_dma32,2UL << (30 -PAGE_SHIFT )); +#ifdef CONFIG_DEBUG_FS + ttm_debugfs_page =debugfs_create_dir ("ttm_page" , ttm_debugfs_root); +#endif +ttm_pool_mgr_init (num_pages);ttm_tt_mgr_init (num_pages, num_dma32);@@ -98,8 +106,10 @@ static int ttm_global_init(void)INIT_LIST_HEAD (&glob->device_list);atomic_set (&glob->bo_count,0 ); -debugfs_create_atomic_t ("buffer_objects" ,0444 , ttm_debugfs_root, +#ifdef CONFIG_DEBUG_FS +debugfs_create_atomic_t ("buffer_objects" ,0444 , ttm_debugfs_page, &glob->bo_count); +#endif out:mutex_unlock (&ttm_global_mutex);return ret;drivers/gpu/drm/ttm/ttm_module.c +1
-0@@ -38,6 +38,7 @@#include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page;static int __init ttm_init (void ) {drivers/gpu/drm/ttm/ttm_module.h +1
-0@@ -36,5 +36,6 @@struct dentry ;extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page;#endif /* _TTM_MODULE_H_ */ drivers/gpu/drm/ttm/ttm_pool.c +2
-2@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long num_pages) }#ifdef CONFIG_DEBUG_FS -debugfs_create_file ("page_pool" ,0444 , ttm_debugfs_root,NULL , +debugfs_create_file ("page_pool" ,0444 , ttm_debugfs_page,NULL , &ttm_pool_debugfs_globals_fops); -debugfs_create_file ("page_pool_shrink" ,0400 , ttm_debugfs_root,NULL , +debugfs_create_file ("page_pool_shrink" ,0400 , ttm_debugfs_page,NULL , &ttm_pool_debugfs_shrink_fops);#endif
Am 12.10.21 um 15:12 schrieb Das, Nirmoy:
Quoted 11 lines · Stanley.Yang
Quoted 6 lines
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu
Error log:
[ 54.396807] debugfs: File 'page_pool' in directory 'amdttm' already present! [ 54.396833] debugfs: File 'page_pool_shrink' in directory 'amdttm' already present! [ 54.396848] debugfs: File 'buffer_objects' in directory 'amdttm' already present!We should instead add a check if those debugfs files already exist/created in ttm debugfs dir using
debugfs_lookup()before creating.
No, IIRC the Intel guys had fixed that already by adding/removing the debugfs file on module load/unload.
Christian.
Quoted 94 lines
Regards,
Nirmoy
Quoted 86 lines
Reason:
page_pool,page_pool_shrinkandbuffer_objectscan be removed when rmmod amdttm, in the above test scenario only rmmod amdgpu, so those debugfs node will not be removed, this caused file create failed. Soultion:
createttm_pagedirectory underttm_rootdirectory when insmod amdgpu,page_pool,page_pool_shrinkandbuffer_objectsare stored inttm_pagedirectiry, removettm_pagedirectory when do rmmod amdgpu, this can fix above issue.Signed-off-by Stanley.Yang <[email protected]>---
drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +0
-0@@ -55,6 +55,10 @@ static void ttm_global_release(void) ttm_pool_mgr_fini();+#ifdef
CONFIG_DEBUG_FS
+debugfs_remove(ttm_debugfs_page);drivers/gpu/drm/ttm/ttm_device.c +2
-0+#endif +
__free_page(glob->dummy_read_page);
memset(glob, 0, sizeof(*glob));
out:drivers/gpu/drm/ttm/ttm_device.c +0
-0@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT));+#ifdef
CONFIG_DEBUG_FS
+ttm_debugfs_page=debugfs_create_dir("ttm_page", ttm_debugfs_root);drivers/gpu/drm/ttm/ttm_device.c +2
-0+#endif +
ttm_pool_mgr_init(num_pages);ttm_tt_mgr_init(num_pages, num_dma32);
@@ -98,8 +106,10 @@ static intttm_global_init(void)INIT_LIST_HEAD(&glob->device_list);atomic_set(&glob->bo_count, 0);
- debugfs_create_atomic_t("buffer_objects", 0444,ttm_debugfs_root, +#ifdefCONFIG_DEBUG_FS
+debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_page, &glob->bo_count);
+#endif
out:
mutex_unlock(&ttm_global_mutex);
return ret;drivers/gpu/drm/ttm/ttm_module.c +1
-0@@ -38,6 +38,7 @@ #include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page; static int __init ttm_init(void) {drivers/gpu/drm/ttm/ttm_module.h +1
-0@@ -36,5 +36,6 @@ struct dentry; extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page; #endif /* _TTM_MODULE_H_ */drivers/gpu/drm/ttm/ttm_pool.c +2
-2@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long num_pages) } #ifdef CONFIG_DEBUG_FS - debugfs_create_file("page_pool", 0444, ttm_debugfs_root, NULL, + debugfs_create_file("page_pool", 0444, ttm_debugfs_page, NULL, &ttm_pool_debugfs_globals_fops); - debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_root,NULL , + debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_page,NULL , &ttm_pool_debugfs_shrink_fops); #endif
Quoted 11 lines · Christian König
Am 12.10.21 um 15:12 schrieb Das, Nirmoy:
Quoted 10 lines · Stanley.Yang
Quoted 6 lines
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu
Error log:
[ 54.396807] debugfs: File 'page_pool' in directory 'amdttm' already present! [ 54.396833] debugfs: File 'page_pool_shrink' in directory 'amdttm' already present! [ 54.396848] debugfs: File 'buffer_objects' in directory 'amdttm' already present!
Quoted 3 lines
Quoted 1 line
We should instead add a check if those debugfs files already exist/created in ttm debugfs dir using
debugfs_lookup()before creating.No, IIRC the Intel guys had fixed that already by adding/removing the debugfs file on module load/unload.
Adding/removing on ttm module load/unload is nicer.
Nirmoy
Quoted 99 lines
Christian.
Quoted 94 lines
Regards,
Nirmoy
Quoted 86 lines
Reason:
page_pool,page_pool_shrinkandbuffer_objectscan be removed when rmmod amdttm, in the above test scenario only rmmod amdgpu, so those debugfs node will not be removed, this caused file create failed. Soultion:
createttm_pagedirectory underttm_rootdirectory when insmod amdgpu,page_pool,page_pool_shrinkandbuffer_objectsare stored inttm_pagedirectiry, removettm_pagedirectory when do rmmod amdgpu, this can fix above issue.Signed-off-by Stanley.Yang <[email protected]>---
drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +0
-0@@ -55,6 +55,10 @@ static void ttm_global_release(void) ttm_pool_mgr_fini();+#ifdef
CONFIG_DEBUG_FS
+debugfs_remove(ttm_debugfs_page);drivers/gpu/drm/ttm/ttm_device.c +2
-0+#endif +
__free_page(glob->dummy_read_page);
memset(glob, 0, sizeof(*glob));
out:drivers/gpu/drm/ttm/ttm_device.c +0
-0@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT));+#ifdef
CONFIG_DEBUG_FS
+ttm_debugfs_page=debugfs_create_dir("ttm_page", ttm_debugfs_root);drivers/gpu/drm/ttm/ttm_device.c +2
-0+#endif +
ttm_pool_mgr_init(num_pages);ttm_tt_mgr_init(num_pages, num_dma32);
@@ -98,8 +106,10 @@ static intttm_global_init(void)INIT_LIST_HEAD(&glob->device_list);atomic_set(&glob->bo_count, 0);
- debugfs_create_atomic_t("buffer_objects", 0444,ttm_debugfs_root, +#ifdefCONFIG_DEBUG_FS
+debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_page, &glob->bo_count);
+#endif
out:
mutex_unlock(&ttm_global_mutex);
return ret;drivers/gpu/drm/ttm/ttm_module.c +1
-0@@ -38,6 +38,7 @@ #include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page; static int __init ttm_init(void) {drivers/gpu/drm/ttm/ttm_module.h +1
-0@@ -36,5 +36,6 @@ struct dentry; extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page; #endif /* _TTM_MODULE_H_ */drivers/gpu/drm/ttm/ttm_pool.c +2
-2@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long num_pages) } #ifdef CONFIG_DEBUG_FS - debugfs_create_file("page_pool", 0444, ttm_debugfs_root, NULL, + debugfs_create_file("page_pool", 0444, ttm_debugfs_page, NULL, &ttm_pool_debugfs_globals_fops); - debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_root,NULL , + debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_page,NULL , &ttm_pool_debugfs_shrink_fops); #endif
[AMD Official Use Only]
Quoted 23 lines
-----邮件原件-----
发件人: amd-gfx <[email protected]> 代表 Das, Nirmoy
发送时间: Thursday, October 14, 2021 2:11 AM
收件人: Christian König <[email protected]>; amd- [email protected]
主题: Re: [PATCH Review 1/1] drm/ttm: fix debugfs node create failedQuoted 13 lines · Christian König
Am 12.10.21 um 15:12 schrieb Das, Nirmoy:
Quoted 12 lines · Stanley.Yang
Quoted 8 lines
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu Error log:
[ 54.396807] debugfs: File 'page_pool' in directory 'amdttm' already present!
[ 54.396833] debugfs: File 'page_pool_shrink' in directory 'amdttm' already present!
[ 54.396848] debugfs: File 'buffer_objects' in directory 'amdttm' already present!
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We should instead add a check if those debugfs files already exist/created in ttm debugfs dir using
debugfs_lookup()before creating.No, IIRC the Intel guys had fixed that already by adding/removing the debugfs file on module load/unload.
Adding/removing on ttm module load/unload is nicer.
The point is that page_pool, page_pool_shrink and buffer_objects are created by amdgpu driver, I think it's better to remove them by amdgpu module due to amdgpu module create them, otherwise, there will be a scene create them failed only reload amdgpu module.
Stanley
Quoted 113 lines
Nirmoy
Quoted 109 lines
Christian.
Quoted 104 lines
Regards,
Nirmoy
Quoted 96 lines
Reason:
page_pool,page_pool_shrinkandbuffer_objectscan be removed when
rmmod amdttm, in the above test scenario only rmmod amdgpu, so those
debugfs node will not be removed, this caused file create failed. Soultion:
createttm_pagedirectory underttm_rootdirectory when insmod amdgpu,
page_pool,page_pool_shrinkandbuffer_objectsare stored inttm_pagedirectiry,
removettm_pagedirectory when do rmmod amdgpu, this can fix above issue.Signed-off-by Stanley.Yang <[email protected]>---
drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +0
-0@@ -55,6 +55,10 @@ static void ttm_global_release(void) ttm_pool_mgr_fini();+#ifdef
CONFIG_DEBUG_FS
+debugfs_remove(ttm_debugfs_page); #endif
+
__free_page(glob->dummy_read_page);
memset(glob, 0, sizeof(*glob));
out:drivers/gpu/drm/ttm/ttm_device.c +0
-0@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT));+#ifdef
CONFIG_DEBUG_FS
+ttm_debugfs_page=debugfs_create_dir("ttm_page", ttm_debugfs_root);drivers/gpu/drm/ttm/ttm_device.c +2
-0+#endif +
ttm_pool_mgr_init(num_pages);ttm_tt_mgr_init(num_pages, num_dma32); @@ -98,8 +106,10 @@ static intttm_global_init(void)INIT_LIST_HEAD(&glob->device_list);atomic_set(&glob->bo_count, 0);
- debugfs_create_atomic_t("buffer_objects", 0444,ttm_debugfs_root,drivers/gpu/drm/ttm/ttm_device.c +3
-0+#ifdef CONFIG_DEBUG_FS + debugfs_create_atomic_t("buffer_objects", 0444, +ttm_debugfs_page,
&glob->bo_count);
+#endif
out:
mutex_unlock(&ttm_global_mutex);
return ret;drivers/gpu/drm/ttm/ttm_module.c +1
-0@@ -38,6 +38,7 @@ #include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page; static int __init ttm_init(void) {drivers/gpu/drm/ttm/ttm_module.h +1
-0@@ -36,5 +36,6 @@ struct dentry; extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page; #endif /* _TTM_MODULE_H_ */(quoted diff) +0
-0
b/drivers/gpu/drm/ttm/ttm_pool.cindex8be7fd7161fd..ecb33daad7b5100644drivers/gpu/drm/ttm/ttm_pool.c +2
-2@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long num_pages) } #ifdef CONFIG_DEBUG_FS - debugfs_create_file("page_pool", 0444, ttm_debugfs_root, NULL, + debugfs_create_file("page_pool", 0444, ttm_debugfs_page, NULL, &ttm_pool_debugfs_globals_fops); - debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_root,NULL , + debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_page,NULL , &ttm_pool_debugfs_shrink_fops); #endif
Am 19.10.21 um 10:02 schrieb Yang, Stanley:
Quoted 24 lines
[AMD Official Use Only]
Quoted 21 lines
-----邮件原件-----
发件人: amd-gfx <[email protected]> 代表 Das, Nirmoy
发送时间: Thursday, October 14, 2021 2:11 AM
收件人: Christian König <[email protected]>; amd- [email protected]
主题: Re: [PATCH Review 1/1] drm/ttm: fix debugfs node create failedQuoted 11 lines · Christian König
Am 12.10.21 um 15:12 schrieb Das, Nirmoy:
Quoted 10 lines · Stanley.Yang
Quoted 8 lines
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu Error log:
[ 54.396807] debugfs: File 'page_pool' in directory 'amdttm'
already present!
[ 54.396833] debugfs: File 'page_pool_shrink' in directory
'amdttm' already present!
[ 54.396848] debugfs: File 'buffer_objects' in directory
'amdttm' already present!
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
We should instead add a check if those debugfs files already exist/created in ttm debugfs dir using
debugfs_lookup()before creating.No, IIRC the Intel guys had fixed that already by adding/removing the debugfs file on module load/unload.
Adding/removing on ttm module load/unload is nicer.
The point is that
page_pool,page_pool_shrinkandbuffer_objectsare created by amdgpu driver,
Yeah, but the debugfs files are not created by the driver. Those are global to TTM and can trivially be created during module load/unload.
Christian.
Quoted 113 lines
I think it's better to remove them by amdgpu module due to amdgpu module create them,
otherwise, there will be a scene create them failed only reload amdgpu module.Stanley
Quoted 109 lines
Nirmoy
Quoted 106 lines
Christian.
Quoted 103 lines
Regards,
Nirmoy
Quoted 96 lines
Reason:
page_pool,page_pool_shrinkandbuffer_objectscan be removed
when
rmmod amdttm, in the above test scenario only rmmod amdgpu, so
those
debugfs node will not be removed, this caused file create failed.
Soultion:
createttm_pagedirectory underttm_rootdirectory when insmod
amdgpu,
page_pool,page_pool_shrinkandbuffer_objectsare stored inttm_pagedirectiry,
removettm_pagedirectory when do rmmod amdgpu, this can fix
above issue.Signed-off-by Stanley.Yang <[email protected]>--- drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +5
-0@@ -55,6 +55,10 @@ static void ttm_global_release(void) ttm_pool_mgr_fini(); +#ifdef CONFIG_DEBUG_FS + debugfs_remove(ttm_debugfs_page); #endif + __free_page(glob->dummy_read_page); memset(glob, 0, sizeof(*glob)); out:@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT)); +#ifdef CONFIG_DEBUG_FS + ttm_debugfs_page = debugfs_create_dir("ttm_page", ttm_debugfs_root); +#endif + ttm_pool_mgr_init(num_pages); ttm_tt_mgr_init(num_pages, num_dma32); @@ -98,8 +106,10 @@ static int ttm_global_init(void) INIT_LIST_HEAD(&glob->device_list); atomic_set(&glob->bo_count, 0); - debugfs_create_atomic_t("buffer_objects", 0444,
ttm_debugfs_root,drivers/gpu/drm/ttm/ttm_device.c +4
-0+#ifdef CONFIG_DEBUG_FS + debugfs_create_atomic_t("buffer_objects", 0444, +ttm_debugfs_page, &glob->bo_count); +#endif out: mutex_unlock(&ttm_global_mutex); return ret;drivers/gpu/drm/ttm/ttm_module.c +1
-0@@ -38,6 +38,7 @@ #include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page; static int __init ttm_init(void) {drivers/gpu/drm/ttm/ttm_module.h +1
-0@@ -36,5 +36,6 @@ struct dentry; extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page; #endif /* _TTM_MODULE_H_ */(quoted diff) +0
-0
b/drivers/gpu/drm/ttm/ttm_pool.cindex8be7fd7161fd..ecb33daad7b5100644drivers/gpu/drm/ttm/ttm_pool.c +2
-2@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long num_pages) } #ifdef CONFIG_DEBUG_FS - debugfs_create_file("page_pool", 0444, ttm_debugfs_root, NULL, + debugfs_create_file("page_pool", 0444, ttm_debugfs_page, NULL, &ttm_pool_debugfs_globals_fops); - debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_root,NULL , + debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_page,NULL , &ttm_pool_debugfs_shrink_fops); #endif
[AMD Official Use Only]
Quoted 38 lines
-----邮件原件-----
发件人: Christian König <[email protected]> 发送时间: Tuesday, October 19, 2021 4:46 PM
收件人: Yang, Stanley <[email protected]>; Das, Nirmoy <[email protected]>; [email protected]
主题: Re: 回复: [PATCH Review 1/1] drm/ttm: fix debugfs node create failedAm 19.10.21 um 10:02 schrieb Yang, Stanley:
Quoted 5 lines
[AMD Official Use Only]
Quoted 2 lines
-----邮件原件-----
发件人: amd-gfx <[email protected]> 代表 Das,Nirmoy
Quoted 11 lines
Quoted 11 lines
发送时间: Thursday, October 14, 2021 2:11 AM
收件人: Christian König <[email protected]>; amd- [email protected]
主题: Re: [PATCH Review 1/1] drm/ttm: fix debugfs node create failedQuoted 4 lines · Christian König
Am 12.10.21 um 15:12 schrieb Das, Nirmoy:
Quoted 3 lines · Stanley.Yang
Quoted 2 lines
Test scenario:
modprobe amdgpu -> rmmod amdgpu -> modprobe amdgpu Errorlog:
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
[ 54.396807] debugfs: File '
page_pool' in directory 'amdttm'
already present!
[ 54.396833] debugfs: File 'page_pool_shrink' in directory
'amdttm' already present!
[ 54.396848] debugfs: File 'buffer_objects' in directory
'amdttm' already present!We should instead add a check if those debugfs files already exist/created in ttm debugfs dir using
debugfs_lookup()before creating.No, IIRC the Intel guys had fixed that already by adding/removing the debugfs file on module load/unload.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Adding/removing on ttm module load/unload is nicer.
The point is that
page_pool,page_pool_shrinkandbuffer_objectsare created by amdgpu driver,Yeah, but the debugfs files are not created by the driver. Those are global to TTM and can trivially be created during module load/unload.
[Yang, Stanley] Thanks Christian, I double check ttm related code the ttm load will create those debugfs file.
Stanley
Quoted 122 lines
Christian.
Quoted 2 lines
I think it's better to remove them by amdgpu module due to amdgpu
module create them, otherwise, there will be a scene create them failedonly reload amdgpu module.
Quoted 88 lines
Stanley
Quoted 86 lines
Nirmoy
Quoted 83 lines
Christian.
Quoted 80 lines
Regards,
Nirmoy
Quoted 73 lines
Reason:
page_pool,page_pool_shrinkandbuffer_objectscan be
removed when
rmmod amdttm, in the above test scenario only rmmod amdgpu,
so those
debugfs node will not be removed, this caused file create failed.
Soultion:
createttm_pagedirectory underttm_rootdirectory when
insmod amdgpu,
page_pool,page_pool_shrinkandbuffer_objectsare stored inttm_pagedirectiry,
removettm_pagedirectory when do rmmod amdgpu, this can fix
above issue.Signed-off-by Stanley.Yang <[email protected]>--- drivers/gpu/drm/ttm/ttm_device.c | 12 +++++++++++- drivers/gpu/drm/ttm/ttm_module.c | 1 + drivers/gpu/drm/ttm/ttm_module.h | 1 + drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_device.c +5
-0@@ -55,6 +55,10 @@ static void ttm_global_release(void) ttm_pool_mgr_fini(); +#ifdef CONFIG_DEBUG_FS + debugfs_remove(ttm_debugfs_page); #endif + __free_page(glob->dummy_read_page); memset(glob, 0, sizeof(*glob)); out:@@ -85,6 +89,10 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT)); +#ifdef CONFIG_DEBUG_FS + ttm_debugfs_page = debugfs_create_dir("ttm_page", ttm_debugfs_root); +#endif + ttm_pool_mgr_init(num_pages); ttm_tt_mgr_init(num_pages, num_dma32); @@ -98,8 +106,10 @@ static int ttm_global_init(void) INIT_LIST_HEAD(&glob->device_list); atomic_set(&glob->bo_count, 0); - debugfs_create_atomic_t("buffer_objects", 0444,
ttm_debugfs_root,drivers/gpu/drm/ttm/ttm_device.c +4
-0+#ifdef CONFIG_DEBUG_FS + debugfs_create_atomic_t("buffer_objects", 0444, +ttm_debugfs_page, &glob->bo_count); +#endif out: mutex_unlock(&ttm_global_mutex); return ret;drivers/gpu/drm/ttm/ttm_module.c +1
-0@@ -38,6 +38,7 @@ #include "ttm_module.h" struct dentry *ttm_debugfs_root; +struct dentry *ttm_debugfs_page; static int __init ttm_init(void) {drivers/gpu/drm/ttm/ttm_module.h +0
-1--- a/drivers/gpu/drm/ttm/ttm_module.hQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
+++
b/drivers/gpu/drm/ttm/ttm_module.hdrivers/gpu/drm/ttm/ttm_module.h +1
-0@@ -36,5 +36,6 @@ struct dentry; extern struct dentry *ttm_debugfs_root; +extern struct dentry *ttm_debugfs_page; #endif /* _TTM_MODULE_H_ */(quoted diff) +0
-0
b/drivers/gpu/drm/ttm/ttm_pool.cindex
8be7fd7161fd..ecb33daad7b5Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/ttm/ttm_pool.c int ttm_pool_mgr_init(unsigned long
Quoted 4 lines
100644
drivers/gpu/drm/ttm/ttm_pool.c +0
-0@@ -709,9 +709,9 @@ int ttm_pool_mgr_init(unsigned long
num_pages)Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/ttm/ttm_pool.c +4
-2} #ifdef CONFIG_DEBUG_FS - debugfs_create_file("page_pool", 0444, ttm_debugfs_root,NULL , + debugfs_create_file("page_pool", 0444, ttm_debugfs_page, +NULL , &ttm_pool_debugfs_globals_fops); - debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_root,NULL , + debugfs_create_file("page_pool_shrink", 0400, +ttm_debugfs_page,NULL,
&ttm_pool_debugfs_shrink_fops); #endif