media: ov5640: Update last busy timestamp to reset autosuspend timer
PATCH 1/1 media: ov5640: Update last busy timestamp to reset autosuspend timer
Otherwise autosuspend delay doesn't work and power is cut off immediately as device is freed.
--- drivers/media/i2c/ov5640.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/media/i2c/ov5640.c +8 -1
@@ -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 ;
Hi Andrey,
Quoted 21 lines · Andrey Skvortsov
Otherwise autosuspend delay doesn't work and power is cut off immediately as device is freed.
Signed-off-by Andrey Skvortsov <[email protected]>--- drivers/media/i2c/ov5640.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/media/i2c/ov5640.c +1
-0@@ -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 ; }
drivers/media/i2c/ov5640.c static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) · line 1309
Quoted 4 lines
drivers/media/i2c/ov5640.c +1
-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.
Quoted 39 lines
drivers/media/i2c/ov5640.c +6
-1return 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 ;
Signature · 3 lines
Kind regards, Sakari Ailus
Hi Sakari
Quoted 26 lines · Sakari Ailus
Hi Andrey,
Quoted 23 lines · Andrey Skvortsov
Otherwise autosuspend delay doesn't work and power is cut off immediately as device is freed.
Signed-off-by Andrey Skvortsov <[email protected]>--- drivers/media/i2c/ov5640.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/media/i2c/ov5640.c +1
-0@@ -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) }
Quoted 8 lines
drivers/media/i2c/ov5640.c static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) · line 1309
Quoted 2 lines
drivers/media/i2c/ov5640.c +1
-0*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.
Quoted 44 lines
Quoted 32 lines
drivers/media/i2c/ov5640.c +5
-1return 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; }drivers/media/i2c/ov5640.c static int ov5640_probe(struct i2c_client *client) · line 4215
Quoted 7 lines
drivers/media/i2c/ov5640.c +1
-0@@ -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
Hi Jacopo,
Quoted 35 lines · Jacopo Mondi
Hi Sakari
Quoted 32 lines · Sakari Ailus
Hi Andrey,
Quoted 21 lines · Andrey Skvortsov
Otherwise autosuspend delay doesn't work and power is cut off immediately as device is freed.
Signed-off-by Andrey Skvortsov <[email protected]>--- drivers/media/i2c/ov5640.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/media/i2c/ov5640.c +1
-0@@ -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 ; }drivers/media/i2c/ov5640.c static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) · line 1309
Quoted 4 lines
drivers/media/i2c/ov5640.c +1
-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().
Quoted 5 lines
Quoted 2 lines
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.
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
drivers/media/i2c/ov5640.c +6
-1return 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 ;
Signature · 3 lines
Kind regards, Sakari Ailus
Quoted 26 lines · Sakari Ailus
Hi Andrey,
Quoted 23 lines · Andrey Skvortsov
Otherwise autosuspend delay doesn't work and power is cut off immediately as device is freed.
Signed-off-by Andrey Skvortsov <[email protected]>--- drivers/media/i2c/ov5640.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/media/i2c/ov5640.c +1
-0@@ -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) }
Quoted 8 lines
drivers/media/i2c/ov5640.c static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) · line 1309
Quoted 2 lines
drivers/media/i2c/ov5640.c +1
-0*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.
Signature · 2 lines
Best regards, Andrey Skvortsov
PATCH v2 1/1 media: ov5640: Update last busy timestamp to reset autosuspend timer
In reply to Sakari AilusOtherwise autosuspend delay doesn't work and power is cut off immediately as device is freed.
---
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(-)
drivers/media/i2c/ov5640.c +6 -1
@@ -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 ;
Signature · 1 line
2.39.0