Lines Matching full:vdev
27 static void ivpu_pm_prepare_cold_boot(struct ivpu_device *vdev) in ivpu_pm_prepare_cold_boot() argument
29 struct ivpu_fw_info *fw = vdev->fw; in ivpu_pm_prepare_cold_boot()
31 ivpu_cmdq_reset_all_contexts(vdev); in ivpu_pm_prepare_cold_boot()
32 ivpu_ipc_reset(vdev); in ivpu_pm_prepare_cold_boot()
33 ivpu_fw_load(vdev); in ivpu_pm_prepare_cold_boot()
37 static void ivpu_pm_prepare_warm_boot(struct ivpu_device *vdev) in ivpu_pm_prepare_warm_boot() argument
39 struct ivpu_fw_info *fw = vdev->fw; in ivpu_pm_prepare_warm_boot()
43 ivpu_pm_prepare_cold_boot(vdev); in ivpu_pm_prepare_warm_boot()
47 ivpu_dbg(vdev, FW_BOOT, "Save/restore entry point %llx", bp->save_restore_ret_address); in ivpu_pm_prepare_warm_boot()
51 static int ivpu_suspend(struct ivpu_device *vdev) in ivpu_suspend() argument
55 ret = ivpu_shutdown(vdev); in ivpu_suspend()
57 ivpu_err(vdev, "Failed to shutdown VPU: %d\n", ret); in ivpu_suspend()
64 static int ivpu_resume(struct ivpu_device *vdev) in ivpu_resume() argument
69 ret = ivpu_hw_power_up(vdev); in ivpu_resume()
71 ivpu_err(vdev, "Failed to power up HW: %d\n", ret); in ivpu_resume()
75 ret = ivpu_mmu_enable(vdev); in ivpu_resume()
77 ivpu_err(vdev, "Failed to resume MMU: %d\n", ret); in ivpu_resume()
78 ivpu_hw_power_down(vdev); in ivpu_resume()
82 ret = ivpu_boot(vdev); in ivpu_resume()
84 ivpu_mmu_disable(vdev); in ivpu_resume()
85 ivpu_hw_power_down(vdev); in ivpu_resume()
86 if (!ivpu_fw_is_cold_boot(vdev)) { in ivpu_resume()
87 ivpu_warn(vdev, "Failed to resume the FW: %d. Retrying cold boot..\n", ret); in ivpu_resume()
88 ivpu_pm_prepare_cold_boot(vdev); in ivpu_resume()
91 ivpu_err(vdev, "Failed to resume the FW: %d\n", ret); in ivpu_resume()
101 struct ivpu_device *vdev = pm->vdev; in ivpu_pm_recovery_work() local
106 ret = pci_try_reset_function(to_pci_dev(vdev->drm.dev)); in ivpu_pm_recovery_work()
107 if (ret == -EAGAIN && !drm_dev_is_unplugged(&vdev->drm)) { in ivpu_pm_recovery_work()
113 ivpu_err(vdev, "Failed to reset VPU: %d\n", ret); in ivpu_pm_recovery_work()
115 kobject_uevent_env(&vdev->drm.dev->kobj, KOBJ_CHANGE, evt); in ivpu_pm_recovery_work()
118 void ivpu_pm_schedule_recovery(struct ivpu_device *vdev) in ivpu_pm_schedule_recovery() argument
120 struct ivpu_pm_info *pm = vdev->pm; in ivpu_pm_schedule_recovery()
123 ivpu_err(vdev, "Recovery not available when disable_recovery param is set\n"); in ivpu_pm_schedule_recovery()
127 if (ivpu_is_fpga(vdev)) { in ivpu_pm_schedule_recovery()
128 ivpu_err(vdev, "Recovery not available on FPGA\n"); in ivpu_pm_schedule_recovery()
134 ivpu_hw_irq_disable(vdev); in ivpu_pm_schedule_recovery()
142 struct ivpu_device *vdev = to_ivpu_device(drm); in ivpu_pm_suspend_cb() local
145 ivpu_dbg(vdev, PM, "Suspend..\n"); in ivpu_pm_suspend_cb()
147 timeout = jiffies + msecs_to_jiffies(vdev->timeout.tdr); in ivpu_pm_suspend_cb()
148 while (!ivpu_hw_is_idle(vdev)) { in ivpu_pm_suspend_cb()
151 ivpu_err(vdev, "Failed to enter idle on system suspend\n"); in ivpu_pm_suspend_cb()
156 ivpu_suspend(vdev); in ivpu_pm_suspend_cb()
157 ivpu_pm_prepare_warm_boot(vdev); in ivpu_pm_suspend_cb()
162 ivpu_dbg(vdev, PM, "Suspend done.\n"); in ivpu_pm_suspend_cb()
170 struct ivpu_device *vdev = to_ivpu_device(drm); in ivpu_pm_resume_cb() local
173 ivpu_dbg(vdev, PM, "Resume..\n"); in ivpu_pm_resume_cb()
178 ret = ivpu_resume(vdev); in ivpu_pm_resume_cb()
180 ivpu_err(vdev, "Failed to resume: %d\n", ret); in ivpu_pm_resume_cb()
182 ivpu_dbg(vdev, PM, "Resume done.\n"); in ivpu_pm_resume_cb()
190 struct ivpu_device *vdev = to_ivpu_device(drm); in ivpu_pm_runtime_suspend_cb() local
193 ivpu_dbg(vdev, PM, "Runtime suspend..\n"); in ivpu_pm_runtime_suspend_cb()
195 if (!ivpu_hw_is_idle(vdev) && vdev->pm->suspend_reschedule_counter) { in ivpu_pm_runtime_suspend_cb()
196 ivpu_dbg(vdev, PM, "Failed to enter idle, rescheduling suspend, retries left %d\n", in ivpu_pm_runtime_suspend_cb()
197 vdev->pm->suspend_reschedule_counter); in ivpu_pm_runtime_suspend_cb()
198 pm_schedule_suspend(dev, vdev->timeout.reschedule_suspend); in ivpu_pm_runtime_suspend_cb()
199 vdev->pm->suspend_reschedule_counter--; in ivpu_pm_runtime_suspend_cb()
203 ret = ivpu_suspend(vdev); in ivpu_pm_runtime_suspend_cb()
205 ivpu_err(vdev, "Failed to set suspend VPU: %d\n", ret); in ivpu_pm_runtime_suspend_cb()
207 if (!vdev->pm->suspend_reschedule_counter) { in ivpu_pm_runtime_suspend_cb()
208 ivpu_warn(vdev, "VPU failed to enter idle, force suspended.\n"); in ivpu_pm_runtime_suspend_cb()
209 ivpu_pm_prepare_cold_boot(vdev); in ivpu_pm_runtime_suspend_cb()
211 ivpu_pm_prepare_warm_boot(vdev); in ivpu_pm_runtime_suspend_cb()
214 vdev->pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT; in ivpu_pm_runtime_suspend_cb()
216 ivpu_dbg(vdev, PM, "Runtime suspend done.\n"); in ivpu_pm_runtime_suspend_cb()
224 struct ivpu_device *vdev = to_ivpu_device(drm); in ivpu_pm_runtime_resume_cb() local
227 ivpu_dbg(vdev, PM, "Runtime resume..\n"); in ivpu_pm_runtime_resume_cb()
229 ret = ivpu_resume(vdev); in ivpu_pm_runtime_resume_cb()
231 ivpu_err(vdev, "Failed to set RESUME state: %d\n", ret); in ivpu_pm_runtime_resume_cb()
233 ivpu_dbg(vdev, PM, "Runtime resume done.\n"); in ivpu_pm_runtime_resume_cb()
238 int ivpu_rpm_get(struct ivpu_device *vdev) in ivpu_rpm_get() argument
242 ret = pm_runtime_resume_and_get(vdev->drm.dev); in ivpu_rpm_get()
243 if (!drm_WARN_ON(&vdev->drm, ret < 0)) in ivpu_rpm_get()
244 vdev->pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT; in ivpu_rpm_get()
249 void ivpu_rpm_put(struct ivpu_device *vdev) in ivpu_rpm_put() argument
251 pm_runtime_mark_last_busy(vdev->drm.dev); in ivpu_rpm_put()
252 pm_runtime_put_autosuspend(vdev->drm.dev); in ivpu_rpm_put()
257 struct ivpu_device *vdev = pci_get_drvdata(pdev); in ivpu_pm_reset_prepare_cb() local
259 pm_runtime_get_sync(vdev->drm.dev); in ivpu_pm_reset_prepare_cb()
261 ivpu_dbg(vdev, PM, "Pre-reset..\n"); in ivpu_pm_reset_prepare_cb()
262 atomic_inc(&vdev->pm->reset_counter); in ivpu_pm_reset_prepare_cb()
263 atomic_set(&vdev->pm->in_reset, 1); in ivpu_pm_reset_prepare_cb()
264 ivpu_prepare_for_reset(vdev); in ivpu_pm_reset_prepare_cb()
265 ivpu_hw_reset(vdev); in ivpu_pm_reset_prepare_cb()
266 ivpu_pm_prepare_cold_boot(vdev); in ivpu_pm_reset_prepare_cb()
267 ivpu_jobs_abort_all(vdev); in ivpu_pm_reset_prepare_cb()
268 ivpu_dbg(vdev, PM, "Pre-reset done.\n"); in ivpu_pm_reset_prepare_cb()
273 struct ivpu_device *vdev = pci_get_drvdata(pdev); in ivpu_pm_reset_done_cb() local
276 ivpu_dbg(vdev, PM, "Post-reset..\n"); in ivpu_pm_reset_done_cb()
277 ret = ivpu_resume(vdev); in ivpu_pm_reset_done_cb()
279 ivpu_err(vdev, "Failed to set RESUME state: %d\n", ret); in ivpu_pm_reset_done_cb()
280 atomic_set(&vdev->pm->in_reset, 0); in ivpu_pm_reset_done_cb()
281 ivpu_dbg(vdev, PM, "Post-reset done.\n"); in ivpu_pm_reset_done_cb()
283 pm_runtime_put_autosuspend(vdev->drm.dev); in ivpu_pm_reset_done_cb()
286 int ivpu_pm_init(struct ivpu_device *vdev) in ivpu_pm_init() argument
288 struct device *dev = vdev->drm.dev; in ivpu_pm_init()
289 struct ivpu_pm_info *pm = vdev->pm; in ivpu_pm_init()
291 pm->vdev = vdev; in ivpu_pm_init()
301 else if (ivpu_is_silicon(vdev)) in ivpu_pm_init()
309 void ivpu_pm_cancel_recovery(struct ivpu_device *vdev) in ivpu_pm_cancel_recovery() argument
311 cancel_work_sync(&vdev->pm->recovery_work); in ivpu_pm_cancel_recovery()
314 void ivpu_pm_enable(struct ivpu_device *vdev) in ivpu_pm_enable() argument
316 struct device *dev = vdev->drm.dev; in ivpu_pm_enable()
324 void ivpu_pm_disable(struct ivpu_device *vdev) in ivpu_pm_disable() argument
326 pm_runtime_get_noresume(vdev->drm.dev); in ivpu_pm_disable()
327 pm_runtime_forbid(vdev->drm.dev); in ivpu_pm_disable()