Camera sensor driver PM fixes
Subsystems (5)
Sakari Ailus
maintainercover Camera sensor driver PM fixes
Hello everyone,
Here are a few patches to fix (runtime) PM handling in the example sensor drivers. These should probably be backported but they don't seem to backport very far without conflicts. As these are almost all on error paths, I'm not sure how much effort it makes sense to put on this as no-one has reported issues in the past either.
Sakari Ailus (4):
media: i2c: ccs: Set the device's runtime PM status correctly in
remove
media: i2c: ccs: Set the device's runtime PM status correctly in probe
media: i2c: imx219: Rectify runtime PM handling in probe and remove
media: i2c: imx319: Rectify runtime PM handling probe and remove
drivers/media/i2c/ccs/ccs-core.c | 6 ++++-- drivers/media/i2c/imx219.c | 13 ++++++++----- drivers/media/i2c/imx319.c | 9 ++++++--- 3 files changed, 18 insertions(+), 10 deletions(-)
base-commit: 73ea5f5031499252f43ad046de42a9c6efea81b6
Signature · 1 line
2.39.5
Sakari Ailus
maintainerPATCH 1/4 media: i2c: ccs: Set the device's runtime PM status correctly in remove
Set the device's runtime PM status to suspended in device removal only if it wasn't suspended already.
--- drivers/media/i2c/ccs/ccs-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +3 -2
@@ -3595,9 +3595,10 @@ static void ccs_remove(struct i2c_client *client)v4l2_async_unregister_subdev (subdev);pm_runtime_disable (&client->dev); -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev)) {ccs_power_off (&client->dev); -pm_runtime_set_suspended (&client->dev); +pm_runtime_set_suspended (&client->dev); + }for (i =0 ; i < sensor->ssds_used; i++)v4l2_device_unregister_subdev (&sensor->ssds[i].sd);
Signature · 1 line
2.39.5
Sakari Ailus
maintainerPATCH 2/4 media: i2c: ccs: Set the device's runtime PM status correctly in probe
In reply to Sakari AilusSet the device's runtime PM status to suspended in probe error paths where it was previously set to active.
--- drivers/media/i2c/ccs/ccs-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ccs/ccs-core.c +1 -0
@@ -3566,6 +3566,7 @@ static int ccs_probe(struct i2c_client *client) out_disable_runtime_pm:pm_runtime_put_noidle (&client->dev);pm_runtime_disable (&client->dev); +pm_runtime_set_suspended (&client->dev); out_cleanup:ccs_cleanup (sensor);
Signature · 1 line
2.39.5
Sakari Ailus
maintainerPATCH 3/4 media: i2c: imx219: Rectify runtime PM handling in probe and remove
In reply to Sakari AilusSet the device's runtime PM status and enable runtime PM before registering the async sub-device. This is needed to avoid the case where the device is runtime PM resumed while runtime PM has not been enabled yet.
Also set the device's runtime PM status to suspended in remove only if it wasn't so already.
--- drivers/media/i2c/imx219.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/i2c/imx219.c +8 -5
@@ -1178,6 +1178,9 @@ static int imx219_probe(struct i2c_client *client) goto error_media_entity; } +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { dev_err_probe(dev, ret,
@@ -1185,15 +1188,14 @@ static int imx219_probe(struct i2c_client *client) goto error_subdev_cleanup; } -/* Enable runtime PM and turn off the device */ -pm_runtime_set_active (dev); -pm_runtime_enable (dev);pm_runtime_idle (dev);return 0 ; error_subdev_cleanup:v4l2_subdev_cleanup (&imx219->sd); +pm_runtime_disable (dev); +pm_runtime_set_suspended (dev); error_media_entity:media_entity_cleanup (&imx219->sd.entity);
@@ -1218,9 +1220,10 @@ static void imx219_remove(struct i2c_client *client)imx219_free_controls (imx219);pm_runtime_disable (&client->dev); -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev)) {imx219_power_off (&client->dev); -pm_runtime_set_suspended (&client->dev); +pm_runtime_set_suspended (&client->dev); + } }static const struct of_device_id imx219_dt_ids[] = {
Signature · 1 line
2.39.5
Re: [PATCH 3/4] media: i2c: imx219: Rectify runtime PM handling in probe and remove
Quoted 61 lines · Sakari Ailus
Set the device's runtime PM status and enable runtime PM before registering the async sub-device. This is needed to avoid the case where the device is runtime PM resumed while runtime PM has not been enabled yet.
Also set the device's runtime PM status to suspended in remove only if it wasn't so already.
Fixes 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor")Cc [email protected] # for >= v6.6Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/imx219.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/media/i2c/imx219.c +8
-5@@ -1178,6 +1178,9 @@ static int imx219_probe(struct i2c_client *client) goto error_media_entity; } +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { dev_err_probe(dev, ret,@@ -1185,15 +1188,14 @@ static int imx219_probe(struct i2c_client *client) goto error_subdev_cleanup; } -/* Enable runtime PM and turn off the device */ -pm_runtime_set_active (dev); -pm_runtime_enable (dev);pm_runtime_idle (dev);return 0 ; error_subdev_cleanup:v4l2_subdev_cleanup (&imx219->sd); +pm_runtime_disable (dev); +pm_runtime_set_suspended (dev); error_media_entity:media_entity_cleanup (&imx219->sd.entity);@@ -1218,9 +1220,10 @@ static void imx219_remove(struct i2c_client *client)imx219_free_controls (imx219);pm_runtime_disable (&client->dev); -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev)) {imx219_power_off (&client->dev); -pm_runtime_set_suspended (&client->dev); +pm_runtime_set_suspended (&client->dev); + } }static const struct of_device_id imx219_dt_ids[] = {
Signature · 2 lines
Best regards, Bingbu Cao
Re: [PATCH 3/4] media: i2c: imx219: Rectify runtime PM handling in probe and remove
In reply to Sakari AilusThanks Sakari
Quoted 6 lines · Sakari Ailus
Set the device's runtime PM status and enable runtime PM before registering the async sub-device. This is needed to avoid the case where the device is runtime PM resumed while runtime PM has not been enabled yet.
Quoted 6 lines
Also set the device's runtime PM status to suspended in remove only if it wasn't so already.
Fixes 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor")Cc [email protected] # for >= v6.6Signed-off-by Sakari Ailus <[email protected]>
Quoted 52 lines
--- drivers/media/i2c/imx219.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/media/i2c/imx219.c +8
-6@@ -1178,6 +1178,9 @@ static int imx219_probe(struct i2c_client *client) goto error_media_entity; } +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { dev_err_probe(dev, ret,@@ -1185,15 +1188,14 @@ static int imx219_probe(struct i2c_client *client) goto error_subdev_cleanup; } -/* Enable runtime PM and turn off the device */ -pm_runtime_set_active (dev); -pm_runtime_enable (dev);pm_runtime_idle (dev);return 0 ; error_subdev_cleanup:v4l2_subdev_cleanup (&imx219->sd); +pm_runtime_disable (dev); +pm_runtime_set_suspended (dev); error_media_entity:media_entity_cleanup (&imx219->sd.entity);@@ -1218,9 +1220,10 @@ static void imx219_remove(struct i2c_client *client)imx219_free_controls (imx219);pm_runtime_disable (&client->dev); -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev)) {imx219_power_off (&client->dev); -pm_runtime_set_suspended (&client->dev); +pm_runtime_set_suspended (&client->dev); + } }static const struct of_device_id imx219_dt_ids[] = { --2.39.5
Sakari Ailus
maintainerPATCH 4/4 media: i2c: imx319: Rectify runtime PM handling probe and remove
In reply to Sakari AilusIdle the device only after the async sub-device has been successfully registered. In error handling, set the device's runtime PM status to suspended only if it has been set to active previously in probe.
Also set the device's runtime PM status to suspended in remove only if it wasn't so already.
--- drivers/media/i2c/imx319.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/i2c/imx319.c +6 -3
@@ -2442,17 +2442,19 @@ static int imx319_probe(struct i2c_client *client)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 (&imx319->sd);if (ret <0 ) goto error_media_entity_pm; +pm_runtime_idle (&client->dev); +return 0 ; error_media_entity_pm:pm_runtime_disable (&client->dev); -pm_runtime_set_suspended (&client->dev); +if (full_power) +pm_runtime_set_suspended (&client->dev);media_entity_cleanup (&imx319->sd.entity); error_handler_free:
@@ -2474,7 +2476,8 @@ static void imx319_remove(struct i2c_client *client)v4l2_ctrl_handler_free (sd->ctrl_handler);pm_runtime_disable (&client->dev); -pm_runtime_set_suspended (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) +pm_runtime_set_suspended (&client->dev);mutex_destroy (&imx319->mutex); }
Signature · 1 line
2.39.5