drm/amdgpu: release gpu full access after "amdgpu_device_ip_late_init"
authorjsg <jsg@openbsd.org>
Mon, 19 Jun 2023 00:30:06 +0000 (00:30 +0000)
committerjsg <jsg@openbsd.org>
Mon, 19 Jun 2023 00:30:06 +0000 (00:30 +0000)
From Chong Li
787e74b21394f126bbce355839dcce9b0ad256d2 in linux-6.1.y/6.1.33
38eecbe086a4e52f54b2bbda8feba65d44addbef in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c

index 9693660..aff64c9 100644 (file)
@@ -2544,8 +2544,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
        amdgpu_fru_get_product_info(adev);
 
 init_failed:
-       if (amdgpu_sriov_vf(adev))
-               amdgpu_virt_release_full_gpu(adev, true);
 
        return r;
 }
@@ -3880,18 +3878,6 @@ fence_driver_init:
 
        r = amdgpu_device_ip_init(adev);
        if (r) {
-               /* failed in exclusive mode due to timeout */
-               if (amdgpu_sriov_vf(adev) &&
-                   !amdgpu_sriov_runtime(adev) &&
-                   amdgpu_virt_mmio_blocked(adev) &&
-                   !amdgpu_virt_wait_reset(adev)) {
-                       dev_err(adev->dev, "VF exclusive mode timeout\n");
-                       /* Don't send request since VF is inactive. */
-                       adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME;
-                       adev->virt.ops = NULL;
-                       r = -EAGAIN;
-                       goto release_ras_con;
-               }
                dev_err(adev->dev, "amdgpu_device_ip_init failed\n");
                amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 0);
                goto release_ras_con;
@@ -4000,8 +3986,10 @@ fence_driver_init:
                                   msecs_to_jiffies(AMDGPU_RESUME_MS));
        }
 
-       if (amdgpu_sriov_vf(adev))
+       if (amdgpu_sriov_vf(adev)) {
+               amdgpu_virt_release_full_gpu(adev, true);
                flush_delayed_work(&adev->delayed_init_work);
+       }
 
        r = sysfs_create_files(&adev->dev->kobj, amdgpu_dev_attributes);
        if (r)
@@ -4043,6 +4031,20 @@ fence_driver_init:
        return 0;
 
 release_ras_con:
+       if (amdgpu_sriov_vf(adev))
+               amdgpu_virt_release_full_gpu(adev, true);
+
+       /* failed in exclusive mode due to timeout */
+       if (amdgpu_sriov_vf(adev) &&
+               !amdgpu_sriov_runtime(adev) &&
+               amdgpu_virt_mmio_blocked(adev) &&
+               !amdgpu_virt_wait_reset(adev)) {
+               dev_err(adev->dev, "VF exclusive mode timeout\n");
+               /* Don't send request since VF is inactive. */
+               adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME;
+               adev->virt.ops = NULL;
+               r = -EAGAIN;
+       }
        amdgpu_release_ras_context(adev);
 
 failed: