Add missing amdgpu_vcn_sysfs_reset_mask_fini() call to properly clean
up the vcn_reset_mask sysfs file during driver unload. Without this
cleanup, subsequent driver reloads fail with "sysfs: cannot create
duplicate filename" errors.

The vcn_v4_0_5 driver creates the vcn_reset_mask sysfs file in
vcn_v4_0_5_sw_init() via amdgpu_vcn_sysfs_reset_mask_init(), but was
missing the corresponding amdgpu_vcn_sysfs_reset_mask_fini() call in
vcn_v4_0_5_sw_fini(). This left the sysfs file orphaned after driver
unload, causing -EEXIST errors on reload.

Error without fix:
  sysfs: cannot create duplicate filename '/devices/.../vcn_reset_mask'
  amdgpu_vcn_sysfs_reset_mask_init+0x2c/0x40 [amdgpu]
  vcn_v4_0_5_sw_init+0x2d6/0x480 [amdgpu]
  [drm:amdgpu_device_ip_init [amdgpu]] *ERROR* sw_init of IP block
  <vcn_v4_0_5> failed -17

Signed-off-by: Yong Jie Wong <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
index b107ee80e4728..cd26d45845322 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
@@ -269,9 +269,12 @@ static int vcn_v4_0_5_sw_fini(struct amdgpu_ip_block 
*ip_block)
                r = amdgpu_vcn_suspend(adev, i);
                if (r)
                        return r;
+       }
+
+       amdgpu_vcn_sysfs_reset_mask_fini(adev);
 
+       for (i = 0; i < adev->vcn.num_vcn_inst; i++)
                amdgpu_vcn_sw_fini(adev, i);
-       }
 
        return 0;
 }
-- 
2.43.0

Reply via email to