[PATCH 0/3] media: imx8mq-mipi-csi2: Simplify power management handling

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Oct 7 14:43:43 PDT 2024


Hi Guo,

On Mon, Sep 30, 2024 at 07:51:45AM +0000, G.N. Zhou (OSS) wrote:
> On Monday, September 30, 2024 3:22 PM, Laurent Pinchart wrote:
> > On Mon, Sep 30, 2024 at 07:08:09AM +0000, G.N. Zhou (OSS) wrote:
> > > On Sunday, September 29, 2024 9:44 PM, Laurent Pinchart wrote:
> > > >
> > > > Hello,
> > > >
> > > > This small patch series is a reaction to "[PATCH] media: nxp:
> > > > imx8mq-mipi-csi2: Fix CSI clocks always enabled issue" ([1]).
> > > > Instead of making the PM handling more complex, I think it can be greatly simplified.
> > > >
> > > > I have only compile-tested the patches. Guoniu, could you give this a try ?
> > >
> > > After applying the patches and test both on iMX8ULP.
> > >
> > > For iMX8ULP, it will cause kernel dump when access CSI registers and
> > > system hang during do suspend/resume while streaming Need to add
> > > system suspend/resume handlers and call
> > > pm_runtime_force_suspend/resume in the handlers.
> > >
> > > I tried to debug this issue and found pm runtime callback won't be
> > > called when system resume. The state of power domain won't enabled.
> > 
> > Thank you for testing.
> > 
> > I wonder if this could be caused by the CSI bridge being resumed from system
> > sleep before the CSI-2 receiver. Could you check if that's the case ? If so, does the
> > following change fix the issue ?
> 
> I tested on iMX8ULP which don't use CSI bridge but ISI, not iMX8MQ. In ISI driver, I notice that
> it already handler the device relationship when subdev bound like bellow:
> 
> link = device_link_add(isi->dev, sd->dev, DL_FLAG_STATELESS);
> if (!link) {
>         dev_err(isi->dev,
>                 "Failed to create device link to source %s\n", sd->name);
>         return -EINVAL;
> }

Ah yes indeed with the ISI it should already be handled.

I can't test this on hardware now as I'm travelling. Is the system hang
happening at suspend or resume time ? What is the order of the
suspend/resume handlers calls for the imx8-isi driver and the
imx8mq-mipi-csi2 driver ?

> For iMX8MQ, I'm trying to enable it, but meet some problems, so can't
> give you the results in short time.
> 
> > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c
> > b/drivers/media/platform/nxp/imx7-media-csi.c
> > index 9566ff738818..c66b0621e395 100644
> > --- a/drivers/media/platform/nxp/imx7-media-csi.c
> > +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> > @@ -2057,9 +2057,22 @@ static int imx7_csi_notify_bound(struct
> > v4l2_async_notifier *notifier,  {
> >  	struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier);
> >  	struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK];
> > +	struct device_link *link;
> > 
> >  	csi->src_sd = sd;
> > 
> > +	/*
> > +	 * Enforce suspend/resume ordering between the source (supplier) and
> > +	 * the CSI (consumer). The source will be suspended before and resume
> > +	 * after the CSI.
> > +	 */
> > +	link = device_link_add(csi->dev, sd->dev, DL_FLAG_STATELESS);
> > +	if (!link) {
> > +		dev_err(csi->dev,
> > +			"Failed to create device link to source %s\n", sd->name);
> > +		return -EINVAL;
> > +	}
> > +
> >  	return v4l2_create_fwnode_links_to_pad(sd, sink, MEDIA_LNK_FL_ENABLED |
> >  					       MEDIA_LNK_FL_IMMUTABLE);
> >  }
> > 
> > > > [1] https://lore.kernel.org/r/20240929101635.1648234-1-guoniu.zhou@oss.nxp.com
> > > >
> > > > Laurent Pinchart (3):
> > > >   media: imx8mq-mipi-csi2: Drop stream stop/restart at suspend/resume time
> > > >   media: imx8mq-mipi-csi2: Drop ST_SUSPENDED guard
> > > >   media: imx8mq-mipi-csi2: Drop system suspend/resume handlers
> > > >
> > > >  drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 113 ++----------------
> > > >  1 file changed, 10 insertions(+), 103 deletions(-)
> > > >
> > > >
> > > > base-commit: 81ee62e8d09ee3c7107d11c8bbfd64073ab601ad

-- 
Regards,

Laurent Pinchart



More information about the linux-arm-kernel mailing list