All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer
@ 2023-01-14 11:21 Andrey Skvortsov
  2023-01-14 12:29 ` Sakari Ailus
  0 siblings, 1 reply; 6+ messages in thread
From: Andrey Skvortsov @ 2023-01-14 11:21 UTC (permalink / raw)
  To: Steve Longerbeam, Mauro Carvalho Chehab, linux-media, linux-kernel
  Cc: Andrey Skvortsov

Otherwise autosuspend delay doesn't work and power is cut off
immediately as device is freed.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
---
 drivers/media/i2c/ov5640.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index ac35350..f71c0f7 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -1238,6 +1238,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val)
 		return ret;
 	}
 
+	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 	return 0;
 }
 
@@ -1305,6 +1306,7 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val)
 	}
 
 	*val = buf[0];
+	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 	return 0;
 }
 
@@ -3615,6 +3617,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 		break;
 	}
 
+	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
 
 	return 0;
@@ -3702,6 +3705,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
 		break;
 	}
 
+	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
 
 	return ret;
@@ -4034,8 +4038,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
 out:
 	mutex_unlock(&sensor->lock);
 
-	if (!enable || ret)
+	if (!enable || ret) {
+		pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 		pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
+	}
 
 	return ret;
 }
@@ -4203,6 +4209,7 @@ static int ov5640_probe(struct i2c_client *client)
 
 	pm_runtime_set_autosuspend_delay(dev, 1000);
 	pm_runtime_use_autosuspend(dev);
+	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
 	return 0;

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

* Re: [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer
  2023-01-14 11:21 [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer Andrey Skvortsov
@ 2023-01-14 12:29 ` Sakari Ailus
  2023-01-14 15:19   ` Jacopo Mondi
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sakari Ailus @ 2023-01-14 12:29 UTC (permalink / raw)
  To: Andrey Skvortsov
  Cc: Steve Longerbeam, Mauro Carvalho Chehab, linux-media, linux-kernel

Hi Andrey,

On Sat, Jan 14, 2023 at 02:21:09PM +0300, Andrey Skvortsov wrote:
> Otherwise autosuspend delay doesn't work and power is cut off
> immediately as device is freed.
> 
> Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
> ---
>  drivers/media/i2c/ov5640.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index ac35350..f71c0f7 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -1238,6 +1238,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val)
>  		return ret;
>  	}
>  
> +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
>  	return 0;
>  }
>  
> @@ -1305,6 +1306,7 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val)
>  	}
>  
>  	*val = buf[0];
> +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);

I wouldn't add these calls to register accesses. It's generally relevant
with autosuspend_put().

The rest seems fine to me.

>  	return 0;
>  }
>  
> @@ -3615,6 +3617,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
>  		break;
>  	}
>  
> +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
>  	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
>  
>  	return 0;
> @@ -3702,6 +3705,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
>  		break;
>  	}
>  
> +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
>  	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
>  
>  	return ret;
> @@ -4034,8 +4038,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
>  out:
>  	mutex_unlock(&sensor->lock);
>  
> -	if (!enable || ret)
> +	if (!enable || ret) {
> +		pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
>  		pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> +	}
>  
>  	return ret;
>  }
> @@ -4203,6 +4209,7 @@ static int ov5640_probe(struct i2c_client *client)
>  
>  	pm_runtime_set_autosuspend_delay(dev, 1000);
>  	pm_runtime_use_autosuspend(dev);
> +	pm_runtime_mark_last_busy(dev);
>  	pm_runtime_put_autosuspend(dev);
>  
>  	return 0;

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer
  2023-01-14 12:29 ` Sakari Ailus
@ 2023-01-14 15:19   ` Jacopo Mondi
  2023-01-14 21:49     ` Sakari Ailus
  2023-01-15 17:28   ` Andrey Skvortsov
  2023-01-15 17:30   ` [PATCHv2] " Andrey Skvortsov
  2 siblings, 1 reply; 6+ messages in thread
From: Jacopo Mondi @ 2023-01-14 15:19 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Andrey Skvortsov, Steve Longerbeam, Mauro Carvalho Chehab,
	linux-media, linux-kernel

Hi Sakari

