drm/amdgpu: add a dev_pm_ops prepare callback (v2)
Subsystems (2)
PATCH 1/2 drm/amdgpu: add a dev_pm_ops prepare callback (v2)
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +24 -0
@@ -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"
@@ -1271,6 +1272,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);
@@ -1484,6 +1506,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,
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: enable DPM_FLAG_MAY_SKIP_RESUME and DPM_FLAG_SMART_SUSPEND flags (v2)
Once the device has runtime suspended, we don't need to power it back up again for system suspend. Likewise for resume, we don't to power up the device again on resume only to power it back off again via runtime pm because it's still idle.
v2: add DPM_FLAG_SMART_PREPARE as well
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -0
@@ -206,6 +206,13 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)if (amdgpu_device_supports_atpx (dev) && !amdgpu_is_atpx_hybrid ())dev_pm_set_driver_flags (dev->dev,DPM_FLAG_NO_DIRECT_COMPLETE ); +/* we want direct complete for BOCO */ +if ((amdgpu_device_supports_atpx (dev) && +amdgpu_is_atpx_hybrid ()) || +amdgpu_device_supports_boco (dev)) +dev_pm_set_driver_flags (dev->dev,DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND | +DPM_FLAG_MAY_SKIP_RESUME );pm_runtime_use_autosuspend (dev->dev);pm_runtime_set_autosuspend_delay (dev->dev,5000 );pm_runtime_allow (dev->dev);
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx