All of lore.kernel.org
 help / color / mirror / Atom feed
From: bingbu.cao@intel.com
To: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com
Cc: hdegoede@redhat.com, bingbu.cao@intel.com, bingbu.cao@linux.intel.com
Subject: [PATCH 4/4] media: ov9734: Enable runtime PM before registering async sub-device
Date: Mon,  6 Nov 2023 16:35:16 +0800	[thread overview]
Message-ID: <20231106083516.763184-5-bingbu.cao@intel.com> (raw)
In-Reply-To: <20231106083516.763184-1-bingbu.cao@intel.com>

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 | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c
index b6244772bc59..1a241b2b6099 100644
--- a/drivers/media/i2c/ov9734.c
+++ b/drivers/media/i2c/ov9734.c
@@ -984,24 +984,27 @@ 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.
 	 */
 	pm_runtime_set_active(&client->dev);
 	pm_runtime_enable(&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;
+	}
+
 	pm_runtime_idle(&client->dev);
 
 	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


  parent reply	other threads:[~2023-11-06  8:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06  8:35 [PATCH 0/4] Enable sensor's runtime PM before registering async sub-dev bingbu.cao
2023-11-06  8:35 ` [PATCH 1/4] media: imx355: Enable runtime PM before registering async sub-device bingbu.cao
2023-11-06  8:35 ` [PATCH 2/4] media: ov01a10: " bingbu.cao
2023-11-06  8:35 ` [PATCH 3/4] media: ov13b10: " bingbu.cao
2023-11-06  8:35 ` bingbu.cao [this message]
2023-11-20  4:14 ` [PATCH 0/4] Enable sensor's runtime PM before registering async sub-dev Bingbu Cao
2023-11-20  6:35   ` Sakari Ailus
2023-11-21  3:03     ` Bingbu Cao
2023-11-21  6:49       ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231106083516.763184-5-bingbu.cao@intel.com \
    --to=bingbu.cao@intel.com \
    --cc=bingbu.cao@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.