All of lore.kernel.org
 help / color / mirror / Atom feed
From: dinghao.liu@zju.edu.cn
To: "Rui Miguel Silva" <rmfrfs@gmail.com>
Cc: kjlu@umn.edu, "Steve Longerbeam" <slongerbeam@gmail.com>,
	 "Philipp Zabel" <p.zabel@pengutronix.de>,
	 "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	 "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	 "Shawn Guo" <shawnguo@kernel.org>,
	 "Sascha Hauer" <s.hauer@pengutronix.de>,
	 "Pengutronix Kernel Team" <kernel@pengutronix.de>,
	 "Fabio Estevam" <festevam@gmail.com>,
	 "NXP Linux Team" <linux-imx@nxp.com>,
	linux-media@vger.kernel.org,  linux-staging@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH] media: imx: imx7-mipi-csis: Fix runtime PM imbalance in mipi_csis_s_stream
Date: Fri, 9 Apr 2021 15:59:53 +0800 (GMT+08:00)	[thread overview]
Message-ID: <5025467a.453b6.178b5a50321.Coremail.dinghao.liu@zju.edu.cn> (raw)
In-Reply-To: <20210408135702.f7ikjvwirvtzsarv@arch-thunder.localdomain>

> Hi Liu,
> Thanks for your patch.
> 
> On Thu, Apr 08, 2021 at 05:08:27PM +0800, Dinghao Liu wrote:
> > When v4l2_subdev_call() fails, a pairing PM usage counter
> > decrement is needed to keep the counter balanced. It's the
> > same for the following error paths in case 'enable' is on.
> > 
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> >  drivers/staging/media/imx/imx7-mipi-csis.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
> > index a01a7364b4b9..2a3fff231a40 100644
> > --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> > +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> > @@ -627,21 +627,26 @@ static int mipi_csis_s_stream(struct v4l2_subdev *mipi_sd, int enable)
> >  			return ret;
> >  		}
> >  		ret = v4l2_subdev_call(state->src_sd, core, s_power, 1);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			pm_runtime_put_noidle(&state->pdev->dev);
> 
> I think here we should go completely pm_runtime_put to call the
> mipi_csis_pm_suspend down the line, right?
> 
> >  			return ret;
> > +		}
> >  	}
> >  
> >  	mutex_lock(&state->lock);
> >  	if (enable) {
> >  		if (state->flags & ST_SUSPENDED) {
> >  			ret = -EBUSY;
> > +			pm_runtime_put_noidle(&state->pdev->dev);
> 
> since we are in ST_SUSPENDED state, for sure the pm counter was
> already 0.
> 
> >  			goto unlock;
> >  		}
> >  
> >  		mipi_csis_start_stream(state);
> >  		ret = v4l2_subdev_call(state->src_sd, video, s_stream, 1);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			pm_runtime_put_noidle(&state->pdev->dev);
> 
> here also we need the pm_runtime_put, maybe just changing the unlock
> tag bellow from:
>     if (!enable)
>         pm_runtime_put(&state->pdev->dev);
> 
> to 
>     if (!enable || (ret < 0))
>         pm_runtime_put(&state->pdev->dev);
> 
> will not hurt the first case and will complete the suspend routine
> afterward in the second case.
> 

This is much clearer, thanks! I will fix this and send a new patch soon.

Regards,
Dinghao

WARNING: multiple messages have this Message-ID (diff)
From: dinghao.liu@zju.edu.cn
To: "Rui Miguel Silva" <rmfrfs@gmail.com>
Cc: kjlu@umn.edu, "Steve Longerbeam" <slongerbeam@gmail.com>,
	 "Philipp Zabel" <p.zabel@pengutronix.de>,
	 "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	 "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	 "Shawn Guo" <shawnguo@kernel.org>,
	 "Sascha Hauer" <s.hauer@pengutronix.de>,
	 "Pengutronix Kernel Team" <kernel@pengutronix.de>,
	 "Fabio Estevam" <festevam@gmail.com>,
	 "NXP Linux Team" <linux-imx@nxp.com>,
	linux-media@vger.kernel.org,  linux-staging@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH] media: imx: imx7-mipi-csis: Fix runtime PM imbalance in mipi_csis_s_stream
Date: Fri, 9 Apr 2021 15:59:53 +0800 (GMT+08:00)	[thread overview]
Message-ID: <5025467a.453b6.178b5a50321.Coremail.dinghao.liu@zju.edu.cn> (raw)
In-Reply-To: <20210408135702.f7ikjvwirvtzsarv@arch-thunder.localdomain>

> Hi Liu,
> Thanks for your patch.
> 
> On Thu, Apr 08, 2021 at 05:08:27PM +0800, Dinghao Liu wrote:
> > When v4l2_subdev_call() fails, a pairing PM usage counter
> > decrement is needed to keep the counter balanced. It's the
> > same for the following error paths in case 'enable' is on.
> > 
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> >  drivers/staging/media/imx/imx7-mipi-csis.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
> > index a01a7364b4b9..2a3fff231a40 100644
> > --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> > +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> > @@ -627,21 +627,26 @@ static int mipi_csis_s_stream(struct v4l2_subdev *mipi_sd, int enable)
> >  			return ret;
> >  		}
> >  		ret = v4l2_subdev_call(state->src_sd, core, s_power, 1);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			pm_runtime_put_noidle(&state->pdev->dev);
> 
> I think here we should go completely pm_runtime_put to call the
> mipi_csis_pm_suspend down the line, right?
> 
> >  			return ret;
> > +		}
> >  	}
> >  
> >  	mutex_lock(&state->lock);
> >  	if (enable) {
> >  		if (state->flags & ST_SUSPENDED) {
> >  			ret = -EBUSY;
> > +			pm_runtime_put_noidle(&state->pdev->dev);
> 
> since we are in ST_SUSPENDED state, for sure the pm counter was
> already 0.
> 
> >  			goto unlock;
> >  		}
> >  
> >  		mipi_csis_start_stream(state);
> >  		ret = v4l2_subdev_call(state->src_sd, video, s_stream, 1);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			pm_runtime_put_noidle(&state->pdev->dev);
> 
> here also we need the pm_runtime_put, maybe just changing the unlock
> tag bellow from:
>     if (!enable)
>         pm_runtime_put(&state->pdev->dev);
> 
> to 
>     if (!enable || (ret < 0))
>         pm_runtime_put(&state->pdev->dev);
> 
> will not hurt the first case and will complete the suspend routine
> afterward in the second case.
> 

This is much clearer, thanks! I will fix this and send a new patch soon.

Regards,
Dinghao
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-04-09  8:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08  9:08 [PATCH] media: imx: imx7-mipi-csis: Fix runtime PM imbalance in mipi_csis_s_stream Dinghao Liu
2021-04-08  9:08 ` Dinghao Liu
2021-04-08 13:57 ` Rui Miguel Silva
2021-04-08 13:57   ` Rui Miguel Silva
2021-04-09  7:59   ` dinghao.liu [this message]
2021-04-09  7:59     ` dinghao.liu
2021-04-09  7:59     ` dinghao.liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5025467a.453b6.178b5a50321.Coremail.dinghao.liu@zju.edu.cn \
    --to=dinghao.liu@zju.edu.cn \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=kjlu@umn.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rmfrfs@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=slongerbeam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.