* [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled issue
@ 2024-09-29 10:16 guoniu.zhou
2024-09-29 12:00 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: guoniu.zhou @ 2024-09-29 10:16 UTC (permalink / raw)
To: rmfrfs, laurent.pinchart, martink, kernel, mchehab, shawnguo,
s.hauer, kernel, festevam
Cc: imx, linux-media, linux-arm-kernel, linux-kernel
From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
Fix CSI clocks always enabled issue after run system suspend/resume.
The clocks for CSI will be enabled in imx8mq_mipi_csi_pm_resume()
when system resume and the state of CSI will be set to ST_POWERED.
It not only cause clock always enabled issue but also system hang
issue on iMX8ULP platform since imx8mq_mipi_csi_pm_suspend() will
access CSI registers if run system suspend/resume again, but the
CSI power domain is not active.
In order to fix this issue, using pm_runtime_force_suspend/resume
instead of calling imx8mq_mipi_csi_pm_suspend/resume directly.
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
---
drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index d4a6c5532969..15029bb81b35 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -697,8 +697,11 @@ static int imx8mq_mipi_csi_suspend(struct device *dev)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct csi_state *state = mipi_sd_to_csi2_state(sd);
+ int ret;
- imx8mq_mipi_csi_pm_suspend(dev);
+ ret = pm_runtime_force_suspend(dev);
+ if (ret < 0)
+ return ret;
state->state |= ST_SUSPENDED;
@@ -713,7 +716,7 @@ static int imx8mq_mipi_csi_resume(struct device *dev)
if (!(state->state & ST_SUSPENDED))
return 0;
- return imx8mq_mipi_csi_pm_resume(dev);
+ return pm_runtime_force_resume(dev);
}
static int imx8mq_mipi_csi_runtime_suspend(struct device *dev)
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled issue
2024-09-29 10:16 [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled issue guoniu.zhou
@ 2024-09-29 12:00 ` Laurent Pinchart
2024-09-29 12:40 ` G.N. Zhou (OSS)
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2024-09-29 12:00 UTC (permalink / raw)
To: guoniu.zhou
Cc: rmfrfs, martink, kernel, mchehab, shawnguo, s.hauer, kernel,
festevam, imx, linux-media, linux-arm-kernel, linux-kernel
Hi Guoniu,
Thank you for the patch.
On Sun, Sep 29, 2024 at 06:16:35PM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
>
> Fix CSI clocks always enabled issue after run system suspend/resume.
>
> The clocks for CSI will be enabled in imx8mq_mipi_csi_pm_resume()
> when system resume and the state of CSI will be set to ST_POWERED.
> It not only cause clock always enabled issue but also system hang
> issue on iMX8ULP platform since imx8mq_mipi_csi_pm_suspend() will
> access CSI registers if run system suspend/resume again, but the
> CSI power domain is not active.
>
> In order to fix this issue, using pm_runtime_force_suspend/resume
> instead of calling imx8mq_mipi_csi_pm_suspend/resume directly.
I think you can simplify suspend/resume handling in the driver by
dropping the system suspend/resume handlers. At system suspend time the
device should already be stopped, because the top-level driver (the CSI
bridge in the i.MX8MQ) should have stopped the pipeline. Similarly, at
system resume time, there should be no need to restart streaming, as the
top-level driver will control that.
I'll send a patch and CC you, could you give it a try ?
> Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> ---
> drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> index d4a6c5532969..15029bb81b35 100644
> --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> @@ -697,8 +697,11 @@ static int imx8mq_mipi_csi_suspend(struct device *dev)
> {
> struct v4l2_subdev *sd = dev_get_drvdata(dev);
> struct csi_state *state = mipi_sd_to_csi2_state(sd);
> + int ret;
>
> - imx8mq_mipi_csi_pm_suspend(dev);
> + ret = pm_runtime_force_suspend(dev);
> + if (ret < 0)
> + return ret;
>
> state->state |= ST_SUSPENDED;
>
> @@ -713,7 +716,7 @@ static int imx8mq_mipi_csi_resume(struct device *dev)
> if (!(state->state & ST_SUSPENDED))
> return 0;
>
> - return imx8mq_mipi_csi_pm_resume(dev);
> + return pm_runtime_force_resume(dev);
> }
>
> static int imx8mq_mipi_csi_runtime_suspend(struct device *dev)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled issue
2024-09-29 12:00 ` Laurent Pinchart
@ 2024-09-29 12:40 ` G.N. Zhou (OSS)
0 siblings, 0 replies; 3+ messages in thread
From: G.N. Zhou (OSS) @ 2024-09-29 12:40 UTC (permalink / raw)
To: Laurent Pinchart, G.N. Zhou (OSS)
Cc: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm,
mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, imx@lists.linux.dev,
linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Hi Laurent,
> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Sent: Sunday, September 29, 2024 8:01 PM
> To: G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> Cc: rmfrfs@gmail.com; martink@posteo.de; kernel@puri.sm;
> mchehab@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de;
> kernel@pengutronix.de; festevam@gmail.com; imx@lists.linux.dev; linux-
> media@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled
> issue
>
> Hi Guoniu,
>
> Thank you for the patch.
>
> On Sun, Sep 29, 2024 at 06:16:35PM +0800, guoniu.zhou@oss.nxp.com wrote:
> > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> >
> > Fix CSI clocks always enabled issue after run system suspend/resume.
> >
> > The clocks for CSI will be enabled in imx8mq_mipi_csi_pm_resume() when
> > system resume and the state of CSI will be set to ST_POWERED.
> > It not only cause clock always enabled issue but also system hang
> > issue on iMX8ULP platform since imx8mq_mipi_csi_pm_suspend() will
> > access CSI registers if run system suspend/resume again, but the CSI
> > power domain is not active.
> >
> > In order to fix this issue, using pm_runtime_force_suspend/resume
> > instead of calling imx8mq_mipi_csi_pm_suspend/resume directly.
>
> I think you can simplify suspend/resume handling in the driver by dropping the
> system suspend/resume handlers. At system suspend time the device should
> already be stopped, because the top-level driver (the CSI bridge in the i.MX8MQ)
> should have stopped the pipeline. Similarly, at system resume time, there should
> be no need to restart streaming, as the top-level driver will control that.
>
> I'll send a patch and CC you, could you give it a try ?
Sure.
>
> > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> > ---
> > drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> > b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> > index d4a6c5532969..15029bb81b35 100644
> > --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> > +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> > @@ -697,8 +697,11 @@ static int imx8mq_mipi_csi_suspend(struct device
> > *dev) {
> > struct v4l2_subdev *sd = dev_get_drvdata(dev);
> > struct csi_state *state = mipi_sd_to_csi2_state(sd);
> > + int ret;
> >
> > - imx8mq_mipi_csi_pm_suspend(dev);
> > + ret = pm_runtime_force_suspend(dev);
> > + if (ret < 0)
> > + return ret;
> >
> > state->state |= ST_SUSPENDED;
> >
> > @@ -713,7 +716,7 @@ static int imx8mq_mipi_csi_resume(struct device *dev)
> > if (!(state->state & ST_SUSPENDED))
> > return 0;
> >
> > - return imx8mq_mipi_csi_pm_resume(dev);
> > + return pm_runtime_force_resume(dev);
> > }
> >
> > static int imx8mq_mipi_csi_runtime_suspend(struct device *dev)
>
> --
> Regards,
>
> Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-29 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-29 10:16 [PATCH] media: nxp: imx8mq-mipi-csi2: Fix CSI clocks always enabled issue guoniu.zhou
2024-09-29 12:00 ` Laurent Pinchart
2024-09-29 12:40 ` G.N. Zhou (OSS)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.