Skip to contentSkip to conversation

Fix PM on imx214 error paths

PATCH In review Sakari Ailus 2 participants 9 messages Jan 16, 2025 – Feb 5, 2025

Subsystems (3)
lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

cover Fix PM on imx214 error paths

Hi André,

I'm posting this separately as it seems to be backportable, your set needs to go on the top. I've pushed that to my "devel" branch in my git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

Sakari Ailus (2):
Revert "media: imx214: Fix the error handling in imx214_probe()"
media: i2c: imx214: Rectify probe error handling related to runtime PM

 drivers/media/i2c/imx214.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 1/2 Revert "media: imx214: Fix the error handling in imx214_probe()"

This reverts commit 9bc92332cc3f06fda3c6e2423995ca2da0a7ec9a.

Revert this "fix" as it's not really helpful but makes backporting a proper fix harder.

Fixes 9bc92332cc3f ("media: imx214: Fix the error handling in imx214_probe()")
Cc [email protected] # for >= v6.12
---
 drivers/media/i2c/imx214.c | 1 -
 1 file changed, 1 deletion(-)
drivers/media/i2c/imx214.c +0 -1
index 4962cfe7c83d..10b6ad66d126 100644
@@ -1114,7 +1114,6 @@ static int imx214_probe(struct i2c_client *client)
 	v4l2_ctrl_handler_free(&imx214->ctrls);
 error_power_off:
 	pm_runtime_disable(imx214->dev);
-	regulator_bulk_disable(IMX214_NUM_SUPPLIES, imx214->supplies);
 
 	return ret;
 }
Signature · 1 line
2.39.5
author maintainer
#2 lore raw

PATCH 2/2 media: i2c: imx214: Rectify probe error handling related to runtime PM

In reply to Sakari Ailus

There were multiple issues in the driver's probe function related to error handling:

- Device's PM runtime status wasn't reverted to suspended on some errors in probe.

- Runtime PM was left enabled for the device on some probe errors.

- Device was left powered on if a probe failure happened or when it was removed when it was powered on.

- An extra pm_runtime_set_suspended() was issued in driver's remove function when the device was suspended.

Fix these bugs.

Fixes 436190596241 ("media: imx214: Add imx214 camera sensor driver")
Cc [email protected] # for >= v6.12
---
 drivers/media/i2c/imx214.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/media/i2c/imx214.c +15 -9
index 10b6ad66d126..6a393e18267f 100644
@@ -1075,10 +1075,6 @@ static int imx214_probe(struct i2c_client *client)
 	 */
 	imx214_power_on(imx214->dev);
 
-	pm_runtime_set_active(imx214->dev);
-	pm_runtime_enable(imx214->dev);
-	pm_runtime_idle(imx214->dev);
-
 	ret = imx214_ctrls_init(imx214);
 	if (ret < 0)
 		goto error_power_off;
@@ -1099,21 +1095,30 @@ static int imx214_probe(struct i2c_client *client)
 
 	imx214_entity_init_state(&imx214->sd, NULL);
 
+	pm_runtime_set_active(imx214->dev);
+	pm_runtime_enable(imx214->dev);
+
 	ret = v4l2_async_register_subdev_sensor(&imx214->sd);
 	if (ret < 0) {
 		dev_err(dev, "could not register v4l2 device\n");
 		goto free_entity;
 	}
 
+	pm_runtime_idle(imx214->dev);
+
 	return 0;
 
 free_entity:
+	pm_runtime_disable(imx214->dev);
+	pm_runtime_set_suspended(&client->dev);
 	media_entity_cleanup(&imx214->sd.entity);
+
 free_ctrl:
 	mutex_destroy(&imx214->mutex);
 	v4l2_ctrl_handler_free(&imx214->ctrls);
+
 error_power_off:
-	pm_runtime_disable(imx214->dev);
+	imx214_power_off(imx214->dev);
 
 	return ret;
 }
@@ -1126,11 +1131,12 @@ static void imx214_remove(struct i2c_client *client)
 	v4l2_async_unregister_subdev(&imx214->sd);
 	media_entity_cleanup(&imx214->sd.entity);
 	v4l2_ctrl_handler_free(&imx214->ctrls);
-
-	pm_runtime_disable(&client->dev);
-	pm_runtime_set_suspended(&client->dev);
-
 	mutex_destroy(&imx214->mutex);
