Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH v5 0/2] media: qcom: iris: fix runtime PM error handling
@ 2026-06-08  8:17 Hungyu Lin
  2026-06-08  8:17 ` [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks Hungyu Lin
  2026-06-08  8:17 ` [PATCH v5 2/2] media: qcom: iris: rollback OPP vote on PM resume failure Hungyu Lin
  0 siblings, 2 replies; 4+ messages in thread
From: Hungyu Lin @ 2026-06-08  8:17 UTC (permalink / raw)
  To: vikash.garodia, dikshita.agarwal
  Cc: abhinav.kumar, bod, mchehab, dmitry.baryshkov, konrad.dybcio,
	busanna.reddy, linux-media, linux-arm-msm, linux-kernel,
	Hungyu Lin

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

-- 
2.34.1


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

* [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks
  2026-06-08  8:17 [PATCH v5 0/2] media: qcom: iris: fix runtime PM error handling Hungyu Lin
@ 2026-06-08  8:17 ` Hungyu Lin
  2026-06-08  8:28   ` sashiko-bot
  2026-06-08  8:17 ` [PATCH v5 2/2] media: qcom: iris: rollback OPP vote on PM resume failure Hungyu Lin
  1 sibling, 1 reply; 4+ messages in thread
From: Hungyu Lin @ 2026-06-08  8:17 UTC (permalink / raw)
  To: vikash.garodia, dikshita.agarwal
  Cc: abhinav.kumar, bod, mchehab, dmitry.baryshkov, konrad.dybcio,
	busanna.reddy, linux-media, linux-arm-msm, linux-kernel,
	Hungyu Lin

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.

Fixes: bb8a95aa038e ("media: iris: implement power management")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/media/platform/qcom/iris/iris_resources.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
index 773f6548370a..6d3339423eec 100644
--- a/drivers/media/platform/qcom/iris/iris_resources.c
+++ b/drivers/media/platform/qcom/iris/iris_resources.c
@@ -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)
-- 
2.34.1


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

* [PATCH v5 2/2] media: qcom: iris: rollback OPP vote on PM resume failure
  2026-06-08  8:17 [PATCH v5 0/2] media: qcom: iris: fix runtime PM error handling Hungyu Lin
  2026-06-08  8:17 ` [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks Hungyu Lin
@ 2026-06-08  8:17 ` Hungyu Lin
  1 sibling, 0 replies; 4+ messages in thread
From: Hungyu Lin @ 2026-06-08  8:17 UTC (permalink / raw)
  To: vikash.garodia, dikshita.agarwal
  Cc: abhinav.kumar, bod, mchehab, dmitry.baryshkov, konrad.dybcio,
	busanna.reddy, linux-media, linux-arm-msm, linux-kernel,
	Hungyu Lin

Rollback the maximum OPP vote when
pm_runtime_resume_and_get() fails in
iris_enable_power_domains().

Use a standard rollback path to release the OPP vote when
power domain enablement does not complete successfully.

Fixes: bb8a95aa038e ("media: iris: implement power management")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/media/platform/qcom/iris/iris_resources.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
index 6d3339423eec..3e18c6998f92 100644
--- a/drivers/media/platform/qcom/iris/iris_resources.c
+++ b/drivers/media/platform/qcom/iris/iris_resources.c
@@ -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)
-- 
2.34.1


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

* Re: [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks
  2026-06-08  8:17 ` [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks Hungyu Lin
@ 2026-06-08  8:28   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-06-08  8:28 UTC (permalink / raw)
  To: Hungyu Lin; +Cc: linux-media

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 <dennylin0707@gmail.com>

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.

> diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
> --- a/drivers/media/platform/qcom/iris/iris_resources.c
> +++ b/drivers/media/platform/qcom/iris/iris_resources.c

[ ... ]

>  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;
>  }

[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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260608081721.82846-1-dennylin0707@gmail.com?part=1

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

end of thread, other threads:[~2026-06-08  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08  8:17 [PATCH v5 0/2] media: qcom: iris: fix runtime PM error handling Hungyu Lin
2026-06-08  8:17 ` [PATCH v5 1/2] media: qcom: iris: fix runtime PM reference leaks Hungyu Lin
2026-06-08  8:28   ` sashiko-bot
2026-06-08  8:17 ` [PATCH v5 2/2] media: qcom: iris: rollback OPP vote on PM resume failure Hungyu Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox