drm/amdgpu: Fix desktop freezed after gpu-reset
authorjsg <jsg@openbsd.org>
Thu, 27 Apr 2023 02:36:57 +0000 (02:36 +0000)
committerjsg <jsg@openbsd.org>
Thu, 27 Apr 2023 02:36:57 +0000 (02:36 +0000)
From Alan Liu
bef774effb278ff0b65ea2dbaa1ab32ba6a1dc13 in linux-6.1.y/6.1.26
c8b5a95b570949536a2b75cd8fc4f1de0bc60629 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_irq.c
sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c

index 22c69ae..9190712 100644 (file)
@@ -664,6 +664,9 @@ int amdgpu_irq_put(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
        if (!src->enabled_types || !src->funcs->set)
                return -EINVAL;
 
+       if (WARN_ON(!amdgpu_irq_enabled(adev, src, type)))
+               return -EINVAL;
+
        if (atomic_dec_and_test(&src->enabled_types[type]))
                return amdgpu_irq_update(adev, src, type);
 
index b87f50e..1ec643a 100644 (file)
@@ -167,10 +167,21 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
        if (rc)
                return rc;
 
-       irq_source = IRQ_TYPE_VBLANK + acrtc->otg_inst;
+       if (amdgpu_in_reset(adev)) {
+               irq_source = IRQ_TYPE_VBLANK + acrtc->otg_inst;
+               /* During gpu-reset we disable and then enable vblank irq, so
+                * don't use amdgpu_irq_get/put() to avoid refcount change.
+                */
+               if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
+                       rc = -EBUSY;
+       } else {
+               rc = (enable)
+                       ? amdgpu_irq_get(adev, &adev->crtc_irq, acrtc->crtc_id)
+                       : amdgpu_irq_put(adev, &adev->crtc_irq, acrtc->crtc_id);
+       }
 
-       if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
-               return -EBUSY;
+       if (rc)
+               return rc;
 
 skip:
        if (amdgpu_in_reset(adev))