All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hungyu Lin <dennylin0707@gmail.com>
To: Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Bryan O'Donoghue <bod@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	Stefan Schmidt <stefan.schmidt@linaro.org>,
	Hans Verkuil <hverkuil@kernel.org>,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Hungyu Lin <dennylin0707@gmail.com>
Subject: [PATCH v6] media: qcom: iris: move OPP handling to VPU power transaction
Date: Wed, 29 Jul 2026 01:10:01 +0000	[thread overview]
Message-ID: <20260729011001.16999-1-dennylin0707@gmail.com> (raw)

The power-domain helpers currently update the OPP for core->dev while
enabling or disabling one functional power domain. This makes a
transaction-wide performance state depend on a low-level helper and can
leave the maximum OPP selected when a later power-domain resume fails.

Move the maximum OPP request to iris_vpu_power_on(), after the ICC vote
and before powering on the controller and hardware. Unwind the OPP vote
together with the ICC vote on failures.

Keep the power-domain helpers limited to runtime PM and use
pm_runtime_resume_and_get() so a failed resume does not leave the usage
counter incremented.

Fixes: bb8a95aa038e ("media: iris: implement power management")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
Changes in v6:
- Move OPP handling from the power-domain helpers to
  iris_vpu_power_on().
- Request the maximum OPP before powering on the controller and
  hardware.
- Add OPP cleanup to the VPU power-on error path.
- Keep the power-domain helpers limited to runtime PM operations.
- Replace pm_runtime_get_sync() with pm_runtime_resume_and_get().
- Rename the patch to reflect the new approach.

Changes in v5:
- Add an error path to roll back the OPP vote when
  pm_runtime_resume_and_get() fails.

 .../media/platform/qcom/iris/iris_resources.c    | 16 +---------------
 .../media/platform/qcom/iris/iris_vpu_common.c   |  8 +++++++-
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
index df9b7badf0c6..5cccbf0636b0 100644
--- a/drivers/media/platform/qcom/iris/iris_resources.c
+++ b/drivers/media/platform/qcom/iris/iris_resources.c
@@ -104,39 +104,25 @@ int iris_enable_power_domains(struct iris_core *core, enum platform_pm_domain_ty
 {
 	int pd_index = iris_get_pd_index_by_type(core, pd_type);
 	struct device *pd_dev;
-	int ret;
 
 	if (pd_index < 0)
 		return pd_index;
 
 	pd_dev = core->pmdomain_tbl->pd_devs[pd_index];
 
-	ret = iris_opp_set_rate(core->dev, ULONG_MAX);
-	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, enum platform_pm_domain_type pd_type)
 {
 	int pd_index = iris_get_pd_index_by_type(core, pd_type);
 	struct device *pd_dev;
-	int ret;
 
 	if (pd_index < 0)
 		return pd_index;
 
 	pd_dev = core->pmdomain_tbl->pd_devs[pd_index];
 
-	ret = iris_opp_set_rate(core->dev, 0);
-	if (ret)
-		return ret;
-
 	pm_runtime_put_sync(pd_dev);
 
 	return 0;
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/platform/qcom/iris/iris_vpu_common.c
index ac9881e2cdc2..5209c32933db 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_common.c
+++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c
@@ -472,10 +472,14 @@ int iris_vpu_power_on(struct iris_core *core)
 	if (ret)
 		goto err;
 
-	ret = core->iris_platform_data->vpu_ops->power_on_controller(core);
+	ret = iris_opp_set_rate(core->dev, ULONG_MAX);
 	if (ret)
 		goto err_unvote_icc;
 
+	ret = core->iris_platform_data->vpu_ops->power_on_controller(core);
+	if (ret)
+		goto err_opp;
+
 	ret = core->iris_platform_data->vpu_ops->power_on_hw(core);
 	if (ret)
 		goto err_power_off_ctrl;
@@ -495,6 +499,8 @@ int iris_vpu_power_on(struct iris_core *core)
 
 err_power_off_ctrl:
 	core->iris_platform_data->vpu_ops->power_off_controller(core);
+err_opp:
+	iris_opp_set_rate(core->dev, 0);
 err_unvote_icc:
 	iris_unset_icc_bw(core);
 err:
-- 
2.43.0


             reply	other threads:[~2026-07-29  1:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  1:10 Hungyu Lin [this message]
2026-08-19 11:28 ` [PATCH v6] media: qcom: iris: move OPP handling to VPU power transaction Konrad Dybcio

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=20260729011001.16999-1-dennylin0707@gmail.com \
    --to=dennylin0707@gmail.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=bod@kernel.org \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=hverkuil@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stefan.schmidt@linaro.org \
    --cc=vikash.garodia@oss.qualcomm.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.