diff mbox series

[v3,12/13] PM: domains: Allow genpd providers to manage OPP tables directly by its FW

Message ID 20230825112633.236607-13-ulf.hansson@linaro.org (mailing list archive)
State New
Delegated to: viresh kumar
Headers show
Series arm_scmi/cpufreq: Add generic performance scaling support | expand

Commit Message

Ulf Hansson Aug. 25, 2023, 11:26 a.m. UTC
In some cases the OPP tables aren't specified in device tree, but rather
encoded in the FW. To allow a genpd provider to specify them dynamically
instead, let's add a new genpd flag, GENPD_FLAG_OPP_TABLE_FW.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---

Changes in v3:
	- None.

---
 drivers/base/power/domain.c | 11 ++++++-----
 include/linux/pm_domain.h   |  5 +++++
 2 files changed, 11 insertions(+), 5 deletions(-)

Comments

Sudeep Holla Sept. 21, 2023, 11:20 a.m. UTC | #1
On Fri, Aug 25, 2023 at 01:26:32PM +0200, Ulf Hansson wrote:
> In some cases the OPP tables aren't specified in device tree, but rather
> encoded in the FW. To allow a genpd provider to specify them dynamically
> instead, let's add a new genpd flag, GENPD_FLAG_OPP_TABLE_FW.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> 
> Changes in v3:
> 	- None.
> 

Just checking if I need Rafael's ack here or that is OK as you are
co-maintainer ? Again asking explicitly to ensure arm-soc is happy when
I send PR.
Ulf Hansson Sept. 21, 2023, 1:05 p.m. UTC | #2
On Thu, 21 Sept 2023 at 13:20, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> On Fri, Aug 25, 2023 at 01:26:32PM +0200, Ulf Hansson wrote:
> > In some cases the OPP tables aren't specified in device tree, but rather
> > encoded in the FW. To allow a genpd provider to specify them dynamically
> > instead, let's add a new genpd flag, GENPD_FLAG_OPP_TABLE_FW.
> >
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > ---
> >
> > Changes in v3:
> >       - None.
> >
>
> Just checking if I need Rafael's ack here or that is OK as you are
> co-maintainer ? Again asking explicitly to ensure arm-soc is happy when
> I send PR.

This should be fine for you to pick up. Rafael would have objected if
this was something that he didn't like. Moreover, there's no other
patches being queued for genpd at this moment so no worries of
conflicts.

Kind regards
Uffe
Sudeep Holla Sept. 21, 2023, 1:30 p.m. UTC | #3
On Thu, Sep 21, 2023 at 03:05:17PM +0200, Ulf Hansson wrote:
> On Thu, 21 Sept 2023 at 13:20, Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > On Fri, Aug 25, 2023 at 01:26:32PM +0200, Ulf Hansson wrote:
> > > In some cases the OPP tables aren't specified in device tree, but rather
> > > encoded in the FW. To allow a genpd provider to specify them dynamically
> > > instead, let's add a new genpd flag, GENPD_FLAG_OPP_TABLE_FW.
> > >
> > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > > ---
> > >
> > > Changes in v3:
> > >       - None.
> > >
> >
> > Just checking if I need Rafael's ack here or that is OK as you are
> > co-maintainer ? Again asking explicitly to ensure arm-soc is happy when
> > I send PR.
> 
> This should be fine for you to pick up. Rafael would have objected if
> this was something that he didn't like. Moreover, there's no other
> patches being queued for genpd at this moment so no worries of
> conflicts.
> 

Fair enough :), but I just wanted to confirm.
diff mbox series

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5cb2023581d4..c74edf80417f 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -130,6 +130,7 @@  static const struct genpd_lock_ops genpd_spin_ops = {
 #define genpd_is_active_wakeup(genpd)	(genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP)
 #define genpd_is_cpu_domain(genpd)	(genpd->flags & GENPD_FLAG_CPU_DOMAIN)
 #define genpd_is_rpm_always_on(genpd)	(genpd->flags & GENPD_FLAG_RPM_ALWAYS_ON)
+#define genpd_is_opp_table_fw(genpd)	(genpd->flags & GENPD_FLAG_OPP_TABLE_FW)
 
 static inline bool irq_safe_dev_in_sleep_domain(struct device *dev,
 		const struct generic_pm_domain *genpd)
@@ -2328,7 +2329,7 @@  int of_genpd_add_provider_simple(struct device_node *np,
 	genpd->dev.of_node = np;
 
 	/* Parse genpd OPP table */
-	if (genpd->set_performance_state) {
+	if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
 		ret = dev_pm_opp_of_add_table(&genpd->dev);
 		if (ret)
 			return dev_err_probe(&genpd->dev, ret, "Failed to add OPP table\n");
@@ -2343,7 +2344,7 @@  int of_genpd_add_provider_simple(struct device_node *np,
 
 	ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
 	if (ret) {
-		if (genpd->set_performance_state) {
+		if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
 			dev_pm_opp_put_opp_table(genpd->opp_table);
 			dev_pm_opp_of_remove_table(&genpd->dev);
 		}
@@ -2387,7 +2388,7 @@  int of_genpd_add_provider_onecell(struct device_node *np,
 		genpd->dev.of_node = np;
 
 		/* Parse genpd OPP table */
-		if (genpd->set_performance_state) {
+		if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
 			ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i);
 			if (ret) {
 				dev_err_probe(&genpd->dev, ret,
@@ -2423,7 +2424,7 @@  int of_genpd_add_provider_onecell(struct device_node *np,
 		genpd->provider = NULL;
 		genpd->has_provider = false;
 
-		if (genpd->set_performance_state) {
+		if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
 			dev_pm_opp_put_opp_table(genpd->opp_table);
 			dev_pm_opp_of_remove_table(&genpd->dev);
 		}
@@ -2455,7 +2456,7 @@  void of_genpd_del_provider(struct device_node *np)
 				if (gpd->provider == &np->fwnode) {
 					gpd->has_provider = false;
 
-					if (!gpd->set_performance_state)
+					if (genpd_is_opp_table_fw(gpd) || !gpd->set_performance_state)
 						continue;
 
 					dev_pm_opp_put_opp_table(gpd->opp_table);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index f776fb93eaa0..05ad8cefdff1 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -61,6 +61,10 @@ 
  * GENPD_FLAG_MIN_RESIDENCY:	Enable the genpd governor to consider its
  *				components' next wakeup when determining the
  *				optimal idle state.
+ *
+ * GENPD_FLAG_OPP_TABLE_FW:	The genpd provider supports performance states,
+ *				but its corresponding OPP tables are not
+ *				described in DT, but are given directly by FW.
  */
 #define GENPD_FLAG_PM_CLK	 (1U << 0)
 #define GENPD_FLAG_IRQ_SAFE	 (1U << 1)
@@ -69,6 +73,7 @@ 
 #define GENPD_FLAG_CPU_DOMAIN	 (1U << 4)
 #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
 #define GENPD_FLAG_MIN_RESIDENCY (1U << 6)
+#define GENPD_FLAG_OPP_TABLE_FW	 (1U << 7)
 
 enum gpd_status {
 	GENPD_STATE_ON = 0,	/* PM domain is on */