Commit 0ec86718 authored by Jacek Lawrynowicz's avatar Jacek Lawrynowicz

accel/ivpu: Fix S3 system suspend when not idle

Wait for VPU to be idle in ivpu_pm_suspend_cb() before powering off
the device, so jobs are not lost and TDRs are not triggered after
resume.

Fixes: 852be13f ("accel/ivpu: Add PM support")
Signed-off-by: default avatarStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: default avatarJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230331113603.2802515-3-stanislaw.gruszka@linux.intel.com
parent 774e7cb5
...@@ -140,32 +140,28 @@ int ivpu_pm_suspend_cb(struct device *dev) ...@@ -140,32 +140,28 @@ int ivpu_pm_suspend_cb(struct device *dev)
{ {
struct drm_device *drm = dev_get_drvdata(dev); struct drm_device *drm = dev_get_drvdata(dev);
struct ivpu_device *vdev = to_ivpu_device(drm); struct ivpu_device *vdev = to_ivpu_device(drm);
int ret; unsigned long timeout;
ivpu_dbg(vdev, PM, "Suspend..\n"); ivpu_dbg(vdev, PM, "Suspend..\n");
ret = ivpu_suspend(vdev); timeout = jiffies + msecs_to_jiffies(vdev->timeout.tdr);
if (ret && vdev->pm->suspend_reschedule_counter) { while (!ivpu_hw_is_idle(vdev)) {
ivpu_dbg(vdev, PM, "Failed to enter idle, rescheduling suspend, retries left %d\n", cond_resched();
vdev->pm->suspend_reschedule_counter); if (time_after_eq(jiffies, timeout)) {
pm_schedule_suspend(dev, vdev->timeout.reschedule_suspend); ivpu_err(vdev, "Failed to enter idle on system suspend\n");
vdev->pm->suspend_reschedule_counter--;
return -EBUSY; return -EBUSY;
} else if (!vdev->pm->suspend_reschedule_counter) { }
ivpu_warn(vdev, "Failed to enter idle, force suspend\n");
ivpu_pm_prepare_cold_boot(vdev);
} else {
ivpu_pm_prepare_warm_boot(vdev);
} }
vdev->pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT; ivpu_suspend(vdev);
ivpu_pm_prepare_warm_boot(vdev);
pci_save_state(to_pci_dev(dev)); pci_save_state(to_pci_dev(dev));
pci_set_power_state(to_pci_dev(dev), PCI_D3hot); pci_set_power_state(to_pci_dev(dev), PCI_D3hot);
ivpu_dbg(vdev, PM, "Suspend done.\n"); ivpu_dbg(vdev, PM, "Suspend done.\n");
return ret; return 0;
} }
int ivpu_pm_resume_cb(struct device *dev) int ivpu_pm_resume_cb(struct device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment