linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Enable sensor's runtime PM before registering async sub-dev
@ 2023-11-22  2:54 bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 1/4] media: imx355: Enable runtime PM before registering async sub-device bingbu.cao
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: bingbu.cao @ 2023-11-22  2:54 UTC (permalink / raw)
  To: linux-media, sakari.ailus; +Cc: hdegoede, bingbu.cao, bingbu.cao

From: Bingbu Cao <bingbu.cao@intel.com>

Following Sakari's patch:
<URL:https://lore.kernel.org/linux-media/20231102090752.1418132-1-sakari.ailus@linux.intel.com/>

The sensor device maybe accessible right after its async sub-device is
registered, so runtime PM should be ready before its async sub-device
is registered.

---
v1->v2: move pm_runtime_idle() together with pm_runtime_enable()
---

Bingbu Cao (4):
  media: imx355: Enable runtime PM before registering async sub-device
  media: ov01a10: Enable runtime PM before registering async sub-device
  media: ov13b10: Enable runtime PM before registering async sub-device
  media: ov9734: Enable runtime PM before registering async sub-device

 drivers/media/i2c/imx355.c  | 12 +++++++-----
 drivers/media/i2c/ov01a10.c | 11 +++++++----
 drivers/media/i2c/ov13b10.c | 13 ++++++++-----
 drivers/media/i2c/ov9734.c  | 18 ++++++++++--------
 4 files changed, 32 insertions(+), 22 deletions(-)

-- 
2.42.0


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

* [PATCH v2 1/4] media: imx355: Enable runtime PM before registering async sub-device
  2023-11-22  2:54 [PATCH v2 0/4] Enable sensor's runtime PM before registering async sub-dev bingbu.cao
@ 2023-11-22  2:54 ` bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 2/4] media: ov01a10: " bingbu.cao
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: bingbu.cao @ 2023-11-22  2:54 UTC (permalink / raw)
  To: linux-media, sakari.ailus; +Cc: hdegoede, bingbu.cao, bingbu.cao

From: Bingbu Cao <bingbu.cao@intel.com>

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's client
device's runtime PM from the async notifier callback, if runtime PM is not
enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 drivers/media/i2c/imx355.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
index 9c79ae8dc842..059a41b7eefc 100644
--- a/drivers/media/i2c/imx355.c
+++ b/drivers/media/i2c/imx355.c
@@ -1788,10 +1788,6 @@ static int imx355_probe(struct i2c_client *client)
 		goto error_handler_free;
 	}
 
-	ret = v4l2_async_register_subdev_sensor(&imx355->sd);
-	if (ret < 0)
-		goto error_media_entity;
-
 	/*
 	 * Device is already turned on by i2c-core with ACPI domain PM.
 	 * Enable runtime PM and turn off the device.
@@ -1800,9 +1796,15 @@ static int imx355_probe(struct i2c_client *client)
 	pm_runtime_enable(&client->dev);
 	pm_runtime_idle(&client->dev);
 
+	ret = v4l2_async_register_subdev_sensor(&imx355->sd);
+	if (ret < 0)
+		goto error_media_entity_runtime_pm;
+
 	return 0;
 
-error_media_entity:
+error_media_entity_runtime_pm:
+	pm_runtime_disable(&client->dev);
+	pm_runtime_set_suspended(&client->dev);
 	media_entity_cleanup(&imx355->sd.entity);
 
 error_handler_free:
-- 
2.42.0


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

* [PATCH v2 2/4] media: ov01a10: Enable runtime PM before registering async sub-device
  2023-11-22  2:54 [PATCH v2 0/4] Enable sensor's runtime PM before registering async sub-dev bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 1/4] media: imx355: Enable runtime PM before registering async sub-device bingbu.cao
@ 2023-11-22  2:54 ` bingbu.cao
  2023-11-22  7:43   ` Sakari Ailus
  2023-11-22  2:54 ` [PATCH v2 3/4] media: ov13b10: " bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 4/4] media: ov9734: " bingbu.cao
  3 siblings, 1 reply; 6+ messages in thread
From: bingbu.cao @ 2023-11-22  2:54 UTC (permalink / raw)
  To: linux-media, sakari.ailus; +Cc: hdegoede, bingbu.cao, bingbu.cao

