[08/19] media: i2c: ov4689: Enable runtime PM before registering sub-device

Message ID 20231211175023.1680247-9-mike.rudenko@gmail.com
State New
Headers
Series Omnivision OV4689 refactoring and improvements |

Commit Message

Mikhail Rudenko Dec. 11, 2023, 5:50 p.m. UTC
  As the sensor may be accessible right after its async sub-device is
registered, enable runtime PM before doing so.

Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
---
 drivers/media/i2c/ov4689.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Laurent Pinchart Dec. 11, 2023, 6:19 p.m. UTC | #1
Hi Mikhail,

Thank you for the patch.

On Mon, Dec 11, 2023 at 08:50:11PM +0300, Mikhail Rudenko wrote:
> As the sensor may be accessible right after its async sub-device is
> registered, enable runtime PM before doing so.

While at it, could you also switch to runtime PM autosuspend, possibly
in a separate patch ? See for instance the imx290 driver.

> Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
> ---
>  drivers/media/i2c/ov4689.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
> index 2eef64cd0070..ba33b0ced532 100644
> --- a/drivers/media/i2c/ov4689.c
> +++ b/drivers/media/i2c/ov4689.c
> @@ -874,16 +874,16 @@ static int ov4689_probe(struct i2c_client *client)
>  		goto err_clean_entity;
>  	}
>  
> +	pm_runtime_set_active(dev);
> +	pm_runtime_enable(dev);
> +	pm_runtime_idle(dev);
> +
>  	ret = v4l2_async_register_subdev_sensor(sd);
>  	if (ret) {
>  		dev_err(dev, "v4l2 async register subdev failed\n");
>  		goto err_clean_subdev;

Don't you need to disable runtime PM in the error path ?

>  	}
>  
> -	pm_runtime_set_active(dev);
> -	pm_runtime_enable(dev);
> -	pm_runtime_idle(dev);
> -
>  	return 0;
>  
>  err_clean_subdev:
  
Mikhail Rudenko Dec. 12, 2023, 12:32 p.m. UTC | #2
On 2023-12-11 at 20:19 +02, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote:

> Hi Mikhail,
>
> Thank you for the patch.
>
> On Mon, Dec 11, 2023 at 08:50:11PM +0300, Mikhail Rudenko wrote:
>> As the sensor may be accessible right after its async sub-device is
>> registered, enable runtime PM before doing so.
>
> While at it, could you also switch to runtime PM autosuspend, possibly
> in a separate patch ? See for instance the imx290 driver.

I actually had a plan to do this in this series, but it had grown a
little bigger then expected and I had to drop a few non-essential
patches, including PM autosuspend. But if you suggest, I'll bring in
back in v2.

>> Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
>> ---
>>  drivers/media/i2c/ov4689.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
>> index 2eef64cd0070..ba33b0ced532 100644
>> --- a/drivers/media/i2c/ov4689.c
>> +++ b/drivers/media/i2c/ov4689.c
>> @@ -874,16 +874,16 @@ static int ov4689_probe(struct i2c_client *client)
>>  		goto err_clean_entity;
>>  	}
>>
>> +	pm_runtime_set_active(dev);
>> +	pm_runtime_enable(dev);
>> +	pm_runtime_idle(dev);
>> +
>>  	ret = v4l2_async_register_subdev_sensor(sd);
>>  	if (ret) {
>>  		dev_err(dev, "v4l2 async register subdev failed\n");
>>  		goto err_clean_subdev;
>
> Don't you need to disable runtime PM in the error path ?

Ack, will improve error in v2.

>>  	}
>>
>> -	pm_runtime_set_active(dev);
>> -	pm_runtime_enable(dev);
>> -	pm_runtime_idle(dev);
>> -
>>  	return 0;
>>
>>  err_clean_subdev:


--
Best regards,
Mikhail Rudenko
  

Patch

diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
index 2eef64cd0070..ba33b0ced532 100644
--- a/drivers/media/i2c/ov4689.c
+++ b/drivers/media/i2c/ov4689.c
@@ -874,16 +874,16 @@  static int ov4689_probe(struct i2c_client *client)
 		goto err_clean_entity;
 	}
 
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+	pm_runtime_idle(dev);
+
 	ret = v4l2_async_register_subdev_sensor(sd);
 	if (ret) {
 		dev_err(dev, "v4l2 async register subdev failed\n");
 		goto err_clean_subdev;
 	}
 
-	pm_runtime_set_active(dev);
-	pm_runtime_enable(dev);
-	pm_runtime_idle(dev);
-
 	return 0;
 
 err_clean_subdev: