Re:[PATCH 1/2] media: amphion: handle core runtime resume failures

From: jiale yao

Date: Mon Oct 19 2026 - 04:31:45 EST


At 2026-10-19 16:27:53, "Jiale Yao" <yaojiale02@xxxxxxx> wrote:
>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.
>

Fixes: f445014a2291 ("media: amphion: fix an issue that using pm_runtime_get_sync incorrectly")

>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