drm/amdgpu: Fix sysfs warning when hotplugging
Subsystems (2)
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
[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 hotpluggingReplace the check
drm_dev_enterwith sysfs directory entry. Because thedev->unpluggedflag will also be set to true, Only uninstall the driver byamdgpu_exit, not actually unplug the device.Signed-off-by Jesse Zhang <[email protected]>Reported-by Andy Dong <[email protected]>--- 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@@ -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@@ -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@@ -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.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
index24e9daacaabb..11c64f087efd100644drivers/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@@ -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@@ -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@@ -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