[PATCH 1/2] media: amphion: handle core runtime resume failures
From: Jiale Yao
Date: Mon Oct 19 2026 - 04:28:23 EST
The core request and resume paths continue with VPU state and hardware
access after pm_runtime_resume_and_get() fails. A failed runtime resume
leaves the device unavailable, so those accesses can fail and the later
runtime PM put does not match an acquired reference.
Check the runtime resume result before accessing the VPU. Release the
core lock and return without touching the hardware when resume fails.
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/media/platform/amphion/vpu_core.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/amphion/vpu_core.c b/drivers/media/platform/amphion/vpu_core.c
index ad54f014d8..3d71442807 100644
--- a/drivers/media/platform/amphion/vpu_core.c
+++ b/drivers/media/platform/amphion/vpu_core.c
@@ -372,7 +372,12 @@ struct vpu_core *vpu_request_core(struct vpu_dev *vpu, enum vpu_core_type type)
goto exit;
mutex_lock(&core->lock);
- pm_runtime_resume_and_get(core->dev);
+ ret = pm_runtime_resume_and_get(core->dev);
+ if (ret < 0) {
+ mutex_unlock(&core->lock);
+ core = NULL;
+ goto exit;
+ }
if (core->state == VPU_CORE_DEINIT) {
if (vpu_iface_get_power_state(core))
@@ -760,7 +765,11 @@ static int __maybe_unused vpu_core_resume(struct device *dev)
int ret = 0;
mutex_lock(&core->lock);
- pm_runtime_resume_and_get(dev);
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0) {
+ mutex_unlock(&core->lock);
+ return ret;
+ }
vpu_core_get_vpu(core);
if (core->request_count) {
--
2.34.1