On Sat, Jan 14, 2023 at 02:29:14PM +0200, Sakari Ailus wrote:
> Hi Andrey,
>
> On Sat, Jan 14, 2023 at 02:21:09PM +0300, Andrey Skvortsov wrote:
> > Otherwise autosuspend delay doesn't work and power is cut off
> > immediately as device is freed.
> >
> > Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
> > ---
> >  drivers/media/i2c/ov5640.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> > index ac35350..f71c0f7 100644
> > --- a/drivers/media/i2c/ov5640.c
> > +++ b/drivers/media/i2c/ov5640.c
> > @@ -1238,6 +1238,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val)
> >  		return ret;
> >  	}
> >
> > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> >  	return 0;
> >  }
> >
> > @@ -1305,6 +1306,7 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val)
> >  	}
> >
> >  	*val = buf[0];
> > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
>
> I wouldn't add these calls to register accesses. It's generally relevant
> with autosuspend_put().
>
> The rest seems fine to me.
>

Does it mean the same should be done for the all the sensor drivers that
use autosuspend ? I count 8 of them, not a huge number.

> >  	return 0;
> >  }
> >
> > @@ -3615,6 +3617,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
> >  		break;
> >  	}
> >
> > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> >  	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> >
> >  	return 0;
> > @@ -3702,6 +3705,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
> >  		break;
> >  	}
> >
> > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> >  	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> >
> >  	return ret;
> > @@ -4034,8 +4038,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
> >  out:
> >  	mutex_unlock(&sensor->lock);
> >
> > -	if (!enable || ret)
> > +	if (!enable || ret) {
> > +		pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> >  		pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> > +	}
> >
> >  	return ret;
> >  }
> > @@ -4203,6 +4209,7 @@ static int ov5640_probe(struct i2c_client *client)
> >
> >  	pm_runtime_set_autosuspend_delay(dev, 1000);
> >  	pm_runtime_use_autosuspend(dev);
> > +	pm_runtime_mark_last_busy(dev);
> >  	pm_runtime_put_autosuspend(dev);
> >
> >  	return 0;
>
> --
> Kind regards,
>
> Sakari Ailus

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

* Re: [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer
  2023-01-14 15:19   ` Jacopo Mondi
@ 2023-01-14 21:49     ` Sakari Ailus
  0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2023-01-14 21:49 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Andrey Skvortsov, Steve Longerbeam, Mauro Carvalho Chehab,
	linux-media, linux-kernel

Hi Jacopo,

On Sat, Jan 14, 2023 at 04:19:06PM +0100, Jacopo Mondi wrote:
> Hi Sakari
> 
> On Sat, Jan 14, 2023 at 02:29:14PM +0200, Sakari Ailus wrote:
> > Hi Andrey,
> >
> > On Sat, Jan 14, 2023 at 02:21:09PM +0300, Andrey Skvortsov wrote:
> > > Otherwise autosuspend delay doesn't work and power is cut off
> > > immediately as device is freed.
> > >
> > > Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
> > > ---
> > >  drivers/media/i2c/ov5640.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> > > index ac35350..f71c0f7 100644
> > > --- a/drivers/media/i2c/ov5640.c
> > > +++ b/drivers/media/i2c/ov5640.c
> > > @@ -1238,6 +1238,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val)
> > >  		return ret;
> > >  	}
> > >
> > > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> > >  	return 0;
> > >  }
> > >
> > > @@ -1305,6 +1306,7 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val)
> > >  	}
> > >
> > >  	*val = buf[0];
> > > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> >
> > I wouldn't add these calls to register accesses. It's generally relevant
> > with autosuspend_put().
> >
> > The rest seems fine to me.
> >
> 
> Does it mean the same should be done for the all the sensor drivers that
> use autosuspend ? I count 8 of them, not a huge number.

pm_runtime_mark_last_busy() should be called before
pm_runtime_put_autosuspend(). I was thinking of adding a helper that would
simply call both of them. We don't have that yet though.

