Skip to contentSkip to conversation

accel/ivpu: Synchronize context abort work with device reset

PATCH In review Karol Wachowski 2 participants 3 messages Sep 14 – Sep 17

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Synchronize context abort work with device reset

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.

---
 drivers/accel/ivpu/ivpu_job.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_job.c +6 -1
index fa04f79e8f7b..245512bab523 100644
@@ -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);
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Karol Wachowski

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.

Quoted 5 lines
---
  drivers/accel/ivpu/ivpu_job.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
author maintainer Applied
#2 lore raw
Quoted 10 lines · Dawid Osuchowski
Quoted 7 lines · Karol Wachowski

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.

Thanks, applied to drm-misc-next.

Quoted 5 lines
Quoted 5 lines

---
  drivers/accel/ivpu/ivpu_job.c | 7 ++++++-

  1 file changed, 6 insertions(+), 1 deletion(-)