[PATCH] drm/amdgpu:remove debugfs file in amdgpu_device_finish

Gary Sun Gary.Sun at amd.com
Mon Nov 6 09:20:40 UTC 2017


remove debugfs file in amdgpu_device_finish

Signed-off-by: Gary Sun <Gary.Sun at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |    1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 4f919d3..6cfcb5f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1250,6 +1250,7 @@ struct amdgpu_debugfs {
 int amdgpu_debugfs_add_files(struct amdgpu_device *adev,
 			     const struct drm_info_list *files,
 			     unsigned nfiles);
+int amdgpu_debugfs_cleanup_files(struct amdgpu_device *adev);
 int amdgpu_debugfs_fence_init(struct amdgpu_device *adev);
 
 #if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7b7439f..ee800ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2520,6 +2520,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 	amdgpu_doorbell_fini(adev);
 	amdgpu_pm_sysfs_fini(adev);
 	amdgpu_debugfs_regs_cleanup(adev);
+	amdgpu_debugfs_cleanup_files(adev);
 }
 
 
@@ -3304,6 +3305,23 @@ int amdgpu_debugfs_add_files(struct amdgpu_device *adev,
 	return 0;
 }
 
+int amdgpu_debugfs_cleanup_files(struct amdgpu_device *adev)
+{
+	unsigned int i;
+
+	for (i = 0; i < adev->debugfs_count; i++) {
+#if defined(CONFIG_DEBUG_FS)
+		drm_debugfs_remove_files(adev->debugfs[i].files,
+				adev->debugfs[i].num_files,
+				adev->ddev->primary);
+#endif
+		adev->debugfs[i].files = NUL;
+		adev->debugfs[i].num_files = 0;
+	}
+	adev->debugfs_count = 0;
+	return 0;
+}
+
 #if defined(CONFIG_DEBUG_FS)
 
 static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
-- 
1.7.1



More information about the amd-gfx mailing list