> 
> > >  	return 0;
> > >  }
> > >
> > > @@ -3615,6 +3617,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
> > >  		break;
> > >  	}
> > >
> > > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> > >  	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> > >
> > >  	return 0;
> > > @@ -3702,6 +3705,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
> > >  		break;
> > >  	}
> > >
> > > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> > >  	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> > >
> > >  	return ret;
> > > @@ -4034,8 +4038,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
> > >  out:
> > >  	mutex_unlock(&sensor->lock);
> > >
> > > -	if (!enable || ret)
> > > +	if (!enable || ret) {
> > > +		pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> > >  		pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
> > > +	}
> > >
> > >  	return ret;
> > >  }
> > > @@ -4203,6 +4209,7 @@ static int ov5640_probe(struct i2c_client *client)
> > >
> > >  	pm_runtime_set_autosuspend_delay(dev, 1000);
> > >  	pm_runtime_use_autosuspend(dev);
> > > +	pm_runtime_mark_last_busy(dev);
> > >  	pm_runtime_put_autosuspend(dev);
> > >
> > >  	return 0;

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer
  2023-01-14 12:29 ` Sakari Ailus
  2023-01-14 15:19   ` Jacopo Mondi
@ 2023-01-15 17:28   ` Andrey Skvortsov
  2023-01-15 17:30   ` [PATCHv2] " Andrey Skvortsov
  2 siblings, 0 replies; 6+ messages in thread
From: Andrey Skvortsov @ 2023-01-15 17:28 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Steve Longerbeam, Mauro Carvalho Chehab, linux-media, linux-kernel

On 23-01-14 14:29, Sakari Ailus wrote:
> Hi Andrey,
> 
> On Sat, Jan 14, 2023 at 02:21:09PM +0300, Andrey Skvortsov wrote:
> > Otherwise autosuspend delay doesn't work and power is cut off
> > immediately as device is freed.
> > 
> > Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
> > ---
> >  drivers/media/i2c/ov5640.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> > index ac35350..f71c0f7 100644
> > --- a/drivers/media/i2c/ov5640.c
> > +++ b/drivers/media/i2c/ov5640.c
> > @@ -1238,6 +1238,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val)
> >  		return ret;
> >  	}
> >  
> > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> >  	return 0;
> >  }
> >  
> > @@ -1305,6 +1306,7 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val)
> >  	}
> >  
> >  	*val = buf[0];
> > +	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
> 
> I wouldn't add these calls to register accesses. It's generally relevant
> with autosuspend_put().
> 
> The rest seems fine to me.
> 

Thanks, Sakari, for the feedback. I wasn't sure about these calls either,
I'll remove them in the v2.

-- 
Best regards,
Andrey Skvortsov

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

* [PATCHv2] media: ov5640: Update last busy timestamp to reset autosuspend timer
  2023-01-14 12:29 ` Sakari Ailus
  2023-01-14 15:19   ` Jacopo Mondi
  2023-01-15 17:28   ` Andrey Skvortsov
@ 2023-01-15 17:30   ` Andrey Skvortsov
  2 siblings, 0 replies; 6+ messages in thread
From: Andrey Skvortsov @ 2023-01-15 17:30 UTC (permalink / raw)
  To: Steve Longerbeam, Jacopo Mondi, Mauro Carvalho Chehab,
	linux-media, linux-kernel
  Cc: Andrey Skvortsov

Otherwise autosuspend delay doesn't work and power is cut off
immediately as device is freed.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
---

Changes since PATCHv1:
 * Removed pm_runtime_mask_last_busy call from ov5640_write_reg and ov5640_read_reg
   as suggested by Sakari Ailus
 * Updated diff against next-20230113

drivers/media/i2c/ov5640.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index e0f908af581b..24f4f395aad6 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -3316,6 +3316,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 		break;
 	}
 
+	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
 
 	return 0;
@@ -3391,6 +3392,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
 		break;
 	}
 
+	pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 	pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
 
 	return ret;
@@ -3710,8 +3712,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
 out:
 	mutex_unlock(&sensor->lock);
 
-	if (!enable || ret)
+	if (!enable || ret) {
+		pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
 		pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
+	}
 
 	return ret;
 }
@@ -3912,6 +3916,7 @@ static int ov5640_probe(struct i2c_client *client)
 
 	pm_runtime_set_autosuspend_delay(dev, 1000);
 	pm_runtime_use_autosuspend(dev);
+	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
 	return 0;
-- 
2.39.0


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

end of thread, other threads:[~2023-01-15 17:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14 11:21 [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer Andrey Skvortsov
2023-01-14 12:29 ` Sakari Ailus
2023-01-14 15:19   ` Jacopo Mondi
2023-01-14 21:49     ` Sakari Ailus
2023-01-15 17:28   ` Andrey Skvortsov
2023-01-15 17:30   ` [PATCHv2] " Andrey Skvortsov

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.