linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Sudeep Holla <sudeep.holla@arm.com>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Viresh Kumar <vireshk@kernel.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>
Cc: Nishanth Menon <nm@ti.com>, Stephen Boyd <sboyd@kernel.org>,
	Nikunj Kela <nkela@quicinc.com>,
	Prasad Sodagudi <psodagud@quicinc.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 9/9] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain
Date: Mon, 25 Sep 2023 15:17:15 +0200	[thread overview]
Message-ID: <20230925131715.138411-10-ulf.hansson@linaro.org> (raw)
In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org>

To allow a consumer driver to use the OPP library to scale the performance
for its device, let's dynamically add the OPP table when the device gets
attached to its SCMI performance domain.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/pmdomain/arm/scmi_perf_domain.c | 34 +++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/pmdomain/arm/scmi_perf_domain.c b/drivers/pmdomain/arm/scmi_perf_domain.c
index aa100270500f..bc3f78abb6da 100644
--- a/drivers/pmdomain/arm/scmi_perf_domain.c
+++ b/drivers/pmdomain/arm/scmi_perf_domain.c
@@ -9,6 +9,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/pm_domain.h>
+#include <linux/pm_opp.h>
 #include <linux/scmi_protocol.h>
 #include <linux/slab.h>
 
@@ -42,6 +43,37 @@ scmi_pd_set_perf_state(struct generic_pm_domain *genpd, unsigned int state)
 	return ret;
 }
 
+static int
+scmi_pd_attach_dev(struct generic_pm_domain *genpd, struct device *dev)
+{
+	struct scmi_perf_domain *pd = to_scmi_pd(genpd);
+	int ret;
+
+	/*
+	 * Allow the device to be attached, but don't add the OPP table unless
+	 * the performance level can be changed.
+	 */
+	if (!pd->info->set_perf)
+		return 0;
+
+	ret = pd->perf_ops->device_opps_add(pd->ph, dev, pd->domain_id);
+	if (ret)
+		dev_warn(dev, "failed to add OPPs for the device\n");
+
+	return ret;
+}
+
+static void
+scmi_pd_detach_dev(struct generic_pm_domain *genpd, struct device *dev)
+{
+	struct scmi_perf_domain *pd = to_scmi_pd(genpd);
+
+	if (!pd->info->set_perf)
+		return;
+
+	dev_pm_opp_remove_all_dynamic(dev);
+}
+
 static int scmi_perf_domain_probe(struct scmi_device *sdev)
 {
 	struct device *dev = &sdev->dev;
@@ -95,6 +127,8 @@ static int scmi_perf_domain_probe(struct scmi_device *sdev)
 		scmi_pd->genpd.flags = GENPD_FLAG_ALWAYS_ON |
 				       GENPD_FLAG_OPP_TABLE_FW;
 		scmi_pd->genpd.set_performance_state = scmi_pd_set_perf_state;
+		scmi_pd->genpd.attach_dev = scmi_pd_attach_dev;
+		scmi_pd->genpd.detach_dev = scmi_pd_detach_dev;
 
 		ret = pm_genpd_init(&scmi_pd->genpd, NULL, false);
 		if (ret)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-09-25 13:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25 13:17 [PATCH 0/9] PM: domains/opp/arm_scmi: Extend performance scaling support Ulf Hansson
2023-09-25 13:17 ` [PATCH 1/9] PM: domains: Introduce dev_pm_domain_set_performance_state() Ulf Hansson
2023-09-25 13:17 ` [PATCH 2/9] PM: domains: Implement the ->set_performance_state() callback for genpd Ulf Hansson
2023-09-25 13:17 ` [PATCH 3/9] OPP: Add dev_pm_opp_add_dynamic() to allow more flexibility Ulf Hansson
2023-09-25 13:17 ` [PATCH 4/9] OPP: Extend dev_pm_opp_data with a level Ulf Hansson
2023-09-25 13:17 ` [PATCH 5/9] OPP: Switch to use dev_pm_domain_set_performance_state() Ulf Hansson
2023-09-25 13:17 ` [PATCH 6/9] OPP: Extend support for the opp-level beyond required-opps Ulf Hansson
2023-09-25 13:33   ` Ulf Hansson
2023-10-03  8:23     ` Viresh Kumar
2023-10-03 12:36       ` Ulf Hansson
2023-10-04  5:04         ` Viresh Kumar
2023-10-04  9:06           ` Ulf Hansson
2023-09-25 13:17 ` [PATCH 7/9] firmware: arm_scmi: Simplify error path in scmi_dvfs_device_opps_add() Ulf Hansson
2023-09-25 13:17 ` [PATCH 8/9] firmware: arm_scmi: Specify the performance level when adding an OPP Ulf Hansson
2023-09-25 13:17 ` Ulf Hansson [this message]
2023-09-29 16:25   ` [PATCH 9/9] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain Sudeep Holla
2023-10-03  8:21     ` Viresh Kumar
2023-10-03 11:26       ` Sudeep Holla
2023-10-04  5:08         ` Viresh Kumar
2023-10-05 15:06           ` Sudeep Holla
2023-10-06  7:09             ` Viresh Kumar
2023-10-06  9:43               ` Sudeep Holla
2023-09-26 16:54 ` [PATCH 0/9] PM: domains/opp/arm_scmi: Extend performance scaling support Rafael J. Wysocki
2023-10-06 14:30 ` (subset) " Sudeep Holla

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=20230925131715.138411-10-ulf.hansson@linaro.org \
    --to=ulf.hansson@linaro.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nkela@quicinc.com \
    --cc=nm@ti.com \
    --cc=psodagud@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=vireshk@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).