Skip to contentSkip to conversation

accel/ivpu: Ensure rpm_runtime_put in case of engine reset/resume fail

PATCH In review Karol Wachowski 2 participants 3 messages Sep 15, 2025 – Sep 16, 2025

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Ensure rpm_runtime_put in case of engine reset/resume fail

Previously, aborting work could return early after engine reset or resume failure, skipping the necessary runtime_put cleanup leaving the device with incorrect reference count breaking runtime power management state.

Replace early returns with goto statements to ensure runtime_put is always executed.

---
 drivers/accel/ivpu/ivpu_job.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/accel/ivpu/ivpu_job.c +2 -2
index 521b7ac6e35e..044268d0fc87 100644
@@ -1050,7 +1050,7 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
 
 	if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW)
 		if (ivpu_jsm_reset_engine(vdev, 0))
-			return;
+			goto runtime_put;
 
 	mutex_lock(&vdev->context_list_lock);
 	xa_for_each(&vdev->context_xa, ctx_id, file_priv) {
@@ -1074,7 +1074,7 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
 		goto runtime_put;
 
 	if (ivpu_jsm_hws_resume_engine(vdev, 0))
-		return;
+		goto runtime_put;
 	/*
 	 * In hardware scheduling mode NPU already has stopped processing jobs
 	 * and won't send us any further notifications, thus we have to free job related resources
Signature · 1 line
2.43.0
#1 lore raw

This looks a bug fix. Is adding 'Fixes:' tag better?

Quoted 34 lines · Karol Wachowski

Previously, aborting work could return early after engine reset or resume failure, skipping the necessary runtime_put cleanup leaving the device with incorrect reference count breaking runtime power management state.

Replace early returns with goto statements to ensure runtime_put is always executed.

---
  drivers/accel/ivpu/ivpu_job.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/accel/ivpu/ivpu_job.c +2 -2
index 521b7ac6e35e..044268d0fc87 100644
@@ -1050,7 +1050,7 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
 
  	if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW)
  		if (ivpu_jsm_reset_engine(vdev, 0))
-			return;
+			goto runtime_put;
 
  	mutex_lock(&vdev->context_list_lock);
  	xa_for_each(&vdev->context_xa, ctx_id, file_priv) {
@@ -1074,7 +1074,7 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
  		goto runtime_put;
 
  	if (ivpu_jsm_hws_resume_engine(vdev, 0))
-		return;
+		goto runtime_put;
  	/*
  	 * In hardware scheduling mode NPU already has stopped processing jobs
  	 * and won't send us any further notifications, thus we have to free job related resources
author maintainer
#2 lore raw

Thanks, I've sent v1 version with added fixes tag.

Karol

Quoted 41 lines · Lizhi Hou

This looks a bug fix. Is adding 'Fixes:' tag better?

Quoted 38 lines · Karol Wachowski

Previously, aborting work could return early after engine reset or resume
failure, skipping the necessary runtime_put cleanup leaving the device with incorrect reference count breaking runtime power management state.

Replace early returns with goto statements to ensure runtime_put is always
executed.

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

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/accel/ivpu/ivpu_job.c +2 -2
index 521b7ac6e35e..044268d0fc87 100644
@@ -1050,7 +1050,7 @@ void ivpu_context_abort_work_fn(struct
 work_struct *work)
         if (vdev->fw->sched_mode == VPU_SCHEDULING_MODE_HW)
           if (ivpu_jsm_reset_engine(vdev, 0))
-            return;
+            goto runtime_put;
         mutex_lock(&vdev->context_list_lock);
       xa_for_each(&vdev->context_xa, ctx_id, file_priv) {
@@ -1074,7 +1074,7 @@ void ivpu_context_abort_work_fn(struct
 work_struct *work)
           goto runtime_put;
         if (ivpu_jsm_hws_resume_engine(vdev, 0))
-        return;
+        goto runtime_put;
       /*
        * In hardware scheduling mode NPU already has stopped

processing jobs
       * and won't send us any further notifications, thus we have to free job related resources