diff mbox series

[9/9] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain

Message ID 20230925131715.138411-10-ulf.hansson@linaro.org
State Accepted
Commit 0a81b0eb81ca94f2be9712b85c2d1c32542a17b2
Headers show
Series [1/9] PM: domains: Introduce dev_pm_domain_set_performance_state() | expand

Commit Message

Ulf Hansson Sept. 25, 2023, 1:17 p.m. UTC
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(+)

Comments

Sudeep Holla Sept. 29, 2023, 4:25 p.m. UTC | #1
On Mon, Sep 25, 2023 at 03:17:15PM +0200, Ulf Hansson wrote:
> 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.
>

The SCMI changes(patches 7-9) look fine to me. Rafael was fine with genpd
changes, Viresh if you are OK with OPP changes I can take it via SCMI as
there are some dependent patches as Ulf has pointed out in the cover letter.

--
Regards,
Sudeep
Viresh Kumar Oct. 3, 2023, 8:21 a.m. UTC | #2
On 29-09-23, 17:25, Sudeep Holla wrote:
> On Mon, Sep 25, 2023 at 03:17:15PM +0200, Ulf Hansson wrote:
> > 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.
> >
> 
> The SCMI changes(patches 7-9) look fine to me. Rafael was fine with genpd
> changes, Viresh if you are OK with OPP changes I can take it via SCMI as
> there are some dependent patches as Ulf has pointed out in the cover letter.

I would like to take OPP patches via my tree as there are some changes in my
tree and I plan to add some more changes on top of this. I can give an immutable
branch though.
Sudeep Holla Oct. 3, 2023, 11:26 a.m. UTC | #3
On Tue, Oct 03, 2023 at 01:51:33PM +0530, Viresh Kumar wrote:
> On 29-09-23, 17:25, Sudeep Holla wrote:
> > On Mon, Sep 25, 2023 at 03:17:15PM +0200, Ulf Hansson wrote:
> > > 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.
> > >
> > 
> > The SCMI changes(patches 7-9) look fine to me. Rafael was fine with genpd
> > changes, Viresh if you are OK with OPP changes I can take it via SCMI as
> > there are some dependent patches as Ulf has pointed out in the cover letter.
> 
> I would like to take OPP patches via my tree as there are some changes in my
> tree and I plan to add some more changes on top of this. I can give an immutable
> branch though.
>

Works for me. Please do share it once you have it ready.
Viresh Kumar Oct. 4, 2023, 5:08 a.m. UTC | #4
On 03-10-23, 12:26, Sudeep Holla wrote:
> On Tue, Oct 03, 2023 at 01:51:33PM +0530, Viresh Kumar wrote:
> > On 29-09-23, 17:25, Sudeep Holla wrote:
> > > On Mon, Sep 25, 2023 at 03:17:15PM +0200, Ulf Hansson wrote:
> > > > 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.
> > > >
> > > 
> > > The SCMI changes(patches 7-9) look fine to me. Rafael was fine with genpd
> > > changes, Viresh if you are OK with OPP changes I can take it via SCMI as
> > > there are some dependent patches as Ulf has pointed out in the cover letter.
> > 
> > I would like to take OPP patches via my tree as there are some changes in my
> > tree and I plan to add some more changes on top of this. I can give an immutable
> > branch though.
> >
> 
> Works for me. Please do share it once you have it ready.

git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git opp/pm-domain-scmi
Sudeep Holla Oct. 5, 2023, 3:06 p.m. UTC | #5
On Wed, Oct 04, 2023 at 10:38:06AM +0530, Viresh Kumar wrote:
> On 03-10-23, 12:26, Sudeep Holla wrote:
> > On Tue, Oct 03, 2023 at 01:51:33PM +0530, Viresh Kumar wrote:
> > > On 29-09-23, 17:25, Sudeep Holla wrote:
> > > > On Mon, Sep 25, 2023 at 03:17:15PM +0200, Ulf Hansson wrote:
> > > > > 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.
> > > > >
> > > > 
> > > > The SCMI changes(patches 7-9) look fine to me. Rafael was fine with genpd
> > > > changes, Viresh if you are OK with OPP changes I can take it via SCMI as
> > > > there are some dependent patches as Ulf has pointed out in the cover letter.
> > > 
> > > I would like to take OPP patches via my tree as there are some changes in my
> > > tree and I plan to add some more changes on top of this. I can give an immutable
> > > branch though.
> > >
> > 
> > Works for me. Please do share it once you have it ready.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git opp/pm-domain-scmi
> 

Thanks, I wasn't expecting these patches in the branch, but if you are
aware off and are fine with it, I have no objections.

	dt-bindings: opp: opp-v2-kryo-cpu: Allow opp-peak-kBps
	OPP: debugfs: Fix warning with W=1 builds
	OPP: Remove doc style comments for internal routines
	OPP: Add dev_pm_opp_find_level_floor()
Viresh Kumar Oct. 6, 2023, 7:09 a.m. UTC | #6
On 05-10-23, 16:06, Sudeep Holla wrote:
> Thanks, I wasn't expecting these patches in the branch, but if you are
> aware off and are fine with it, I have no objections.
> 
> 	dt-bindings: opp: opp-v2-kryo-cpu: Allow opp-peak-kBps
> 	OPP: debugfs: Fix warning with W=1 builds
> 	OPP: Remove doc style comments for internal routines
> 	OPP: Add dev_pm_opp_find_level_floor()

Ahh, I didn't create a fresh branch for this but added them on top of
OPP changes. Fixed it now. Fetch the repo again.
Sudeep Holla Oct. 6, 2023, 9:43 a.m. UTC | #7
On Fri, Oct 06, 2023 at 12:39:23PM +0530, Viresh Kumar wrote:
> On 05-10-23, 16:06, Sudeep Holla wrote:
> > Thanks, I wasn't expecting these patches in the branch, but if you are
> > aware off and are fine with it, I have no objections.
> > 
> > 	dt-bindings: opp: opp-v2-kryo-cpu: Allow opp-peak-kBps
> > 	OPP: debugfs: Fix warning with W=1 builds
> > 	OPP: Remove doc style comments for internal routines
> > 	OPP: Add dev_pm_opp_find_level_floor()
> 
> Ahh, I didn't create a fresh branch for this but added them on top of
> OPP changes. Fixed it now. Fetch the repo again.

Thanks, glad I asked, initially assumed you were aware of it :).
diff mbox series

Patch

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)