Skip to contentSkip to conversation

PM / Domains: Add support for 'required-opps' to set default perf state

PATCH Superseded Rajendra Nayak 4 participants 19 messages Jul 16, 2021 – Jul 28, 2021

Subsystems (9)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover PM / Domains: Add support for 'required-opps' to set default perf state

v4: Fixed error handling in __genpd_dev_pm_attach()

This is a re-spin of the series [1] which was adding support for a new DT binding (assigned-performance-state) and based on the discussions on that thread [2] it was concluded that we could achieve the same with the existing 'required-opps' binding instead.

So this series, just drops the new binding and uses required-opps to achieve the default perf state setting thats needed by some devices.

---
Some devics within power-domains with performance states do not support DVFS, but still need to vote on a default/static state while they are active. Add support for this using the 'required-opps' property in device tree.

[1] https://lore.kernel.org/patchwork/project/lkml/list/?series=501336&state=%2A&archive=both
[2] https://lore.kernel.org/patchwork/patch/1436886/

Rajendra Nayak (2):
PM / Domains: Add support for 'required-opps' to set default perf
state
arm64: dts: sc7180: Add required-opps for i2c

 arch/arm64/boot/dts/qcom/sc7180.dtsi | 24 +++++++++++++++++++++++
 drivers/base/power/domain.c          | 37 +++++++++++++++++++++++++++++++++---
 include/linux/pm_domain.h            |  1 +
 3 files changed, 59 insertions(+), 3 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

