Skip to content

Commit 7d4b4c7

Browse files
committed
accel/ivpu: Remove suspend_reschedule_counter
Don't retry runtime suspend. It is now expected to succeed on the first try. After autosuspend_delay passed, FW should already be idle and ready for warm suspend. Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Reviewed-by: Wachowski, Karol <karol.wachowski@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240611120433.1012423-4-jacek.lawrynowicz@linux.intel.com
1 parent b7ed87f commit 7d4b4c7

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

drivers/accel/ivpu/ivpu_pm.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -237,42 +237,35 @@ int ivpu_pm_runtime_suspend_cb(struct device *dev)
237237
{
238238
struct drm_device *drm = dev_get_drvdata(dev);
239239
struct ivpu_device *vdev = to_ivpu_device(drm);
240-
bool hw_is_idle = true;
241-
int ret;
240+
int ret, ret_d0i3;
241+
bool is_idle;
242242

243243
drm_WARN_ON(&vdev->drm, !xa_empty(&vdev->submitted_jobs_xa));
244244
drm_WARN_ON(&vdev->drm, work_pending(&vdev->pm->recovery_work));
245245

246246
ivpu_dbg(vdev, PM, "Runtime suspend..\n");
247247

248-
if (!ivpu_hw_is_idle(vdev) && vdev->pm->suspend_reschedule_counter) {
249-
ivpu_dbg(vdev, PM, "Failed to enter idle, rescheduling suspend, retries left %d\n",
250-
vdev->pm->suspend_reschedule_counter);
251-
pm_schedule_suspend(dev, vdev->timeout.reschedule_suspend);
252-
vdev->pm->suspend_reschedule_counter--;
253-
return -EAGAIN;
254-
}
248+
is_idle = ivpu_hw_is_idle(vdev);
249+
if (!is_idle)
250+
ivpu_err(vdev, "NPU is not idle before autosuspend\n");
255251

256-
if (!vdev->pm->suspend_reschedule_counter)
257-
hw_is_idle = false;
258-
else if (ivpu_jsm_pwr_d0i3_enter(vdev))
259-
hw_is_idle = false;
252+
ret_d0i3 = ivpu_jsm_pwr_d0i3_enter(vdev);
253+
if (ret_d0i3)
254+
ivpu_err(vdev, "Failed to prepare for d0i3: %d\n", ret_d0i3);
260255

261256
ret = ivpu_suspend(vdev);
262257
if (ret)
263258
ivpu_err(vdev, "Failed to suspend NPU: %d\n", ret);
264259

265-
if (!hw_is_idle) {
266-
ivpu_err(vdev, "NPU failed to enter idle, force suspended.\n");
260+
if (!is_idle || ret_d0i3) {
261+
ivpu_err(vdev, "Forcing cold boot due to previous errors\n");
267262
atomic_inc(&vdev->pm->reset_counter);
268263
ivpu_fw_log_dump(vdev);
269264
ivpu_pm_prepare_cold_boot(vdev);
270265
} else {
271266
ivpu_pm_prepare_warm_boot(vdev);
272267
}
273268

274-
vdev->pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT;
275-
276269
ivpu_dbg(vdev, PM, "Runtime suspend done.\n");
277270

278271
return 0;
@@ -300,8 +293,7 @@ int ivpu_rpm_get(struct ivpu_device *vdev)
300293
int ret;
301294

302295
ret = pm_runtime_resume_and_get(vdev->drm.dev);
303-
if (!drm_WARN_ON(&vdev->drm, ret < 0))
304-
vdev->pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT;
296+
drm_WARN_ON(&vdev->drm, ret < 0);
305297

306298
return ret;
307299
}
@@ -365,7 +357,6 @@ void ivpu_pm_init(struct ivpu_device *vdev)
365357
int delay;
366358

367359
pm->vdev = vdev;
368-
pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT;
369360

370361
init_rwsem(&pm->reset_lock);
371362
atomic_set(&pm->reset_pending, 0);

drivers/accel/ivpu/ivpu_pm.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
3-
* Copyright (C) 2020-2023 Intel Corporation
3+
* Copyright (C) 2020-2024 Intel Corporation
44
*/
55

66
#ifndef __IVPU_PM_H__
@@ -19,7 +19,6 @@ struct ivpu_pm_info {
1919
atomic_t reset_counter;
2020
atomic_t reset_pending;
2121
bool is_warmboot;
22-
u32 suspend_reschedule_counter;
2322
};
2423

2524
void ivpu_pm_init(struct ivpu_device *vdev);

0 commit comments

Comments
 (0)