From: kettenis Date: Fri, 16 Aug 2024 10:46:46 +0000 (+0000) Subject: Hook up a few more bits of suspend/resume power management code. This X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cc2e793a64b07ac2beb7dc9ae90904cb05e753d7;p=openbsd Hook up a few more bits of suspend/resume power management code. This 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@ --- diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c index 17038e2472d..e6b273789b2 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c @@ -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; } diff --git a/sys/dev/pci/drm/include/linux/pci.h b/sys/dev/pci/drm/include/linux/pci.h index bfa2140d58b..330439856b6 100644 --- a/sys/dev/pci/drm/include/linux/pci.h +++ b/sys/dev/pci/drm/include/linux/pci.h @@ -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_ */ diff --git a/sys/dev/pci/drm/include/linux/pm_runtime.h b/sys/dev/pci/drm/include/linux/pm_runtime.h index 70f839dd146..5a5abf1dee5 100644 --- a/sys/dev/pci/drm/include/linux/pm_runtime.h +++ b/sys/dev/pci/drm/include/linux/pm_runtime.h @@ -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