PATCH v4 2/2 arm64: dts: sc7180: Add required-opps for i2c

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm64/boot/dts/qcom/sc7180.dtsi +24 -0
index a5d58eb..cd30185 100644
@@ -785,8 +785,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi0: spi@880000 {
@@ -837,8 +839,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi1: spi@884000 {
@@ -889,8 +893,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart2: serial@888000 {
@@ -923,8 +929,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi3: spi@88c000 {
@@ -975,8 +983,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart4: serial@890000 {
@@ -1009,8 +1019,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi5: spi@894000 {
@@ -1074,8 +1086,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi6: spi@a80000 {
@@ -1126,8 +1140,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart7: serial@a84000 {
@@ -1160,8 +1176,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi8: spi@a88000 {
@@ -1212,8 +1230,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart9: serial@a8c000 {
@@ -1246,8 +1266,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi10: spi@a90000 {
@@ -1298,8 +1320,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi11: spi@a94000 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH v4 1/2 PM / Domains: Add support for 'required-opps' to set default perf state

In reply to Rajendra Nayak

Some devics within power domains with performance states do not support DVFS, but still need to vote on a default/static state while they are active. They can express this using the 'required-opps' property in device tree, which points to the phandle of the OPP supported by the corresponding power-domains.

Add support to parse this information from DT and then set the specified performance state during attach and drop it on detach. Also drop/set as part of runtime suspend/resume callbacks.

---
 drivers/base/power/domain.c | 37 ++++++++++++++++++++++++++++++++++---
 include/linux/pm_domain.h   |  1 +
 2 files changed, 35 insertions(+), 3 deletions(-)
drivers/base/power/domain.c +34 -3
index a934c67..dcc0b71 100644
@@ -917,6 +917,10 @@ static int genpd_runtime_suspend(struct device *dev)
 	if (irq_safe_dev_in_no_sleep_domain(dev, genpd))
 		return 0;
 
+	/* Drop the default performance state */
+	if (dev_gpd_data(dev)->default_pstate)
+		dev_pm_genpd_set_performance_state(dev, 0);
+
 	genpd_lock(genpd);
 	gpd_data->rpm_pstate = genpd_drop_performance_state(dev);
 	genpd_power_off(genpd, true, 0);
@@ -937,6 +941,7 @@ static int genpd_runtime_resume(struct device *dev)
 {
 	struct generic_pm_domain *genpd;
 	struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev);
+	unsigned int default_pstate = gpd_data->default_pstate;
 	struct gpd_timing_data *td = &gpd_data->td;
 	bool runtime_pm = pm_runtime_enabled(dev);
 	ktime_t time_start;
@@ -968,6 +973,9 @@ static int genpd_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	/* Set the default performance state */
+	if (default_pstate)
+		dev_pm_genpd_set_performance_state(dev, default_pstate);
  out:
 	/* Measure resume latency. */
 	time_start = 0;
@@ -1000,6 +1008,8 @@ static int genpd_runtime_resume(struct device *dev)
 	genpd_stop_dev(genpd, dev);
 err_poweroff:
 	if (!pm_runtime_is_irq_safe(dev) || genpd_is_irq_safe(genpd)) {
+		if (default_pstate)
+			dev_pm_genpd_set_performance_state(dev, 0);
 		genpd_lock(genpd);
 		gpd_data->rpm_pstate = genpd_drop_performance_state(dev);
 		genpd_power_off(genpd, true, 0);
@@ -2598,6 +2608,12 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
 
 	dev_dbg(dev, "removing from PM domain %s\n", pd->name);
 
+	/* Drop the default performance state */
+	if (dev_gpd_data(dev)->default_pstate) {
+		dev_pm_genpd_set_performance_state(dev, 0);
+		dev_gpd_data(dev)->default_pstate = 0;
+	}
+
 	for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
 		ret = genpd_remove_device(pd, dev);
 		if (ret != -EAGAIN)
@@ -2635,9 +2651,10 @@ static void genpd_dev_pm_sync(struct device *dev)
 static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 				 unsigned int index, bool power_on)
 {
+	struct device_node *np;
 	struct of_phandle_args pd_args;
 	struct generic_pm_domain *pd;
-	int ret;
+	int ret, pstate;
 
 	ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
 				"#power-domain-cells", index, &pd_args);
@@ -2675,10 +2692,24 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 		genpd_unlock(pd);
 	}
 
-	if (ret)
+	if (ret) {
 		genpd_remove_device(pd, dev);
+		return -EPROBE_DEFER;
+	}
+
+	/* Set the default performance state */
+	np = base_dev->of_node;
+	if (of_parse_phandle(np, "required-opps", index)) {
+		pstate = of_get_required_opp_performance_state(np, index);
+		if (pstate < 0) {
+			dev_err(dev, "failed to set pstate:%d", pstate);
+			ret = pstate;
+		}
+		dev_pm_genpd_set_performance_state(dev, pstate);
+		dev_gpd_data(dev)->default_pstate = pstate;
+	}
 
-	return ret ? -EPROBE_DEFER : 1;
+	return ret ? ret : 1;
 }
 
 /**
include/linux/pm_domain.h +1 -0
index 21a0577..67017c9 100644
@@ -198,6 +198,7 @@ struct generic_pm_domain_data {
 	struct notifier_block *power_nb;
 	int cpu;
 	unsigned int performance_state;
+	unsigned int default_pstate;
 	unsigned int rpm_pstate;
 	ktime_t	next_wakeup;
 	void *data;
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Reviewed-by on v4 2/2
#5 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

In reply to Rajendra Nayak

Quoting Rajendra Nayak (2021-07-16 03:00:58)

Quoted 11 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

---

#6 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

In reply to Rajendra Nayak
Quoted 5 lines · Rajendra Nayak

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Regards,
Bjorn

Quoted 145 lines
---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm64/boot/dts/qcom/sc7180.dtsi +24 -0
index a5d58eb..cd30185 100644
@@ -785,8 +785,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi0: spi@880000 {
@@ -837,8 +839,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi1: spi@884000 {
@@ -889,8 +893,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart2: serial@888000 {
@@ -923,8 +929,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi3: spi@88c000 {
@@ -975,8 +983,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart4: serial@890000 {
@@ -1009,8 +1019,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>,
 						<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi5: spi@894000 {
@@ -1074,8 +1086,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi6: spi@a80000 {
@@ -1126,8 +1140,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart7: serial@a84000 {
@@ -1160,8 +1176,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi8: spi@a88000 {
@@ -1212,8 +1230,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			uart9: serial@a8c000 {
@@ -1246,8 +1266,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi10: spi@a90000 {
@@ -1298,8 +1320,10 @@
 						<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_1 0>,
 						<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
 				interconnect-names = "qup-core", "qup-config",
 							"qup-memory";
+				power-domains = <&rpmhpd SC7180_CX>;
+				required-opps = <&rpmhpd_opp_low_svs>;
 				status = "disabled";
 			};
 
 			spi11: spi@a94000 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw
In reply to Rajendra Nayak

Quoting Rajendra Nayak (2021-07-16 03:00:57)

Quoted 1 line

Some devics within power domains with performance states do not

devices

Quoted 20 lines

support DVFS, but still need to vote on a default/static state while they are active. They can express this using the 'required-opps' property in device tree, which points to the phandle of the OPP supported by the corresponding power-domains.

Add support to parse this information from DT and then set the specified performance state during attach and drop it on detach. Also drop/set as part of runtime suspend/resume callbacks.

---
 drivers/base/power/domain.c | 37 ++++++++++++++++++++++++++++++++++---
 include/linux/pm_domain.h   |  1 +
 2 files changed, 35 insertions(+), 3 deletions(-)
drivers/base/power/domain.c +0 -0
index a934c67..dcc0b71 100644

drivers/base/power/domain.c static int genpd_runtime_resume(struct device *dev) · line 1014

Quoted 7 lines
drivers/base/power/domain.c +2 -0
@@ -1000,6 +1008,8 @@ static int genpd_runtime_resume(struct device *dev)
        genpd_stop_dev(genpd, dev);
 err_poweroff:
        if (!pm_runtime_is_irq_safe(dev) || genpd_is_irq_safe(genpd)) {
+               if (default_pstate)
+                       dev_pm_genpd_set_performance_state(dev, 0);
                genpd_lock(genpd);
                gpd_data->rpm_pstate = genpd_drop_performance_state(dev);

Maybe this should be

		  prev_state = genpd_drop_performance_state(dev);
		  if (!default_pstate)
		  	gdp_data->rpm_pstate = prev_state;

so we don't call dev_pm_genpd_set_performance_state() effectively twice? Also it would make sure we call dev_pm_genpd_set_performance_state() underneath the genpd_lock() if that is important. Similarly do that on suspend path.

Quoted 20 lines
drivers/base/power/domain.c +7 -1
                genpd_power_off(genpd, true, 0);
@@ -2598,6 +2608,12 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
 
        dev_dbg(dev, "removing from PM domain %s\n", pd->name);
 
+       /* Drop the default performance state */
+       if (dev_gpd_data(dev)->default_pstate) {
+               dev_pm_genpd_set_performance_state(dev, 0);
+               dev_gpd_data(dev)->default_pstate = 0;
+       }
+
        for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
                ret = genpd_remove_device(pd, dev);
                if (ret != -EAGAIN)
@@ -2675,10 +2692,24 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
                genpd_unlock(pd);
        }
 
-       if (ret)
+       if (ret) {

drivers/base/power/domain.c static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, · line 2705

Quoted 10 lines
drivers/base/power/domain.c +9 -0
                genpd_remove_device(pd, dev);
+               return -EPROBE_DEFER;
+       }
+
+       /* Set the default performance state */
+       np = base_dev->of_node;
+       if (of_parse_phandle(np, "required-opps", index)) {
+               pstate = of_get_required_opp_performance_state(np, index);
+               if (pstate < 0) {
+                       dev_err(dev, "failed to set pstate:%d", pstate);

Missing newline on printk. Also can we spell out pstate as "failed to set required performance state %d for power-domain %d"?

Quoted 11 lines
drivers/base/power/domain.c +6 -1
+                       ret = pstate;
+               }
+               dev_pm_genpd_set_performance_state(dev, pstate);
+               dev_gpd_data(dev)->default_pstate = pstate;
+       }
 
-       return ret ? -EPROBE_DEFER : 1;
+       return ret ? ret : 1;
 }
 
 /**
#7 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

In reply to Bjorn Andersson

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 8 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Quoted 9 lines

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

#8 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 16 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 15 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

Quoted 5 lines
Quoted 2 lines

..is the required-opps really needed with my rpmhpd patch in place?

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

Regards,
Bjorn

#9 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 18 lines · Stephen Boyd
Quoted 17 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 15 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

..is the required-opps really needed with my rpmhpd patch in place?

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

#10 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 28 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 18 lines · Stephen Boyd
Quoted 17 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 15 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

..is the required-opps really needed with my rpmhpd patch in place?

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

Quoted 9 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

As this means that anyone who needs any of the rpmhpd domains active also needs to specify required-opps, which wouldn't be needed for any other power domain provider.

And more importantly it means that a device sitting in a GDSC, which would be parented by a rpmhpd domain has no way to specify the GDSC and trickle the minimum-vote up to the rpmhpd domain. (And I know that we don't describe the parentship of the GDSCs today, but this patch tells me that it's around the corner - for more than MMCX)

Regards,
Bjorn

Quoted 5 lines
Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

#11 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 21 lines · Bjorn Andersson
Quoted 19 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 18 lines · Stephen Boyd
Quoted 17 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 15 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

..is the required-opps really needed with my rpmhpd patch in place?

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

Quoted 19 lines

As this means that anyone who needs any of the rpmhpd domains active also needs to specify required-opps, which wouldn't be needed for any other power domain provider.

And more importantly it means that a device sitting in a GDSC, which would be parented by a rpmhpd domain has no way to specify the GDSC and trickle the minimum-vote up to the rpmhpd domain. (And I know that we don't describe the parentship of the GDSCs today, but this patch tells me that it's around the corner - for more than MMCX)

Regards,
Bjorn

Quoted 5 lines
Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw
In reply to Stephen Boyd
Quoted 35 lines · Stephen Boyd

Quoting Rajendra Nayak (2021-07-16 03:00:57)

Quoted 1 line

Some devics within power domains with performance states do not

devices

Quoted 20 lines

support DVFS, but still need to vote on a default/static state while they are active. They can express this using the 'required-opps' property in device tree, which points to the phandle of the OPP supported by the corresponding power-domains.

Add support to parse this information from DT and then set the specified performance state during attach and drop it on detach. Also drop/set as part of runtime suspend/resume callbacks.

---
  drivers/base/power/domain.c | 37 ++++++++++++++++++++++++++++++++++---
  include/linux/pm_domain.h   |  1 +
  2 files changed, 35 insertions(+), 3 deletions(-)
drivers/base/power/domain.c +0 -0
index a934c67..dcc0b71 100644

drivers/base/power/domain.c static int genpd_runtime_resume(struct device *dev) · line 1014

Quoted 7 lines
drivers/base/power/domain.c +2 -0
@@ -1000,6 +1008,8 @@ static int genpd_runtime_resume(struct device *dev)
         genpd_stop_dev(genpd, dev);
  err_poweroff:
         if (!pm_runtime_is_irq_safe(dev) || genpd_is_irq_safe(genpd)) {
+               if (default_pstate)
+                       dev_pm_genpd_set_performance_state(dev, 0);
                 genpd_lock(genpd);
                 gpd_data->rpm_pstate = genpd_drop_performance_state(dev);

Maybe this should be

Quoted 8 lines
		  prev_state = genpd_drop_performance_state(dev);
		  if (!default_pstate)
		  	gdp_data->rpm_pstate = prev_state;

so we don't call dev_pm_genpd_set_performance_state() effectively twice? Also it would make sure we call dev_pm_genpd_set_performance_state() underneath the genpd_lock() if that is important. Similarly do that on suspend path.

looking through this more, I think I can completely drop any special handling for default_pstate in runtime suspend and resume. The existing drop/restore login Ulf has added should take care of it. I'll test and respin soon.

Quoted 19 lines
Quoted 19 lines
drivers/base/power/domain.c +6 -0
                 genpd_power_off(genpd, true, 0);
@@ -2598,6 +2608,12 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
 
         dev_dbg(dev, "removing from PM domain %s\n", pd->name);
 
+       /* Drop the default performance state */
+       if (dev_gpd_data(dev)->default_pstate) {
+               dev_pm_genpd_set_performance_state(dev, 0);
+               dev_gpd_data(dev)->default_pstate = 0;
+       }
+
         for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
                 ret = genpd_remove_device(pd, dev);
                 if (ret != -EAGAIN)
@@ -2675,10 +2692,24 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
                 genpd_unlock(pd);
         }
 
Quoted 15 lines

drivers/base/power/domain.c static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, · line 2705

Quoted 12 lines
drivers/base/power/domain.c +10 -1
-       if (ret)
+       if (ret) {
                 genpd_remove_device(pd, dev);
+               return -EPROBE_DEFER;
+       }
+
+       /* Set the default performance state */
+       np = base_dev->of_node;
+       if (of_parse_phandle(np, "required-opps", index)) {
+               pstate = of_get_required_opp_performance_state(np, index);
+               if (pstate < 0) {
+                       dev_err(dev, "failed to set pstate:%d", pstate);

Missing newline on printk. Also can we spell out pstate as "failed to set required performance state %d for power-domain %d"?

thanks, will fix when I respin.
Thanks for the review.

Quoted 12 lines
Quoted 12 lines
drivers/base/power/domain.c +6 -1
+                       ret = pstate;
+               }
+               dev_pm_genpd_set_performance_state(dev, pstate);
+               dev_gpd_data(dev)->default_pstate = pstate;
+       }
 
-       return ret ? -EPROBE_DEFER : 1;
+       return ret ? ret : 1;
  }
 
  /**
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#12 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

In reply to Rajendra Nayak
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

Quoted 8 lines

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

So perhaps instead of introducing the enabled_corner we need to introduce your patch and slap a WARN_ON(corner == 0) in rpmhpd_power_on() - to ensure that all clients that uses a rpmhpd domain actually do vote for a high enough corner?

Regards,
Bjorn

Quoted 23 lines
Quoted 19 lines

As this means that anyone who needs any of the rpmhpd domains active also needs to specify required-opps, which wouldn't be needed for any other power domain provider.

And more importantly it means that a device sitting in a GDSC, which would be parented by a rpmhpd domain has no way to specify the GDSC and trickle the minimum-vote up to the rpmhpd domain. (And I know that we don't describe the parentship of the GDSCs today, but this patch tells me that it's around the corner - for more than MMCX)

Regards,
Bjorn

Quoted 5 lines
Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#13 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 69 lines · Bjorn Andersson
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

Quoted 8 lines

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

Quoted 3 lines

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

Right, it might work in some cases but might not work for all.

Quoted 5 lines

So perhaps instead of introducing the enabled_corner we need to introduce your patch and slap a WARN_ON(corner == 0) in rpmhpd_power_on() - to ensure that all clients that uses a rpmhpd domain actually do vote for a high enough corner?

So this would mean the expectation is that the clients set the perf state/corner before they call power_on? I don;t think that's the case today with most clients, infact its the opposite, we power on first and then make a call to set the perf state of the domain.

Quoted 27 lines

Regards,
Bjorn

Quoted 23 lines
Quoted 19 lines

As this means that anyone who needs any of the rpmhpd domains active also needs to specify required-opps, which wouldn't be needed for any other power domain provider.

And more importantly it means that a device sitting in a GDSC, which would be parented by a rpmhpd domain has no way to specify the GDSC and trickle the minimum-vote up to the rpmhpd domain. (And I know that we don't describe the parentship of the GDSCs today, but this patch tells me that it's around the corner - for more than MMCX)

Regards,
Bjorn

Quoted 5 lines
Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#14 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 72 lines · Rajendra Nayak
Quoted 69 lines · Bjorn Andersson
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 26 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

Quoted 6 lines
Quoted 3 lines

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

Right, it might work in some cases but might not work for all.

Which makes it way less desirable.

The enable state for rpmhpd power domains doesn't meet my expectations for how a power domain should behave, but we should at least be consistent across all consumers of it then...

But the original issue remains, that when a device is powered by MDSS_GDSC, which is a subdomain of MMCX we still need to ensure that "on" for MMCX is actually "on" - which just happens to be the first non-0 corner.

But I presume we will end up having to do the same with &gcc's GDSCs, which are subdomains of CX and MX where this isn't true.

Quoted 11 lines
Quoted 5 lines

So perhaps instead of introducing the enabled_corner we need to introduce your patch and slap a WARN_ON(corner == 0) in rpmhpd_power_on() - to ensure that all clients that uses a rpmhpd domain actually do vote for a high enough corner?

So this would mean the expectation is that the clients set the perf state/corner before they call power_on? I don;t think that's the case today with most clients, infact its the opposite, we power on first and then make a call to set the perf state of the domain.

You're right, it's pretty much always the opposite, given that genpd will always enable the domain during attach.

Regards,
Bjorn

Quoted 31 lines
Quoted 27 lines

Regards,
Bjorn

Quoted 23 lines
Quoted 19 lines

As this means that anyone who needs any of the rpmhpd domains active also needs to specify required-opps, which wouldn't be needed for any other power domain provider.

And more importantly it means that a device sitting in a GDSC, which would be parented by a rpmhpd domain has no way to specify the GDSC and trickle the minimum-vote up to the rpmhpd domain. (And I know that we don't describe the parentship of the GDSCs today, but this patch tells me that it's around the corner - for more than MMCX)

Regards,
Bjorn

Quoted 5 lines
Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#15 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 78 lines · Bjorn Andersson
Quoted 76 lines · Rajendra Nayak
Quoted 72 lines · Bjorn Andersson
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

Quoted 8 lines

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

Quoted 7 lines
Quoted 2 lines

Right, it might work in some cases but might not work for all.

Which makes it way less desirable.

The enable state for rpmhpd power domains doesn't meet my expectations for how a power domain should behave,

Right and that's perhaps because these are not the usual power-domains, which have one "on/active" state and one or more "off/inactive" states (off/ret/clock-stop) Rpmhpd has multiple "on/active" states, and whats "on/active" for one consumer might not be "on/active" for another, so this information is hard to be managed at a generic level and these requests in some way or the other need to come in explicitly from the resp. consumers.

Quoted 61 lines

but we should at least be
consistent across all consumers of it then...

But the original issue remains, that when a device is powered by MDSS_GDSC, which is a subdomain of MMCX we still need to ensure that "on" for MMCX is actually "on" - which just happens to be the first non-0 corner.

But I presume we will end up having to do the same with &gcc's GDSCs, which are subdomains of CX and MX where this isn't true.

Quoted 11 lines
Quoted 5 lines

So perhaps instead of introducing the enabled_corner we need to introduce your patch and slap a WARN_ON(corner == 0) in rpmhpd_power_on() - to ensure that all clients that uses a rpmhpd domain actually do vote for a high enough corner?

So this would mean the expectation is that the clients set the perf state/corner before they call power_on? I don;t think that's the case today with most clients, infact its the opposite, we power on first and then make a call to set the perf state of the domain.

You're right, it's pretty much always the opposite, given that genpd will always enable the domain during attach.

Regards,
Bjorn

Quoted 31 lines
Quoted 27 lines

Regards,
Bjorn

Quoted 23 lines
Quoted 19 lines

As this means that anyone who needs any of the rpmhpd domains active also needs to specify required-opps, which wouldn't be needed for any other power domain provider.

And more importantly it means that a device sitting in a GDSC, which would be parented by a rpmhpd domain has no way to specify the GDSC and trickle the minimum-vote up to the rpmhpd domain. (And I know that we don't describe the parentship of the GDSCs today, but this patch tells me that it's around the corner - for more than MMCX)

Regards,
Bjorn

Quoted 5 lines
Quoted 5 lines

And if this (which?) clock requires a higher corner than the lowest possible in order to tick at this "lowest" frequency, I'm certainly interested in some more details.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#16 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 88 lines · Rajendra Nayak
Quoted 78 lines · Bjorn Andersson
Quoted 76 lines · Rajendra Nayak
Quoted 72 lines · Bjorn Andersson
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

Quoted 8 lines

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

Quoted 7 lines
Quoted 2 lines

Right, it might work in some cases but might not work for all.

Which makes it way less desirable.

The enable state for rpmhpd power domains doesn't meet my expectations for how a power domain should behave,

Quoted 7 lines

Right and that's perhaps because these are not the usual power-domains, which have one "on/active" state and one or more "off/inactive" states (off/ret/clock-stop) Rpmhpd has multiple "on/active" states, and whats "on/active" for one consumer might not be "on/active" for another, so this information is hard to be managed at a generic level and these requests in some way or the other need to come in explicitly from the resp. consumers.

I think it's fine if we just acknowledge that this is how the rpmhpd domains works.

But I am worried about how we're going to handle the case where the consumer is indirectly referencing one of these power-domains using a subdomain (gdsc).

And the open question is if a solution to that problem will solve this problem as well, or if we need to have this and some mechanism to describe the "on state" for the parent of a subdomain.

Regards,
Bjorn

#17 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 98 lines · Bjorn Andersson
Quoted 88 lines · Rajendra Nayak
Quoted 78 lines · Bjorn Andersson
Quoted 76 lines · Rajendra Nayak
Quoted 72 lines · Bjorn Andersson
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz) Though qup-i2c does not support DVFS, it still needs to vote for a performance state on 'CX' to satisfy the 19.2 Mhz clock frequency requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from device tree, and also add the power-domains property to specify the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

Quoted 8 lines

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

Quoted 7 lines
Quoted 2 lines

Right, it might work in some cases but might not work for all.

Which makes it way less desirable.

The enable state for rpmhpd power domains doesn't meet my expectations for how a power domain should behave,

Quoted 7 lines

Right and that's perhaps because these are not the usual power-domains, which have one "on/active" state and one or more "off/inactive" states (off/ret/clock-stop) Rpmhpd has multiple "on/active" states, and whats "on/active" for one consumer might not be "on/active" for another, so this information is hard to be managed at a generic level and these requests in some way or the other need to come in explicitly from the resp. consumers.

Quoted 6 lines

I think it's fine if we just acknowledge that this is how the rpmhpd domains works.

But I am worried about how we're going to handle the case where the consumer is indirectly referencing one of these power-domains using a subdomain (gdsc).

With the proper subdomain relationship in place and with Ulf's patches, this seems to be handled correctly. gdsc sets proper level for the parent power domain, which gets voted and unvoted by the core pm code when gdsc's power domain is powered on or off.

Quoted 3 lines

And the open question is if a solution to that problem will solve this problem as well, or if we need to have this and some mechanism to describe the "on state" for the parent of a subdomain.

Signature · 2 lines
With best wishes
Dmitry
#18 lore raw

Re: [PATCH v4 2/2] arm64: dts: sc7180: Add required-opps for i2c

Quoted 102 lines · Dmitry Baryshkov
Quoted 101 lines · Bjorn Andersson
Quoted 88 lines · Rajendra Nayak
Quoted 78 lines · Bjorn Andersson
Quoted 76 lines · Rajendra Nayak
Quoted 72 lines · Bjorn Andersson
Quoted 27 lines · Rajendra Nayak
Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd

Quoting Bjorn Andersson (2021-07-16 13:52:12)

Quoted 21 lines · Stephen Boyd
Quoted 20 lines

Quoting Bjorn Andersson (2021-07-16 13:18:56)

Quoted 17 lines · Rajendra Nayak
Quoted 6 lines

qup-i2c devices on sc7180 are clocked with a fixed clock (19.2 MHz)
Though qup-i2c does not support DVFS, it still needs to vote for a
performance state on 'CX' to satisfy the 19.2 Mhz clock frequency
requirement.

Sounds good, but...

Quoted 4 lines

Use 'required-opps' to pass this information from
device tree, and also add the power-domains property to specify
the CX power-domain.

..is the required-opps really needed with my rpmhpd patch in place?

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Yes? Because rpmhpd_opp_low_svs is not the lowest performance state for CX.

On e.g. sm8250 the first available non-zero corner presented in cmd-db is low_svs.

what rail is this? the mmcx? Perhaps it does not support RET. cx usually supports both collapse state and RET.

That was the one I was specifically looking at for the MDSS_GDSC->MMCX issue, so it's likely I didn't look elsewhere.

Quoted 18 lines
Quoted 11 lines
Quoted 10 lines

Indeed. On sc7180 it's not the first non-zero corner. I suppose retention for CX isn't actually used when the SoC is awake so your rpmhpd patch is putting in a vote for something that doesn't do anything at runtime for CX? I imagine that rpmh only sets the aggregate corner to retention when the whole SoC is suspended/sleeping, otherwise things wouldn't go very well. Similarly, min_svs may be VDD minimization? If so, those first two states are basically states that shouldn't be used at runtime, almost like sleep states.

Quoted 2 lines

But if that's the case, I don't think it's appropriate for the "enabled state" of the domain to use any of those corners.

I rechecked the downstream kernels where all this voting happens from within the clock drivers, and I do see votes to min_svs for some clocks, but Stephen is right that RET is not something that's voted on while in active state.

Quoted 8 lines

But always going with something just above the ret level while active will also not work for all devices, for instance for i2c on 7180, it needs a cx vote of low svs while the rail (cx) does support something lower than that which is min svs. (why can't it just work with min svs?, I don't know, these values and recommendations come in from the voltage plans published by HW teams for every SoC and we just end up using them in SW, perhaps something to dig further and understand which I will try and do but these are the values in voltage plans and downstream kernels which work for now)

So to some degree this invalidates my argumentation about the enabled_corner in rpmhpd, given that "enabled" means a different corner for each rail - not just the one with lowest non-zero value.

Quoted 7 lines
Quoted 2 lines

Right, it might work in some cases but might not work for all.

Which makes it way less desirable.

The enable state for rpmhpd power domains doesn't meet my expectations for how a power domain should behave,

Quoted 7 lines

Right and that's perhaps because these are not the usual power-domains, which have one "on/active" state and one or more "off/inactive" states (off/ret/clock-stop) Rpmhpd has multiple "on/active" states, and whats "on/active" for one consumer might not be "on/active" for another, so this information is hard to be managed at a generic level and these requests in some way or the other need to come in explicitly from the resp. consumers.

I think it's fine if we just acknowledge that this is how the rpmhpd domains works.

Quoted 9 lines
Quoted 3 lines

But I am worried about how we're going to handle the case where the consumer is indirectly referencing one of these power-domains using a subdomain (gdsc).

With the proper subdomain relationship in place and with Ulf's patches, this seems to be handled correctly. gdsc sets proper level for the parent power domain, which gets voted and unvoted by the core pm code when gdsc's power domain is powered on or off.

Right, but this works only in our case because "on" for MMCX happens to be the first non-zero corner.

What this patch points out is that for some of the other power domains my patch in the rpmhpd driver isn't sufficient - and presumably wouldn't work for other gdsc's (that are parented by CX or MX).

Regards,
Bjorn

Quoted 8 lines
Quoted 3 lines

And the open question is if a solution to that problem will solve this problem as well, or if we need to have this and some mechanism to describe the "on state" for the parent of a subdomain.

Signature · 2 lines
With best wishes
Dmitry