drm/amdgpu: fix software pci_unplug on some chips
authorjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:39:56 +0000 (02:39 +0000)
committerjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:39:56 +0000 (02:39 +0000)
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

index fb5be1c..fe48628 100644 (file)
@@ -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);