Skip to contentSkip to conversation

drm/amdgpu: Fix sysfs warning when hotplugging

PATCH Superseded [email protected] 2 participants 2 messages Nov 15, 2024 – Nov 18, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix sysfs warning when hotplugging

Replace the check drm_dev_enter with sysfs directory entry. Because the dev->unplugged flag will also be set to true, Only uninstall the driver by amdgpu_exit, not actually unplug the device.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c         | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c        | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c | 6 ++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c        | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c         | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c         | 5 +----
 drivers/gpu/drm/amd/amdgpu/df_v3_6.c            | 6 +-----
 7 files changed, 8 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -4
index c65feb97167d..cda0efd4d73c 100644
@@ -1779,13 +1779,10 @@ int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
 
 void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
 {
-	int idx;
-
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd) {
 		amdgpu_gfx_sysfs_xcp_fini(adev);
 		amdgpu_gfx_sysfs_isolation_shader_fini(adev);
 		amdgpu_gfx_sysfs_reset_mask_fini(adev);
-		drm_dev_exit(idx);
 	}
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +1 -4
index bf4dbceb18e1..7444b556e78a 100644
@@ -448,11 +448,8 @@ int amdgpu_jpeg_sysfs_reset_mask_init(struct amdgpu_device *adev)
 
 void amdgpu_jpeg_sysfs_reset_mask_fini(struct amdgpu_device *adev)
 {
-	int idx;
-
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd) {
 		if (adev->jpeg.num_jpeg_inst)
 			device_remove_file(adev->dev, &dev_attr_jpeg_reset_mask);
-		drm_dev_exit(idx);
 	}
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c +2 -4
index 9a0346ed6ea4..ead1ca43e14e 100644
@@ -130,7 +130,7 @@ int amdgpu_preempt_mgr_init(struct amdgpu_device *adev)
 void amdgpu_preempt_mgr_fini(struct amdgpu_device *adev)
 {
 	struct ttm_resource_manager *man = &adev->mman.preempt_mgr;
-	int idx, ret;
+	int ret;
 
 	ttm_resource_manager_set_used(man, false);
 
@@ -138,10 +138,8 @@ void amdgpu_preempt_mgr_fini(struct amdgpu_device *adev)
 	if (ret)
 		return;
 
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd)
 		device_remove_file(adev->dev, &dev_attr_mem_info_preempt_used);
-		drm_dev_exit(idx);
-	}
 
 	ttm_resource_manager_cleanup(man);
 	ttm_set_driver_manager(&adev->mman.bdev, AMDGPU_PL_PREEMPT, NULL);
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +1 -4
index 24e9daacaabb..11c64f087efd 100644
@@ -449,14 +449,11 @@ int amdgpu_sdma_sysfs_reset_mask_init(struct amdgpu_device *adev)
 
 void amdgpu_sdma_sysfs_reset_mask_fini(struct amdgpu_device *adev)
 {
-	int idx;
-
 	if (!amdgpu_gpu_recovery)
 		return;
 
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd) {
 		if (adev->sdma.num_instances)
 			device_remove_file(adev->dev, &dev_attr_sdma_reset_mask);
-		drm_dev_exit(idx);
 	}
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +1 -4
index 25f490ad3a85..ed9c795e7b35 100644
@@ -1310,11 +1310,8 @@ int amdgpu_vcn_sysfs_reset_mask_init(struct amdgpu_device *adev)
 
 void amdgpu_vcn_sysfs_reset_mask_fini(struct amdgpu_device *adev)
 {
-	int idx;
-
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd) {
 		if (adev->vcn.num_vcn_inst)
 			device_remove_file(adev->dev, &dev_attr_vcn_reset_mask);
-		drm_dev_exit(idx);
 	}
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +1 -4
index b5f5a1a81c29..dc96e81235df 100644
@@ -904,12 +904,9 @@ int amdgpu_vpe_sysfs_reset_mask_init(struct amdgpu_device *adev)
 
 void amdgpu_vpe_sysfs_reset_mask_fini(struct amdgpu_device *adev)
 {
-	int idx;
-
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd) {
 		if (adev->vpe.num_instances)
 			device_remove_file(adev->dev, &dev_attr_vpe_reset_mask);
-		drm_dev_exit(idx);
 	}
 }
 
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +1 -5
index 54c05af2eed2..0bbeab852540 100644
@@ -255,12 +255,8 @@ static void df_v3_6_sw_init(struct amdgpu_device *adev)
 
 static void df_v3_6_sw_fini(struct amdgpu_device *adev)
 {
-	int idx;
-
-	if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+	if (adev->dev->kobj.sd)
 		device_remove_file(adev->dev, &dev_attr_df_cntr_avail);
-		drm_dev_exit(idx);
-	}
 }
 
 static void df_v3_6_enable_broadcast_mode(struct amdgpu_device *adev,
Signature · 1 line
2.25.1
#1 lore raw

[Public]

Hi Jesse,

I recommend reverting the old patch "[PATCH V2] drm/amdgpu: fix warning when removing sysfs" first, and then applying your change.

Thanks
Tim Huang

Quoted 170 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, November 15, 2024 10:08 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Prosyak, Vitaly <[email protected]>; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Dong, Andy <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix sysfs warning when hotplugging

Replace the check drm_dev_enter with sysfs directory entry. Because the dev->unplugged flag will also be set to true, Only uninstall the driver by amdgpu_exit, not actually unplug the device.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c         | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c        | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c | 6 ++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c        | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c         | 5 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c         | 5 +----
 drivers/gpu/drm/amd/amdgpu/df_v3_6.c            | 6 +-----
 7 files changed, 8 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -4
index c65feb97167d..cda0efd4d73c 100644
@@ -1779,13 +1779,10 @@ int amdgpu_gfx_sysfs_init(struct
 amdgpu_device *adev)
 
 void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)  {
-     int idx;
-
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd) {
              amdgpu_gfx_sysfs_xcp_fini(adev);
              amdgpu_gfx_sysfs_isolation_shader_fini(adev);
              amdgpu_gfx_sysfs_reset_mask_fini(adev);
-             drm_dev_exit(idx);
      }
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +1 -4
index bf4dbceb18e1..7444b556e78a 100644
@@ -448,11 +448,8 @@ int amdgpu_jpeg_sysfs_reset_mask_init(struct
 amdgpu_device *adev)
 
 void amdgpu_jpeg_sysfs_reset_mask_fini(struct amdgpu_device *adev)  {
-     int idx;
-
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd) {
              if (adev->jpeg.num_jpeg_inst)
                      device_remove_file(adev->dev, &dev_attr_jpeg_reset_mask);
-             drm_dev_exit(idx);
      }
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_preempt_mgr.c +2 -4
index 9a0346ed6ea4..ead1ca43e14e 100644
@@ -130,7 +130,7 @@ int amdgpu_preempt_mgr_init(struct amdgpu_device
 *adev)  void amdgpu_preempt_mgr_fini(struct amdgpu_device *adev)  {
      struct ttm_resource_manager *man = &adev->mman.preempt_mgr;
-     int idx, ret;
+     int ret;
 
      ttm_resource_manager_set_used(man, false);
 
@@ -138,10 +138,8 @@ void amdgpu_preempt_mgr_fini(struct
 amdgpu_device *adev)
      if (ret)
              return;
 
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd)
              device_remove_file(adev->dev,
 &dev_attr_mem_info_preempt_used);