From: Bingbu Cao <bingbu.cao@intel.com>

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's client
device's runtime PM from the async notifier callback, if runtime PM is not
enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 drivers/media/i2c/ov01a10.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c
index 2b9e1b3a3bf4..8e36f91913aa 100644
--- a/drivers/media/i2c/ov01a10.c
+++ b/drivers/media/i2c/ov01a10.c
@@ -953,17 +953,20 @@ static int ov01a10_probe(struct i2c_client *client)
 		goto err_media_entity_cleanup;
 	}
 
+	pm_runtime_enable(dev);
+	pm_runtime_idle(dev);
+
 	ret = v4l2_async_register_subdev_sensor(&ov01a10->sd);
 	if (ret < 0) {
 		dev_err(dev, "Failed to register subdev: %d\n", ret);
-		goto err_media_entity_cleanup;
+		goto err_pm_disable;
 	}
 
-	pm_runtime_enable(dev);
-	pm_runtime_idle(dev);
-
 	return 0;
 
+err_pm_disable:
+	pm_runtime_disable(dev);
+
 err_media_entity_cleanup:
 	media_entity_cleanup(&ov01a10->sd.entity);
 
-- 
2.42.0


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

* [PATCH v2 3/4] media: ov13b10: Enable runtime PM before registering async sub-device
  2023-11-22  2:54 [PATCH v2 0/4] Enable sensor's runtime PM before registering async sub-dev bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 1/4] media: imx355: Enable runtime PM before registering async sub-device bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 2/4] media: ov01a10: " bingbu.cao
@ 2023-11-22  2:54 ` bingbu.cao
  2023-11-22  2:54 ` [PATCH v2 4/4] media: ov9734: " bingbu.cao
  3 siblings, 0 replies; 6+ messages in thread
From: bingbu.cao @ 2023-11-22  2:54 UTC (permalink / raw)
  To: linux-media, sakari.ailus; +Cc: hdegoede, bingbu.cao, bingbu.cao

From: Bingbu Cao <bingbu.cao@intel.com>

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's client
device's runtime PM from the async notifier callback, if runtime PM is not
enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 drivers/media/i2c/ov13b10.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c
index dbc642c5995b..e8baf0e1b017 100644
--- a/drivers/media/i2c/ov13b10.c
+++ b/drivers/media/i2c/ov13b10.c
@@ -1536,24 +1536,27 @@ static int ov13b10_probe(struct i2c_client *client)
 		goto error_handler_free;
 	}
 
-	ret = v4l2_async_register_subdev_sensor(&ov13b->sd);
-	if (ret < 0)
-		goto error_media_entity;
 
 	/*
 	 * Device is already turned on by i2c-core with ACPI domain PM.
 	 * Enable runtime PM and turn off the device.
 	 */
-
 	/* Set the device's state to active if it's in D0 state. */
 	if (full_power)
 		pm_runtime_set_active(&client->dev);
 	pm_runtime_enable(&client->dev);
 	pm_runtime_idle(&client->dev);
 
+	ret = v4l2_async_register_subdev_sensor(&ov13b->sd);
+	if (ret < 0)
+		goto error_media_entity_runtime_pm;
+
 	return 0;
 
-error_media_entity:
+error_media_entity_runtime_pm:
+	pm_runtime_disable(&client->dev);
+	if (full_power)
+		pm_runtime_set_suspended(&client->dev);
 	media_entity_cleanup(&ov13b->sd.entity);
 
 error_handler_free:
-- 
2.42.0


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

* [PATCH v2 4/4] media: ov9734: Enable runtime PM before registering async sub-device
  2023-11-22  2:54 [PATCH v2 0/4] Enable sensor's runtime PM before registering async sub-dev bingbu.cao
                   ` (2 preceding siblings ...)
  2023-11-22  2:54 ` [PATCH v2 3/4] media: ov13b10: " bingbu.cao
