stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 01/15] media: i2c: os05b10: Use pm_runtime_get_if_active() when applying controls
       [not found] <20260325114404.95188-1-tarang.raval@siliconsignals.io>
@ 2026-03-25 11:43 ` Tarang Raval
  2026-06-29 15:22   ` Mehdi Djait
  0 siblings, 1 reply; 3+ messages in thread
From: Tarang Raval @ 2026-03-25 11:43 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Tarang Raval, stable, Himanshu Bhavani, Elgin Perumbilly,
	Mauro Carvalho Chehab, Hans Verkuil, Vladimir Zapolskiy,
	linux-media, linux-kernel

os05b10_set_ctrl() currently uses pm_runtime_get_if_in_use() to decide
whether controls should be applied to hardware.

This is not correct for the intended behavior. If the runtime PM usage
count is 0 while the device is still active, pm_runtime_get_if_in_use()
returns 0 and the control update is skipped, leaving the software state
updated but not the hardware state.

Use pm_runtime_get_if_active() instead so controls are applied whenever
the device is runtime-active, regardless of the current usage count.

Cc: stable@vger.kernel.org
Fixes: 3aa9296a23ec4("media: i2c: add os05b10 image sensor driver")
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
 drivers/media/i2c/os05b10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index e0453c988e4a..5da5b7d21f31 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -531,7 +531,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
 			return ret;
 	}
 
-	if (pm_runtime_get_if_in_use(os05b10->dev) == 0)
+	if (pm_runtime_get_if_active(os05b10->dev) == 0)
 		return 0;
 
 	switch (ctrl->id) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 01/15] media: i2c: os05b10: Use pm_runtime_get_if_active() when applying controls
  2026-03-25 11:43 ` [PATCH v2 01/15] media: i2c: os05b10: Use pm_runtime_get_if_active() when applying controls Tarang Raval
@ 2026-06-29 15:22   ` Mehdi Djait
  2026-06-30  7:17     ` Tarang Raval
  0 siblings, 1 reply; 3+ messages in thread
From: Mehdi Djait @ 2026-06-29 15:22 UTC (permalink / raw)
  To: Tarang Raval
  Cc: Sakari Ailus, stable, Himanshu Bhavani, Elgin Perumbilly,
	Mauro Carvalho Chehab, Hans Verkuil, Vladimir Zapolskiy,
	linux-media, linux-kernel

Hi Tarang,

On Wed, Mar 25, 2026 at 05:13:47PM +0530, Tarang Raval wrote:
> os05b10_set_ctrl() currently uses pm_runtime_get_if_in_use() to decide
> whether controls should be applied to hardware.
> 
> This is not correct for the intended behavior. If the runtime PM usage
> count is 0 while the device is still active, pm_runtime_get_if_in_use()
> returns 0 and the control update is skipped, leaving the software state
> updated but not the hardware state.
> 
> Use pm_runtime_get_if_active() instead so controls are applied whenever
> the device is runtime-active, regardless of the current usage count.
> 
> Cc: stable@vger.kernel.org
> Fixes: 3aa9296a23ec4("media: i2c: add os05b10 image sensor driver")

A space is missing here after the commit hash.
See https://docs.kernel.org/process/submitting-patches.html

checkpatch will warn you about it.

with that:
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>

> Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
> ---
>  drivers/media/i2c/os05b10.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index e0453c988e4a..5da5b7d21f31 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
> @@ -531,7 +531,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
>  			return ret;
>  	}
>  
> -	if (pm_runtime_get_if_in_use(os05b10->dev) == 0)
> +	if (pm_runtime_get_if_active(os05b10->dev) == 0)

small nit: how about
	if (!pm_runtime_get_if_active(os05b10->dev))

consistent with other drivers using this call but really not important,
up to you if you want to change it.

--
Kind Regards
Mehdi Djait

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 01/15] media: i2c: os05b10: Use pm_runtime_get_if_active() when applying controls
  2026-06-29 15:22   ` Mehdi Djait
@ 2026-06-30  7:17     ` Tarang Raval
  0 siblings, 0 replies; 3+ messages in thread
From: Tarang Raval @ 2026-06-30  7:17 UTC (permalink / raw)
  To: Mehdi Djait
  Cc: Sakari Ailus, stable@vger.kernel.org, Himanshu Bhavani,
	Elgin Perumbilly, Mauro Carvalho Chehab, Hans Verkuil,
	Vladimir Zapolskiy, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org

Hi, Mehdi.

> On Wed, Mar 25, 2026 at 05:13:47PM +0530, Tarang Raval wrote:
> > os05b10_set_ctrl() currently uses pm_runtime_get_if_in_use() to decide
> > whether controls should be applied to hardware.
> >
> > This is not correct for the intended behavior. If the runtime PM usage
> > count is 0 while the device is still active, pm_runtime_get_if_in_use()
> > returns 0 and the control update is skipped, leaving the software state
> > updated but not the hardware state.
> >
> > Use pm_runtime_get_if_active() instead so controls are applied whenever
> > the device is runtime-active, regardless of the current usage count.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 3aa9296a23ec4("media: i2c: add os05b10 image sensor driver")
>
> A space is missing here after the commit hash.
> See https://docs.kernel.org/process/submitting-patches.html
>
> checkpatch will warn you about it.

Recently, I found that this is not actually a bug. Using
pm_runtime_get_if_active() would simply allow more control updates to be
written over I²C while the device is runtime-active, even when the PM
usage count is zero. Since this is not a bug fix, I'll remove the Fixes
tag.

> with that:
> Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
>
> > Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
> > ---
> >  drivers/media/i2c/os05b10.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> > index e0453c988e4a..5da5b7d21f31 100644
> > --- a/drivers/media/i2c/os05b10.c
> > +++ b/drivers/media/i2c/os05b10.c
> > @@ -531,7 +531,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
> >                       return ret;
> >       }
> >
> > -     if (pm_runtime_get_if_in_use(os05b10->dev) == 0)
> > +     if (pm_runtime_get_if_active(os05b10->dev) == 0)
>
> small nit: how about
>         if (!pm_runtime_get_if_active(os05b10->dev))
>
> consistent with other drivers using this call but really not important,
> up to you if you want to change it.

Sure, I will update.

Best Regards,
Tarang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-30  7:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260325114404.95188-1-tarang.raval@siliconsignals.io>
2026-03-25 11:43 ` [PATCH v2 01/15] media: i2c: os05b10: Use pm_runtime_get_if_active() when applying controls Tarang Raval
2026-06-29 15:22   ` Mehdi Djait
2026-06-30  7:17     ` Tarang Raval

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).