+	pm_runtime_disable(&client->dev);
+	if (!pm_runtime_status_suspended(&client->dev)) {
+		imx214_power_off(imx214->dev);
+		pm_runtime_set_suspended(&client->dev);
+	}
 }
 
 static const struct of_device_id imx214_of_match[] = {
Signature · 1 line
2.39.5
Acked-by on the v1 series
#3 lore raw
In reply to Sakari Ailus

Hi Sakari,

Am Donnerstag, dem 16.01.2025 um 13:46 +0200 schrieb Sakari Ailus:

Quoted 7 lines

Hi André,

I'm posting this separately as it seems to be backportable, your set needs to go on the top. I've pushed that to my "devel" branch in my git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

The patches look good to me. I don't see any problems, but I haven't tested the error paths. That's why no "Tested-by".

Shall I send a new version of my patches rebased on yours or can my patches be taken from your "devel" branch?

Regards,
André

Quoted 9 lines

Sakari Ailus (2):
  Revert "media: imx214: Fix the error handling in imx214_probe()"
  media: i2c: imx214: Rectify probe error handling related to runtime PM

 drivers/media/i2c/imx214.c | 25 +++++++++++++++----------

 1 file changed, 15 insertions(+), 10 deletions(-)
author maintainer
#4 lore raw

Hi André,

Quoted 11 lines · André Apitzsch

Hi Sakari,

Am Donnerstag, dem 16.01.2025 um 13:46 +0200 schrieb Sakari Ailus:

Quoted 7 lines

Hi André,

I'm posting this separately as it seems to be backportable, your set needs to go on the top. I've pushed that to my "devel" branch in my git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

Quoted 7 lines

The patches look good to me. I don't see any problems, but I haven't tested the error paths. That's why no "Tested-by".

Shall I send a new version of my patches rebased on yours or can my patches be taken from your "devel" branch?

If you're fine with the result of my rebase, there's no need to.

Signature · 3 lines
Kind regards,

Sakari Ailus
#5 lore raw

Hi Sakari,

Am Mittwoch, dem 22.01.2025 um 12:04 +0000 schrieb Sakari Ailus:

Quoted 20 lines

Hi André,

Quoted 17 lines · André Apitzsch

Hi Sakari,

Am Donnerstag, dem 16.01.2025 um 13:46 +0200 schrieb Sakari Ailus:

Quoted 9 lines

Hi André,

I'm posting this separately as it seems to be backportable, your set
needs to go on the top. I've pushed that to my "devel" branch in my
git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

The patches look good to me. I don't see any problems, but I haven't
tested the error paths. That's why no "Tested-by".

Quoted 7 lines
Quoted 4 lines

Shall I send a new version of my patches rebased on yours or can my patches be taken from your "devel" branch?

If you're fine with the result of my rebase, there's no need to.

I'm fine with that.

André

author maintainer
#6 lore raw
Quoted 23 lines · André Apitzsch

Hi Sakari,

Am Mittwoch, dem 22.01.2025 um 12:04 +0000 schrieb Sakari Ailus:

Quoted 20 lines

Hi André,

Quoted 17 lines · André Apitzsch

Hi Sakari,

Am Donnerstag, dem 16.01.2025 um 13:46 +0200 schrieb Sakari Ailus:

Quoted 9 lines

Hi André,

I'm posting this separately as it seems to be backportable, your set
needs to go on the top. I've pushed that to my "devel" branch in my
git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

The patches look good to me. I don't see any problems, but I haven't
tested the error paths. That's why no "Tested-by".

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Shall I send a new version of my patches rebased on yours or can my patches be taken from your "devel" branch?

If you're fine with the result of my rebase, there's no need to.

I'm fine with that.

Ack, thanks!

Signature · 1 line
Sakari Ailus
#7 lore raw

Hi Sakari,

Am Donnerstag, dem 23.01.2025 um 07:44 +0000 schrieb Sakari Ailus:

Quoted 24 lines · André Apitzsch
Quoted 23 lines

Hi Sakari,

Am Mittwoch, dem 22.01.2025 um 12:04 +0000 schrieb Sakari Ailus:

Quoted 20 lines

Hi André,

Quoted 17 lines · André Apitzsch

Hi Sakari,

Am Donnerstag, dem 16.01.2025 um 13:46 +0200 schrieb Sakari Ailus:

Quoted 7 lines

Hi André,

I'm posting this separately as it seems to be backportable, your set needs to go on the top. I've pushed that to my "devel" branch in my git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

The patches look good to me. I don't see any problems, but I haven't tested the error paths. That's why no "Tested-by".

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Shall I send a new version of my patches rebased on yours or can my patches be taken from your "devel" branch?

If you're fine with the result of my rebase, there's no need to.

I'm fine with that.

Ack, thanks!

What is missing to get your and my imx214 changes into next?

Regards,
André

author maintainer
#8 lore raw

Hi André,

Quoted 30 lines · André Apitzsch

Hi Sakari,

Am Donnerstag, dem 23.01.2025 um 07:44 +0000 schrieb Sakari Ailus:

Quoted 27 lines · André Apitzsch
Quoted 26 lines

Hi Sakari,

Am Mittwoch, dem 22.01.2025 um 12:04 +0000 schrieb Sakari Ailus:

Quoted 23 lines

Hi André,

Quoted 19 lines · André Apitzsch

Hi Sakari,

Am Donnerstag, dem 16.01.2025 um 13:46 +0200 schrieb Sakari Ailus:

Quoted 7 lines

Hi André,

I'm posting this separately as it seems to be backportable, your set needs to go on the top. I've pushed that to my "devel" branch in my git.linuxtv.org tree <URL:https://git.linuxtv.org/sailus/media_tree.git/>, please let me know if you see problems.

The patches look good to me. I don't see any problems, but I haven't tested the error paths. That's why no "Tested-by".

Shall I send a new version of my patches rebased on yours or can my patches be taken from your "devel" branch?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

If you're fine with the result of my rebase, there's no need to.

I'm fine with that.

Ack, thanks!

What is missing to get your and my imx214 changes into next?

It'll still take a while but shouldn't be long.

Signature · 1 line
Sakari Ailus