From 75aab5aad704ceedca710149a8cfc9fd52b78f0b Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 30 Nov 2023 02:39:56 +0000 Subject: [PATCH] drm/amdgpu: fix software pci_unplug on some chips From Vitaly Prosyak 6586b5f8e456de7bddbed2446f5f558f9035c7ad in linux-6.1.y/6.1.64 4638e0c29a3f2294d5de0d052a4b8c9f33ccb957 in mainline linux --- sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c index fb5be1ce7ca..fe48628a0aa 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c @@ -1278,7 +1278,8 @@ static void amdgpu_ras_sysfs_remove_bad_page_node(struct amdgpu_device *adev) { struct amdgpu_ras *con = amdgpu_ras_get_context(adev); - sysfs_remove_file_from_group(&adev->dev->kobj, + if (adev->dev->kobj.sd) + sysfs_remove_file_from_group(&adev->dev->kobj, &con->badpages_attr.attr, RAS_FS_NAME); } @@ -1295,7 +1296,8 @@ static int amdgpu_ras_sysfs_remove_feature_node(struct amdgpu_device *adev) .attrs = attrs, }; - sysfs_remove_group(&adev->dev->kobj, &group); + if (adev->dev->kobj.sd) + sysfs_remove_group(&adev->dev->kobj, &group); return 0; } @@ -1348,9 +1350,12 @@ int amdgpu_ras_sysfs_remove(struct amdgpu_device *adev, if (!obj || !obj->attr_inuse) return -EINVAL; - sysfs_remove_file_from_group(&adev->dev->kobj, +#ifdef __linux__ + if (adev->dev->kobj.sd) + sysfs_remove_file_from_group(&adev->dev->kobj, &obj->sysfs_attr.attr, RAS_FS_NAME); +#endif obj->attr_inuse = 0; put_obj(obj); -- 2.20.1