@ 2023-11-22  2:54 ` bingbu.cao
  3 siblings, 0 replies; 6+ messages in thread
From: bingbu.cao @ 2023-11-22  2:54 UTC (permalink / raw)
  To: linux-media, sakari.ailus; +Cc: hdegoede, bingbu.cao, bingbu.cao

From: Bingbu Cao <bingbu.cao@intel.com>

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's client
device's runtime PM from the async notifier callback, if runtime PM is not
enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 drivers/media/i2c/ov9734.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c
index b6244772bc59..e4239b77e1d6 100644
--- a/drivers/media/i2c/ov9734.c
+++ b/drivers/media/i2c/ov9734.c
@@ -984,13 +984,6 @@ static int ov9734_probe(struct i2c_client *client)
 		goto probe_error_v4l2_ctrl_handler_free;
 	}
 
-	ret = v4l2_async_register_subdev_sensor(&ov9734->sd);
-	if (ret < 0) {
-		dev_err(&client->dev, "failed to register V4L2 subdev: %d",
-			ret);
-		goto probe_error_media_entity_cleanup;
-	}
-
 	/*
 	 * Device is already turned on by i2c-core with ACPI domain PM.
 	 * Enable runtime PM and turn off the device.
@@ -999,9 +992,18 @@ static int ov9734_probe(struct i2c_client *client)
 	pm_runtime_enable(&client->dev);
 	pm_runtime_idle(&client->dev);
 
+	ret = v4l2_async_register_subdev_sensor(&ov9734->sd);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to register V4L2 subdev: %d",
+			ret);
+		goto probe_error_media_entity_cleanup_pm;
+	}
+
 	return 0;
 
-probe_error_media_entity_cleanup:
+probe_error_media_entity_cleanup_pm:
+	pm_runtime_disable(&client->dev);
+	pm_runtime_set_suspended(&client->dev);
 	media_entity_cleanup(&ov9734->sd.entity);
 
 probe_error_v4l2_ctrl_handler_free:
-- 
2.42.0


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

* Re: [PATCH v2 2/4] media: ov01a10: Enable runtime PM before registering async sub-device
  2023-11-22  2:54 ` [PATCH v2 2/4] media: ov01a10: " bingbu.cao
@ 2023-11-22  7:43   ` Sakari Ailus
  0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2023-11-22  7:43 UTC (permalink / raw)
  To: bingbu.cao; +Cc: linux-media, hdegoede, bingbu.cao

Hi Bingbu,

On Wed, Nov 22, 2023 at 10:54:08AM +0800, bingbu.cao@intel.com wrote:
> From: Bingbu Cao <bingbu.cao@intel.com>
> 
> As the sensor device maybe accessible right after its async sub-device is
> registered, such as ipu-bridge will try to power up sensor by sensor's client
> device's runtime PM from the async notifier callback, if runtime PM is not
> enabled, it will fail.
> 
> So runtime PM should be ready before its async sub-device is registered
> and accessible by others.
> 
> Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
> ---
>  drivers/media/i2c/ov01a10.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c
> index 2b9e1b3a3bf4..8e36f91913aa 100644
> --- a/drivers/media/i2c/ov01a10.c
> +++ b/drivers/media/i2c/ov01a10.c
> @@ -953,17 +953,20 @@ static int ov01a10_probe(struct i2c_client *client)
>  		goto err_media_entity_cleanup;
>  	}
>  
> +	pm_runtime_enable(dev);
> +	pm_runtime_idle(dev);

Somehow this driver is missign pm_runtime_set_active() call. Could you
add it? (Similarly, pm_runtime_set_suspended() goes to .remove().)

I think it's fine to have it in the same patch.

A Fixes: tag would be nice, too, including Cc: stable.

> +
>  	ret = v4l2_async_register_subdev_sensor(&ov01a10->sd);
>  	if (ret < 0) {
>  		dev_err(dev, "Failed to register subdev: %d\n", ret);
> -		goto err_media_entity_cleanup;
> +		goto err_pm_disable;
>  	}
>  
> -	pm_runtime_enable(dev);
> -	pm_runtime_idle(dev);
> -
>  	return 0;
>  
> +err_pm_disable:
> +	pm_runtime_disable(dev);
> +
>  err_media_entity_cleanup:
>  	media_entity_cleanup(&ov01a10->sd.entity);
>  

-- 
Regards,

Sakari Ailus

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

end of thread, other threads:[~2023-11-22  7:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22  2:54 [PATCH v2 0/4] Enable sensor's runtime PM before registering async sub-dev bingbu.cao
2023-11-22  2:54 ` [PATCH v2 1/4] media: imx355: Enable runtime PM before registering async sub-device bingbu.cao
2023-11-22  2:54 ` [PATCH v2 2/4] media: ov01a10: " bingbu.cao
2023-11-22  7:43   ` Sakari Ailus
2023-11-22  2:54 ` [PATCH v2 3/4] media: ov13b10: " bingbu.cao
2023-11-22  2:54 ` [PATCH v2 4/4] media: ov9734: " bingbu.cao

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).