Skip to contentSkip to conversation

drm/amdgpu: do not keep debugfs dentry

PATCH New Nirmoy Das 2 participants 3 messages Feb 11, 2021

Subsystems (3)
lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH v3 1/2 drm/amdgpu: do not keep debugfs dentry

Cleanup unnecessary debugfs dentries and surrounding functions.

v3: remove return value check for debugfs_create_file()
v2: remove ttm_debugfs_entries array.
do not init variables.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h         |  4 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 20 +++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c     | 73 +++++++++------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h     |  4 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 41 ++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |  4 --
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h     |  3 -
 7 files changed, 51 insertions(+), 98 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -4
index e0c797a5f739..e3d4d2dcb3a0 100644
@@ -797,10 +797,6 @@ struct amdgpu_device {
 	struct amdgpu_i2c_chan		*i2c_bus[AMDGPU_MAX_I2C_BUS];
 	struct amdgpu_debugfs		debugfs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
 	unsigned			debugfs_count;
-#if defined(CONFIG_DEBUG_FS)
-	struct dentry                   *debugfs_preempt;
-	struct dentry			*debugfs_regs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
-#endif
 	struct amdgpu_atif		*atif;
 	struct amdgpu_atcs		atcs;
 	struct mutex			srbm_mutex;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +9 -11
index 4c38c5771cbc..55db646d0ba4 100644
@@ -1228,7 +1228,6 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 					  adev, debugfs_regs[i]);
 		if (!i && !IS_ERR_OR_NULL(ent))
 			i_size_write(ent->d_inode, adev->rmmio_size);
-		adev->debugfs_regs[i] = ent;
 	}
 
 	return 0;
