Re: [PATCH 6/6] media: i2c: imx334: Enable runtime PM before sub-device registration

From: Sakari Ailus
Date: Thu Mar 27 2025 - 07:15:25 EST


On Thu, Mar 27, 2025 at 11:02:33AM +0000, Tarang Raval wrote:
> Hi Sakari,
>
> Thanks for the review.
>
> > On Mon, Mar 10, 2025 at 12:47:48PM +0530, Tarang Raval wrote:
> > > Runtime PM is fully initialized before calling
> > > v4l2_async_register_subdev_sensor(). Moving the runtime PM initialization
> > > earlier prevents potential access to an uninitialized or powered-down device.
> > >
> > > Signed-off-by: Tarang Raval <tarang.raval@xxxxxxxxxxxxxxxxx>
> > > ---
> > >  drivers/media/i2c/imx334.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c
> > > index ffa39bb317f7..8964d60324e2 100644
> > > --- a/drivers/media/i2c/imx334.c
> > > +++ b/drivers/media/i2c/imx334.c
> > > @@ -1295,6 +1295,9 @@ static int imx334_probe(struct i2c_client *client)
> > >               goto error_handler_free;
> > >       }
> > >
> > > +     pm_runtime_set_active(imx334->dev);
> > > +     pm_runtime_enable(imx334->dev);
> > > +
> > >       ret = v4l2_async_register_subdev_sensor(&imx334->sd);
> > >       if (ret < 0) {
> > >               dev_err(imx334->dev,
> > > @@ -1302,8 +1305,6 @@ static int imx334_probe(struct i2c_client *client)
> > >               goto error_media_entity;
> > >       }
> > >
> > > -     pm_runtime_set_active(imx334->dev);
> > > -     pm_runtime_enable(imx334->dev);
>
> > Please also change error handling accordingly.
>
> Oh, I missed that.
>  
> > Btw. the remove function calls pm_runtime_suspended() that does nothing
> > (use pm_runtime_set_suspended() instead). Could you add a patch to fix it?
>
> Should I include these changes in this patch, or should I create a separate
> patch for them.

A separate patch would be better as it could be cc'd to stable as well.
Probably this issue has been there all along...

--
Sakari Ailus