The amdgpu(4) code uses separate code paths for suspend and hibernate.
authorkettenis <kettenis@openbsd.org>
Sat, 17 Aug 2024 10:38:21 +0000 (10:38 +0000)
committerkettenis <kettenis@openbsd.org>
Sat, 17 Aug 2024 10:38:21 +0000 (10:38 +0000)
Use the ACPI sleep state to determine which path to go down into.  This
fixes (un)hibernate again after the fix for S0/S3 broke it.

Using the ACPI sleep state for this is not ideal.  If we ever want to
support amdgpu(4) on architectures without ACPI, we'll need a different
solution.

ok jsg@

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

index e6b2737..8b666f3 100644 (file)
@@ -2458,8 +2458,6 @@ static int amdgpu_pmops_resume(struct device *dev)
        return r;
 }
 
-#ifdef notyet
-
 static int amdgpu_pmops_freeze(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -2477,6 +2475,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
        return 0;
 }
 
+#ifdef notyet
+
 static int amdgpu_pmops_thaw(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -2491,6 +2491,8 @@ static int amdgpu_pmops_poweroff(struct device *dev)
        return amdgpu_device_suspend(drm_dev, true);
 }
 
+#endif
+
 static int amdgpu_pmops_restore(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -2498,6 +2500,8 @@ static int amdgpu_pmops_restore(struct device *dev)
        return amdgpu_device_resume(drm_dev, true);
 }
 
+#ifdef notyet
+
 static int amdgpu_runtime_idle_check_display(struct device *dev)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
@@ -3674,15 +3678,22 @@ amdgpu_activate(struct device *self, int act)
        case DVACT_QUIESCE:
                rv = config_activate_children(self, act);
                amdgpu_pmops_prepare(self);
-               amdgpu_pmops_suspend(self);
+               if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4)
+                       amdgpu_pmops_freeze(self);
+               else
+                       amdgpu_pmops_suspend(self);
                break;
        case DVACT_SUSPEND:
-               amdgpu_pmops_suspend_noirq(self);
+               if (!acpi_softc || acpi_softc->sc_state != ACPI_STATE_S4)
+                       amdgpu_pmops_suspend_noirq(self);
                break;
        case DVACT_RESUME:
                break;
        case DVACT_WAKEUP:
-               amdgpu_pmops_resume(self);
+               if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4)
+                       amdgpu_pmops_restore(self);
+               else
+                       amdgpu_pmops_resume(self);
                rv = config_activate_children(self, act);
                break;
        }