All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] drm/amdgpu: add a dev_pm_ops prepare callback (v2)
@ 2021-03-09  4:10 Alex Deucher
  2021-03-09  4:10 ` [PATCH 2/7] drm/amdgpu: enable DPM_FLAG_MAY_SKIP_RESUME and DPM_FLAG_SMART_SUSPEND flags (v2) Alex Deucher
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Alex Deucher @ 2021-03-09  4:10 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher

as per:
https://www.kernel.org/doc/html/latest/driver-api/pm/devices.html

The prepare callback is required to support the DPM_FLAG_SMART_SUSPEND
driver flag.  This allows runtime pm to auto complete when the
system goes into suspend avoiding a wake up on suspend and on resume.
Apply this for hybrid gfx and BOCO systems where d3cold is
provided by the ACPI platform.

v2: check if device is runtime suspended in prepare.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index aecf7baf219a..8d4fbee01011 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -36,6 +36,7 @@
 #include <linux/vga_switcheroo.h>
 #include <drm/drm_probe_helper.h>
 #include <linux/mmu_notifier.h>
+#include <linux/suspend.h>
 
 #include "amdgpu.h"
 #include "amdgpu_irq.h"
@@ -1293,6 +1294,27 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
 	adev->mp1_state = PP_MP1_STATE_NONE;
 }
 
+static int amdgpu_pmops_prepare(struct device *dev)
+{
+	struct drm_device *drm_dev = dev_get_drvdata(dev);
+
+	/* Return a positive number here so
+	 * DPM_FLAG_SMART_SUSPEND works properly
+	 */
+	if ((amdgpu_device_supports_atpx(drm_dev) &&
+	    amdgpu_is_atpx_hybrid()) ||
+	    amdgpu_device_supports_boco(drm_dev))
+		return pm_runtime_suspended(dev) &&
+			pm_suspend_via_firmware();
+
+	return 0;
+}
+
+static void amdgpu_pmops_complete(struct device *dev)
+{
+	/* nothing to do */
+}
+
 static int amdgpu_pmops_suspend(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
@@ -1511,6 +1533,8 @@ long amdgpu_drm_ioctl(struct file *filp,
 }
 
 static const struct dev_pm_ops amdgpu_pm_ops = {
+	.prepare = amdgpu_pmops_prepare,
+	.complete = amdgpu_pmops_complete,
 	.suspend = amdgpu_pmops_suspend,
 	.resume = amdgpu_pmops_resume,
 	.freeze = amdgpu_pmops_freeze,
-- 
2.29.2

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-03-10 20:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09  4:10 [PATCH 1/7] drm/amdgpu: add a dev_pm_ops prepare callback (v2) Alex Deucher
2021-03-09  4:10 ` [PATCH 2/7] drm/amdgpu: enable DPM_FLAG_MAY_SKIP_RESUME and DPM_FLAG_SMART_SUSPEND flags (v2) Alex Deucher
2021-03-09  4:10 ` [PATCH 3/7] drm/amdgpu: disentangle HG systems from vgaswitcheroo Alex Deucher
2021-03-10  8:42   ` Quan, Evan
2021-03-09  4:10 ` [PATCH 4/7] drm/amdgpu: track what pmops flow we are in Alex Deucher
2021-03-09  6:19   ` Lazar, Lijo
2021-03-09 15:47     ` Alex Deucher
2021-03-09 17:25       ` Bhardwaj, Rajneesh
2021-03-10 10:16         ` Liang, Prike
2021-03-10 13:19           ` Bhardwaj, Rajneesh
2021-03-10 20:00         ` Alex Deucher
2021-03-09  4:10 ` [PATCH 5/7] drm/amdgpu: don't evict vram on APUs for suspend to ram Alex Deucher
2021-03-09  4:10 ` [PATCH 6/7] drm/amdgpu: clean up S0ix logic Alex Deucher
2021-03-09  4:10 ` [PATCH 7/7] drm/amdgpu: clean up non-DC suspend/resume handling Alex Deucher
2021-03-10  9:05   ` Quan, Evan
2021-03-10  8:28 ` [PATCH 1/7] drm/amdgpu: add a dev_pm_ops prepare callback (v2) Quan, Evan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.