From: Laurent Pinchart Date: Thu, 21 Aug 2025 13:51:23 +0000 (+0300) Subject: media: nxp: imx8-isi: m2m: Delay power up until streamon X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=aec0f43f1429641e8a94d54aaecd16527b589486;p=users%2Fhch%2Fmisc.git media: nxp: imx8-isi: m2m: Delay power up until streamon There's no need to power up the device when userspace opens it. Delay the operation until streamon. Link: https://lore.kernel.org/r/20250821135123.29462-2-laurent.pinchart@ideasonboard.com Signed-off-by: Laurent Pinchart Reviewed-by: Guoniu Zhou Tested-by: Guoniu Zhou Reviewed-by: Frank Li Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c index a8b10d944d69..00afcbfbdde4 100644 --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c @@ -250,6 +250,10 @@ static int mxc_isi_m2m_vb2_prepare_streaming(struct vb2_queue *q) if (m2m->usage_count == INT_MAX) return -EOVERFLOW; + ret = pm_runtime_resume_and_get(m2m->isi->dev); + if (ret) + return ret; + /* * Acquire the pipe and initialize the channel with the first user of * the M2M device. @@ -263,7 +267,7 @@ static int mxc_isi_m2m_vb2_prepare_streaming(struct vb2_queue *q) &mxc_isi_m2m_frame_write_done, bypass); if (ret) - return ret; + goto err_pm; mxc_isi_channel_get(m2m->pipe); } @@ -290,7 +294,8 @@ err_deinit: mxc_isi_channel_put(m2m->pipe); mxc_isi_channel_release(m2m->pipe); } - +err_pm: + pm_runtime_put(m2m->isi->dev); return ret; } @@ -350,6 +355,8 @@ static void mxc_isi_m2m_vb2_unprepare_streaming(struct vb2_queue *q) } WARN_ON(m2m->usage_count < 0); + + pm_runtime_put(m2m->isi->dev); } static const struct vb2_ops mxc_isi_m2m_vb2_qops = { @@ -643,16 +650,10 @@ static int mxc_isi_m2m_open(struct file *file) if (ret) goto err_ctx; - ret = pm_runtime_resume_and_get(m2m->isi->dev); - if (ret) - goto err_ctrls; - v4l2_fh_add(&ctx->fh, file); return 0; -err_ctrls: - mxc_isi_m2m_ctx_ctrls_delete(ctx); err_ctx: v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); err_fh: @@ -664,7 +665,6 @@ err_fh: static int mxc_isi_m2m_release(struct file *file) { - struct mxc_isi_m2m *m2m = video_drvdata(file); struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file); v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); @@ -676,8 +676,6 @@ static int mxc_isi_m2m_release(struct file *file) mutex_destroy(&ctx->vb2_lock); kfree(ctx); - pm_runtime_put(m2m->isi->dev); - return 0; }