media: qcom: iris: fix runtime PM error handling
Subsystems (4)
v5 cover media: qcom: iris: fix runtime PM error handling
This series fixes two issues in the Iris power management path.
Patch 1 updates the runtime PM handling to use pm_runtime_resume_and_get() and ensures that runtime PM references remain balanced during power-down error handling.
Patch 2 rolls back the maximum OPP vote when pm_runtime_resume_and_get() fails during power-up, preventing the driver from leaving an unnecessary OPP vote active after a failed resume.
Changes in v5:
- Handle pm_runtime_put_sync() return value in iris_disable_power_domains().
- Add a blank line before return statement in rollback path.
Changes in v4:
- Added Dmitry Baryshkov's Reviewed-by tag to patch 1.
- Reworked rollback handling in patch 2 to use a standard goto-based error path.
- Roll back the OPP vote from a dedicated error label when pm_runtime_resume_and_get() fails.
Hungyu Lin (2):
media: qcom: iris: fix runtime PM reference leaks
media: qcom: iris: rollback OPP vote on PM resume failure
.../media/platform/qcom/iris/iris_resources.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
PATCH v5 1/2 media: qcom: iris: fix runtime PM reference leaks
Use pm_runtime_resume_and_get() in iris_enable_power_domains() to avoid leaking a runtime PM usage count on failure.
Also ensure pm_runtime_put_sync() is always called in iris_disable_power_domains(), even when iris_opp_set_rate() fails, so runtime PM references remain balanced.
--- drivers/media/platform/qcom/iris/iris_resources.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/media/platform/qcom/iris/iris_resources.c +6 -9
@@ -78,24 +78,21 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)if (ret)return ret; - ret =pm_runtime_get_sync (pd_dev); -if (ret <0 ) -return ret; - -return ret; +return pm_runtime_resume_and_get (pd_dev); }int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev) {int ret; +int pm_ret; ret =iris_opp_set_rate (core->dev,0 ); -if (ret) -return ret; -pm_runtime_put_sync (pd_dev); + pm_ret =pm_runtime_put_sync (pd_dev); +if (!ret) + ret = pm_ret; -return 0 ; +return ret; }static struct clk *iris_get_clk_by_type (struct iris_core *core,enum platform_clk_type clk_type)
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] `iris_disable_power_domains()` incorrectly propagates `1` on success when the device is already…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] iris_disable_power_domains() incorrectly propagates 1 on success when the device is already suspended. --
commit 7b8fb44887231870efc4a92ebbb558afa99135b1
Author: Hungyu Lin <[email protected]>
media: qcom: iris: fix runtime PM reference leaks
This commit uses pm_runtime_resume_and_get() in iris_enable_power_domains() to prevent reference leaks on failure. It also updates iris_disable_power_domains() to always call pm_runtime_put_sync() and capture its result.
Quoted 3 lines
drivers/media/platform/qcom/iris/iris_resources.c +0
-0
[ ... ]
Quoted 7 lines
int
iris_disable_power_domains(struct iris_core *core, struct device *pd_dev){drivers/media/platform/qcom/iris/iris_resources.c +1
-1int ret; +int pm_ret; ret =iris_opp_set_rate (core->dev,0 ); -if (ret)
drivers/media/platform/qcom/iris/iris_resources.c int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev) · line 96
Quoted 10 lines
drivers/media/platform/qcom/iris/iris_resources.c +4
-3-return ret; -pm_runtime_put_sync (pd_dev); + pm_ret =pm_runtime_put_sync (pd_dev); +if (!ret) + ret = pm_ret; -return 0 ; +return ret; }
[Severity: Low]
Is it intentional to propagate a positive return value here?
According to the runtime PM API, pm_runtime_put_sync() returns 1 as a success case when the device usage count drops to zero but it is already in the RPM_SUSPENDED state.
By capturing and returning this value directly from iris_disable_power_domains(), the function will return 1 instead of 0 on a successful suspend. While current callers may ignore the return value, future callers checking if (ret) could incorrectly treat this normal success case as a failure.
Would it be safer to normalize positive return values to 0?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v5 2/2 media: qcom: iris: rollback OPP vote on PM resume failure
In reply to Hungyu LinRollback the maximum OPP vote whenpm_runtime_resume_and_get() fails iniris_enable_power_domains().
Use a standard rollback path to release the OPP vote when power domain enablement does not complete successfully.
--- drivers/media/platform/qcom/iris/iris_resources.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_resources.c +10 -1
@@ -78,7 +78,16 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)if (ret)return ret; -return pm_runtime_resume_and_get (pd_dev); + ret =pm_runtime_resume_and_get (pd_dev); +if (ret) + goto err_opp; + +return 0 ; + +err_opp: +iris_opp_set_rate (core->dev,0 ); + +return ret; }int iris_disable_power_domains (struct iris_core *core,struct device *pd_dev)
Signature · 1 line
2.34.1