-             drm_dev_exit(idx);
-     }
 
      ttm_resource_manager_cleanup(man);
      ttm_set_driver_manager(&adev->mman.bdev, AMDGPU_PL_PREEMPT,

NULL); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
index 24e9daacaabb..11c64f087efd 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +1 -4
@@ -449,14 +449,11 @@ int amdgpu_sdma_sysfs_reset_mask_init(struct
 amdgpu_device *adev)
 
 void amdgpu_sdma_sysfs_reset_mask_fini(struct amdgpu_device *adev)  {
-     int idx;
-
      if (!amdgpu_gpu_recovery)
              return;
 
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd) {
              if (adev->sdma.num_instances)
                      device_remove_file(adev->dev, &dev_attr_sdma_reset_mask);
-             drm_dev_exit(idx);
      }
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +1 -4
index 25f490ad3a85..ed9c795e7b35 100644
@@ -1310,11 +1310,8 @@ int amdgpu_vcn_sysfs_reset_mask_init(struct
 amdgpu_device *adev)
 
 void amdgpu_vcn_sysfs_reset_mask_fini(struct amdgpu_device *adev)  {
-     int idx;
-
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd) {
              if (adev->vcn.num_vcn_inst)
                      device_remove_file(adev->dev, &dev_attr_vcn_reset_mask);
-             drm_dev_exit(idx);
      }
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +1 -4
index b5f5a1a81c29..dc96e81235df 100644
@@ -904,12 +904,9 @@ int amdgpu_vpe_sysfs_reset_mask_init(struct
 amdgpu_device *adev)
 
 void amdgpu_vpe_sysfs_reset_mask_fini(struct amdgpu_device *adev)  {
-     int idx;
-
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd) {
              if (adev->vpe.num_instances)
                      device_remove_file(adev->dev, &dev_attr_vpe_reset_mask);
-             drm_dev_exit(idx);
      }
 }
 
drivers/gpu/drm/amd/amdgpu/df_v3_6.c +1 -6
index 54c05af2eed2..0bbeab852540 100644
@@ -255,12 +255,8 @@ static void df_v3_6_sw_init(struct amdgpu_device
 *adev)
 
 static void df_v3_6_sw_fini(struct amdgpu_device *adev)  {
-     int idx;
-
-     if (drm_dev_enter(adev_to_drm(adev), &idx)) {
+     if (adev->dev->kobj.sd)
              device_remove_file(adev->dev, &dev_attr_df_cntr_avail);
-             drm_dev_exit(idx);
-     }
 }
 
 static void df_v3_6_enable_broadcast_mode(struct amdgpu_device *adev,
--

2.25.1