diff mbox series

[3/3] media: i2c: imx219: Balance runtime PM use-count in resume callback

Message ID 20210310122014.28353-4-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State Superseded
Delegated to: Kieran Bingham
Headers show
Series media: i2c: imx219: Trivial Fixes | expand

Commit Message

Lad Prabhakar March 10, 2021, 12:20 p.m. UTC
The runtime PM use-count gets incremented in imx219_set_stream() call
when streaming is started this needs to be balanced by calling
pm_runtime_put() upon failure to start stream in resume callback.

Fixes: 1283b3b8f82b9 ("media: i2c: Add driver for Sony IMX219 sensor")
Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/media/i2c/imx219.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart March 10, 2021, 12:48 p.m. UTC | #1
Hi Prabhakar,

Thank you for the patch.

On Wed, Mar 10, 2021 at 12:20:14PM +0000, Lad Prabhakar wrote:
> The runtime PM use-count gets incremented in imx219_set_stream() call
> when streaming is started this needs to be balanced by calling
> pm_runtime_put() upon failure to start stream in resume callback.
> 
> Fixes: 1283b3b8f82b9 ("media: i2c: Add driver for Sony IMX219 sensor")
> Reported-by: Pavel Machek <pavel@denx.de>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>  drivers/media/i2c/imx219.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index 87c021de1460..afffc85cd265 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -1184,6 +1184,7 @@ static int __maybe_unused imx219_resume(struct device *dev)
>  {
>  	struct v4l2_subdev *sd = dev_get_drvdata(dev);
>  	struct imx219 *imx219 = to_imx219(sd);
> +	struct i2c_client *client;
>  	int ret;
>  
>  	mutex_lock(&imx219->mutex);
> @@ -1197,7 +1198,9 @@ static int __maybe_unused imx219_resume(struct device *dev)
>  	return 0;
>  
>  error:
> +	client = v4l2_get_subdevdata(&imx219->sd);
>  	imx219_stop_streaming(imx219);
> +	pm_runtime_put(&client->dev);
>  	imx219->streaming = false;
>  	__v4l2_ctrl_grab(imx219->vflip, false);
>  	__v4l2_ctrl_grab(imx219->hflip, false);

Similarly to the __v4l2_ctrl_grab(), it could be better to move
pm_runtime_put() to imx219_stop_streaming().
Lad, Prabhakar March 10, 2021, 2:01 p.m. UTC | #2
Hi Laurent,

Thank you for the review.

On Wed, Mar 10, 2021 at 12:49 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Wed, Mar 10, 2021 at 12:20:14PM +0000, Lad Prabhakar wrote:
> > The runtime PM use-count gets incremented in imx219_set_stream() call
> > when streaming is started this needs to be balanced by calling
> > pm_runtime_put() upon failure to start stream in resume callback.
> >
> > Fixes: 1283b3b8f82b9 ("media: i2c: Add driver for Sony IMX219 sensor")
> > Reported-by: Pavel Machek <pavel@denx.de>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >  drivers/media/i2c/imx219.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> > index 87c021de1460..afffc85cd265 100644
> > --- a/drivers/media/i2c/imx219.c
> > +++ b/drivers/media/i2c/imx219.c
> > @@ -1184,6 +1184,7 @@ static int __maybe_unused imx219_resume(struct device *dev)
> >  {
> >       struct v4l2_subdev *sd = dev_get_drvdata(dev);
> >       struct imx219 *imx219 = to_imx219(sd);
> > +     struct i2c_client *client;
> >       int ret;
> >
> >       mutex_lock(&imx219->mutex);
> > @@ -1197,7 +1198,9 @@ static int __maybe_unused imx219_resume(struct device *dev)
> >       return 0;
> >
> >  error:
> > +     client = v4l2_get_subdevdata(&imx219->sd);
> >       imx219_stop_streaming(imx219);
> > +     pm_runtime_put(&client->dev);
> >       imx219->streaming = false;
> >       __v4l2_ctrl_grab(imx219->vflip, false);
> >       __v4l2_ctrl_grab(imx219->hflip, false);
>
> Similarly to the __v4l2_ctrl_grab(), it could be better to move
> pm_runtime_put() to imx219_stop_streaming().
>
Agreed, moved this to imx219_stop_streaming().

Cheers,
Prabhakar

> --
> Regards,
>
> Laurent Pinchart
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 87c021de1460..afffc85cd265 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1184,6 +1184,7 @@  static int __maybe_unused imx219_resume(struct device *dev)
 {
 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
 	struct imx219 *imx219 = to_imx219(sd);
+	struct i2c_client *client;
 	int ret;
 
 	mutex_lock(&imx219->mutex);
@@ -1197,7 +1198,9 @@  static int __maybe_unused imx219_resume(struct device *dev)
 	return 0;
 
 error:
+	client = v4l2_get_subdevdata(&imx219->sd);
 	imx219_stop_streaming(imx219);
+	pm_runtime_put(&client->dev);
 	imx219->streaming = false;
 	__v4l2_ctrl_grab(imx219->vflip, false);
 	__v4l2_ctrl_grab(imx219->hflip, false);