From: Jozef Wludzik <[email protected]> Acquire pm->reset_lock in ivpu_context_abort_work_fn() to prevent it from running concurrently with a device reset. If the lock cannot be acquired immediately, skip the abort work to avoid racing with reset. The device power management is disabled during reset.
Signed-off-by: Jozef Wludzik <[email protected]> Signed-off-by: Karol Wachowski <[email protected]> --- drivers/accel/ivpu/ivpu_job.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c index fa04f79e8f7b..245512bab523 100644 --- a/drivers/accel/ivpu/ivpu_job.c +++ b/drivers/accel/ivpu/ivpu_job.c @@ -1311,9 +1311,12 @@ void ivpu_context_abort_work_fn(struct work_struct *work) unsigned long ctx_id; unsigned long id; - if (drm_WARN_ON(&vdev->drm, pm_runtime_get_if_active(vdev->drm.dev) <= 0)) + if (!down_read_trylock(&vdev->pm->reset_lock)) return; + if (drm_WARN_ON(&vdev->drm, pm_runtime_get_if_active(vdev->drm.dev) <= 0)) + goto unlock; + if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW) if (reset_engine_and_mark_faulty_contexts(vdev)) goto runtime_put; @@ -1354,4 +1357,6 @@ void ivpu_context_abort_work_fn(struct work_struct *work) runtime_put: pm_runtime_put_autosuspend(vdev->drm.dev); +unlock: + up_read(&vdev->pm->reset_lock); } -- 2.43.0
