[PATCH v4 0/4] media: wave5: fix runtime PM error handling

From: Jiale Yao

Date: Fri Oct 23 2026 - 05:33:03 EST


The Wave5 decoder, encoder, and close paths assume that
pm_runtime_resume_and_get() always succeeds. Runtime resume can fail while
enabling the VPU clocks, after which firmware commands can access unavailable
registers and cleanup paths can drop references that were not acquired.

Check runtime resume results before hardware access. On errors from callbacks
that cannot return an error, return queued buffers and complete the active
job. When closing an instance, still release host-side resources and return
-EIO so the common release path completes instance cleanup.

media-next already checks the decoder destination queue resume result, but
uses vb2_buffer_done() instead of the mem2mem completion helper. This series
keeps the remaining decoder resume fixes separate from that interface fix.

Changes in v4:
- Fail both decoder queues and stop the instance when runtime resume fails in
device_run(), preventing repeated scheduling of the same job.
- Add the Fixes tag and Brandon Brnich's Tested-by tag to patch 2.
- Add Jackson Lee's Reviewed-by tag to the close-path patch.

Changes in v3:
- Move the encoder STOP state transition before runtime resume in
stop_streaming(), so a resume failure cannot leave the instance in
PIC_RUN.
- Factor decoder host-resource cleanup into a helper and return -EIO
directly after resume failure, avoiding an unheld mutex unlock and an
unmatched runtime PM put.
- Add Jackson Lee's Reviewed-by tag to the encoder patch.
- Keep the m2m buffer completion helper patch unchanged.

Changes in v2:
- Rebase on media-next.
- Split the decoder changes: fix the remaining unchecked resume results
separately from the existing destination-buffer completion path.
- Use v4l2_m2m_buf_done() for the destination-buffer completion path.
- Stop the encoder and fail both queues on a runtime resume failure to
prevent the mem2mem scheduler from repeatedly running a failed job.
- Rebase the close-path cleanup on the already accepted runtime PM
reference leak fix.
- Drop v1 patch 4 because its runtime PM reference leak fix is already
accepted upstream.

Jiale Yao (4):
media: wave5: handle remaining decoder runtime resume failures
media: wave5: use m2m buffer completion helper
media: wave5: handle encoder runtime resume failures
media: wave5: handle runtime resume failure when closing

.../chips-media/wave5/wave5-vpu-dec.c | 57 +++++++++++++++++--
.../chips-media/wave5/wave5-vpu-enc.c | 35 ++++++++++--
.../platform/chips-media/wave5/wave5-vpuapi.c | 47 +++++++++------
3 files changed, 111 insertions(+), 28 deletions(-)


base-commit: d7e7bca7169873b46e857c025c10f3336c1258d8
--
2.34.1