@@ -1591,22 +1590,21 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
 
 int amdgpu_debugfs_init(struct amdgpu_device *adev)
 {
+	struct dentry *ent;
 	int r, i;
 
-	adev->debugfs_preempt =
-		debugfs_create_file("amdgpu_preempt_ib", 0600,
-				    adev_to_drm(adev)->primary->debugfs_root, adev,
-				    &fops_ib_preempt);
-	if (!(adev->debugfs_preempt)) {
+	ent = debugfs_create_file("amdgpu_preempt_ib", 0600,
+				  adev_to_drm(adev)->primary->debugfs_root, adev,
+				  &fops_ib_preempt);
+	if (!ent) {
 		DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n");
 		return -EIO;
 	}
 
-	adev->smu.debugfs_sclk =
-		debugfs_create_file("amdgpu_force_sclk", 0200,
-				    adev_to_drm(adev)->primary->debugfs_root, adev,
-				    &fops_sclk_set);
-	if (!(adev->smu.debugfs_sclk)) {
+	ent = debugfs_create_file("amdgpu_force_sclk", 0200,
+				  adev_to_drm(adev)->primary->debugfs_root, adev,
+				  &fops_sclk_set);
+	if (!ent) {
 		DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
 		return -EIO;
 	}
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +30 -43

133 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +0 -4
index 762f5e46c007..aed0716efa5a 100644
@@ -318,8 +318,6 @@ struct amdgpu_ras {
 	uint32_t supported;
 	uint32_t features;
 	struct list_head head;
-	/* debugfs */
-	struct dentry *dir;
 	/* sysfs */
 	struct device_attribute features_attr;
 	struct bin_attribute badpages_attr;
@@ -395,8 +393,6 @@ struct ras_manager {
 	struct list_head node;
 	/* the device */
 	struct amdgpu_device *adev;
-	/* debugfs */
-	struct dentry *ent;
 	/* sysfs */
 	struct device_attribute sysfs_attr;
 	int attr_inuse;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +12 -29

60 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -4
index 6c142455fc66..4df4cf2fd4dd 100644
@@ -68,10 +68,6 @@ struct amdgpu_mman {
 	bool				initialized;
 	void __iomem			*aper_base_kaddr;
 
-#if defined(CONFIG_DEBUG_FS)
-	struct dentry			*debugfs_entries[8];
-#endif
-
 	/* buffer handling */
 	const struct amdgpu_buffer_funcs	*buffer_funcs;
 	struct amdgpu_ring			*buffer_funcs_ring;
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -3
index 10b0624ade65..83147b7d836e 100644
@@ -439,9 +439,6 @@ struct smu_context
 	struct smu_baco_context		smu_baco;
 	struct smu_temperature_range	thermal_range;
 	void *od_settings;
-#if defined(CONFIG_DEBUG_FS)
-	struct dentry                   *debugfs_sclk;
-#endif
 
 	struct smu_umd_pstate_table	pstate_table;
 	uint32_t pstate_sclk;

--
2.30.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#1 lore raw

PATCH 2/2 drm/radeon: cleanup debugfs

Remove unnecessary debugfs dentries and also radeon_ttm_debugfs_fini() as drm_debugfs_cleanup() will recursively remove debugfs files.

---
 drivers/gpu/drm/radeon/radeon.h     |  5 -----
 drivers/gpu/drm/radeon/radeon_ttm.c | 24 +++++-------------------
 2 files changed, 5 insertions(+), 24 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -5
index f9f550784590..2c0e3e7c294d 100644
@@ -454,11 +454,6 @@ struct radeon_surface_reg {
 struct radeon_mman {
 	struct ttm_bo_device		bdev;
 	bool				initialized;
-
-#if defined(CONFIG_DEBUG_FS)
-	struct dentry			*vram;
-	struct dentry			*gtt;
-#endif
 };
 
 struct radeon_bo_list {
drivers/gpu/drm/radeon/radeon_ttm.c +5 -19
index 46bf835284f4..9d156b12d24c 100644
@@ -55,7 +55,6 @@
 #include "radeon_ttm.h"
 
 static int radeon_ttm_debugfs_init(struct radeon_device *rdev);
-static void radeon_ttm_debugfs_fini(struct radeon_device *rdev);
 
 struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
 {
@@ -793,7 +792,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
 
 	if (!rdev->mman.initialized)
 		return;
-	radeon_ttm_debugfs_fini(rdev);
+
 	if (rdev->stolen_vga_memory) {
 		r = radeon_bo_reserve(rdev->stolen_vga_memory, false);
 		if (r == 0) {
@@ -1009,12 +1008,11 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
 	struct drm_minor *minor = rdev->ddev->primary;
 	struct dentry *root = minor->debugfs_root;
 
-	rdev->mman.vram = debugfs_create_file("radeon_vram", S_IFREG | S_IRUGO,
-					      root, rdev,
-					      &radeon_ttm_vram_fops);
+	debugfs_create_file("radeon_vram", S_IFREG | S_IRUGO, root, rdev,
+			    &radeon_ttm_vram_fops);
 
-	rdev->mman.gtt = debugfs_create_file("radeon_gtt", S_IFREG | S_IRUGO,
-					     root, rdev, &radeon_ttm_gtt_fops);
+	debugfs_create_file("radeon_gtt", S_IFREG | S_IRUGO, root, rdev,
+			    &radeon_ttm_gtt_fops);
 
 	count = ARRAY_SIZE(radeon_ttm_debugfs_list);
 
@@ -1029,15 +1027,3 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
 	return 0;
 #endif
 }
-
-static void radeon_ttm_debugfs_fini(struct radeon_device *rdev)
-{
-#if defined(CONFIG_DEBUG_FS)
-
-	debugfs_remove(rdev->mman.vram);
-	rdev->mman.vram = NULL;
-
-	debugfs_remove(rdev->mman.gtt);
-	rdev->mman.gtt = NULL;
-#endif
-}
Signature · 6 lines
2.30.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/radeon: cleanup debugfs

Am 11.02.21 um 13:26 schrieb Nirmoy Das:

Quoted 4 lines

Remove unnecessary debugfs dentries and also radeon_ttm_debugfs_fini() as drm_debugfs_cleanup() will recursively remove debugfs files.

Quoted 65 lines
---
  drivers/gpu/drm/radeon/radeon.h     |  5 -----
  drivers/gpu/drm/radeon/radeon_ttm.c | 24 +++++-------------------
  2 files changed, 5 insertions(+), 24 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -5
index f9f550784590..2c0e3e7c294d 100644
@@ -454,11 +454,6 @@ struct radeon_surface_reg {
  struct radeon_mman {
  	struct ttm_bo_device		bdev;
  	bool				initialized;
-
-#if defined(CONFIG_DEBUG_FS)
-	struct dentry			*vram;
-	struct dentry			*gtt;
-#endif
  };
 
  struct radeon_bo_list {
drivers/gpu/drm/radeon/radeon_ttm.c +5 -9
index 46bf835284f4..9d156b12d24c 100644
@@ -55,7 +55,6 @@
  #include "radeon_ttm.h"
 
  static int radeon_ttm_debugfs_init(struct radeon_device *rdev);
-static void radeon_ttm_debugfs_fini(struct radeon_device *rdev);
 
  struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
  {
@@ -793,7 +792,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
 
  	if (!rdev->mman.initialized)
  		return;
-	radeon_ttm_debugfs_fini(rdev);
+
  	if (rdev->stolen_vga_memory) {
  		r = radeon_bo_reserve(rdev->stolen_vga_memory, false);
  		if (r == 0) {
@@ -1009,12 +1008,11 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
  	struct drm_minor *minor = rdev->ddev->primary;
  	struct dentry *root = minor->debugfs_root;
 
-	rdev->mman.vram = debugfs_create_file("radeon_vram", S_IFREG | S_IRUGO,
-					      root, rdev,
-					      &radeon_ttm_vram_fops);
+	debugfs_create_file("radeon_vram", S_IFREG | S_IRUGO, root, rdev,
+			    &radeon_ttm_vram_fops);
 
-	rdev->mman.gtt = debugfs_create_file("radeon_gtt", S_IFREG | S_IRUGO,
-					     root, rdev, &radeon_ttm_gtt_fops);
+	debugfs_create_file("radeon_gtt", S_IFREG | S_IRUGO, root, rdev,
+			    &radeon_ttm_gtt_fops);
 
  	count = ARRAY_SIZE(radeon_ttm_debugfs_list);
 
@@ -1029,15 +1027,3 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
  	return 0;
  #endif
  }
-
-static void radeon_ttm_debugfs_fini(struct radeon_device *rdev)

drivers/gpu/drm/radeon/radeon_ttm.c static int radeon_ttm_debugfs_init(struct radeon_device *rdev) · line 1043

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_ttm.c +0 -10
-{
-#if defined(CONFIG_DEBUG_FS)
-
-	debugfs_remove(rdev->mman.vram);
-	rdev->mman.vram = NULL;
-
-	debugfs_remove(rdev->mman.gtt);
-	rdev->mman.gtt = NULL;
-#endif
-}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx