Hook up a few more bits of suspend/resume power management code. This
authorkettenis <kettenis@openbsd.org>
Fri, 16 Aug 2024 10:46:46 +0000 (10:46 +0000)
committerkettenis <kettenis@openbsd.org>
Fri, 16 Aug 2024 10:46:46 +0000 (10:46 +0000)
fixes S3 suspend/resume on the Lenovo ThinCentre M715q with:

  amdgpu0: RAVEN GC 9.1.0 8 CU rev 0x01

and also fixes S0 suspend/resume on various laptops with AMD graphics
provided we disable a few checks (which will be done in a separate
commit).

ok jsg@

sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c
sys/dev/pci/drm/include/linux/pci.h
sys/dev/pci/drm/include/linux/pm_runtime.h

index 17038e2..e6b2737 100644 (file)
@@ -2383,8 +2383,6 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work)
        }
 }
 
-#ifdef notyet
-
 static int amdgpu_pmops_prepare(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -2460,6 +2458,8 @@ 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);
@@ -3496,6 +3496,8 @@ amdgpu_attachhook(struct device *self)
        struct drm_gem_object *obj;
        struct amdgpu_bo *rbo;
 
+       dev_set_drvdata(self, dev);
+
        r = amdgpu_driver_load_kms(adev, adev->flags);
        if (r)
                goto out;
@@ -3671,15 +3673,16 @@ amdgpu_activate(struct device *self, int act)
        switch (act) {
        case DVACT_QUIESCE:
                rv = config_activate_children(self, act);
-               amdgpu_device_prepare(dev);
-               amdgpu_device_suspend(dev, true);
+               amdgpu_pmops_prepare(self);
+               amdgpu_pmops_suspend(self);
                break;
        case DVACT_SUSPEND:
+               amdgpu_pmops_suspend_noirq(self);
                break;
        case DVACT_RESUME:
                break;
        case DVACT_WAKEUP:
-               amdgpu_device_resume(dev, true);
+               amdgpu_pmops_resume(self);
                rv = config_activate_children(self, act);
                break;
        }
index bfa2140..3304398 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pci.h,v 1.16 2024/01/16 23:38:13 jsg Exp $    */
+/*     $OpenBSD: pci.h,v 1.17 2024/08/16 10:46:46 kettenis Exp $       */
 /*
  * Copyright (c) 2015 Mark Kettenis
  *
@@ -524,4 +524,10 @@ pci_match_id(const struct pci_device_id *ids, struct pci_dev *pdev)
 #define PCI_CLASS_ACCELERATOR_PROCESSING \
     (PCI_CLASS_ACCELERATOR << 8)
 
+static inline int
+pci_device_is_present(struct pci_dev *pdev)
+{
+       return 1;
+}
+
 #endif /* _LINUX_PCI_H_ */
index 70f839d..5a5abf1 100644 (file)
@@ -80,4 +80,10 @@ pm_runtime_get_if_active(struct device *dev, bool x)
        return -EINVAL;
 }
 
+static inline int
+pm_runtime_suspended(struct device *dev)
+{
+       return 0;
+}
+
 #endif