linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms
@ 2023-08-08 11:43 Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 01/10] interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients Konrad Dybcio
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

Certain platforms require that some buses (or individual nodes) make
some additional changes to the clock rate formula, throwing in some
magic, Qualcomm-defined coefficients, to account for "inefficiencies".

Add the framework for it and utilize it on a couple SoCs.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
Changes in v3:
- Allocate the node bus clock on the stack, as dynamically allocating
  it actually wastes memory on systems with 64-bit pointers..
- Add the node bus clock struct member in the correct patch
- Simplify using coefficients by only checking the node-level ones, and
  setting them equal to the bus-specific ones at probe if absent
- Fix building on arm32
- Mention some references to the related downstream code
- Link to v2: https://lore.kernel.org/r/20230726-topic-icc_coeff-v2-0-8c91c6c76076@linaro.org

Changes in v2:
- Use the (arguably less favourable but necessary for precission) 100/x
  instead of x/100 for ib coefficient, update values in consequent
  patches to reflect that
- Rename "_percent" to "_coeff" because of /\
- Add the necessary code to support per-node clocks
- Add the necessary code to support per-node coefficients
- Hook up the CPUSS<->GNoC clock on QCM2290
- Update EBI node on QCM2290
- Link to v1: https://lore.kernel.org/r/20230726-topic-icc_coeff-v1-0-31616960818c@linaro.org

---
Konrad Dybcio (10):
      interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients
      interconnect: qcom: icc-rpm: Separate out clock rate calulcations
      interconnect: qcom: icc-rpm: Let nodes drive their own bus clock
      interconnect: qcom: icc-rpm: Check for node-specific rate coefficients
      interconnect: qcom: qcm2290: Hook up MAS_APPS_PROC's bus clock
      interconnect: qcom: qcm2290: Set AB coefficients
      interconnect: qcom: qcm2290: Update EBI channel configuration
      interconnect: qcom: sdm660: Set AB/IB coefficients
      interconnect: qcom: msm8996: Set AB/IB coefficients
      clk: qcom: smd-rpm: Move CPUSS_GNoC clock to interconnect

 drivers/clk/qcom/clk-smd-rpm.c             | 16 +++++--
 drivers/interconnect/qcom/icc-rpm-clocks.c |  6 +++
 drivers/interconnect/qcom/icc-rpm.c        | 76 +++++++++++++++++++++++++-----
 drivers/interconnect/qcom/icc-rpm.h        | 15 ++++++
 drivers/interconnect/qcom/msm8996.c        |  8 +++-
 drivers/interconnect/qcom/qcm2290.c        |  9 +++-
 drivers/interconnect/qcom/sdm660.c         |  4 ++
 7 files changed, 115 insertions(+), 19 deletions(-)
---
base-commit: 71cd4fc492ec41e4acd85e98bbf7a13753fc1e03
change-id: 20230726-topic-icc_coeff-b053d5409b9f

Best regards,
-- 
Konrad Dybcio <konrad.dybcio@linaro.org>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 01/10] interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 02/10] interconnect: qcom: icc-rpm: Separate out clock rate calulcations Konrad Dybcio
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

Presumably due to the hardware being so complex, some nodes (or busses)
have different (usually higher) requirements for bandwidth than what
the usual calculations would suggest.

Looking at the available downstream files, it seems like AB values are
adjusted per-bus and IB values are adjusted per-node.
With that in mind, introduce percentage-based coefficient struct members
and use them in the calculations.

One thing to note is that the IB coefficient is inverse (100/ib_percent)
which feels a bit backwards, but it's necessary for precision..

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/icc-rpm.c | 18 +++++++++++++++---
 drivers/interconnect/qcom/icc-rpm.h |  6 ++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index 2c16917ba1fd..8b02aa8aa96a 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -298,7 +298,8 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
  */
 static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_rate)
 {
-	u64 agg_avg_rate, agg_rate;
+	struct qcom_icc_provider *qp = to_qcom_provider(provider);
+	u64 agg_avg_rate, agg_peak_rate, agg_rate;
 	struct qcom_icc_node *qn;
 	struct icc_node *node;
 	int i;
@@ -315,8 +316,19 @@ static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_r
 			else
 				agg_avg_rate = qn->sum_avg[i];
 
-			agg_rate = max_t(u64, agg_avg_rate, qn->max_peak[i]);
-			do_div(agg_rate, qn->buswidth);
+			if (qp->ab_coeff) {
+				agg_avg_rate = agg_avg_rate * qp->ab_coeff;
+				agg_avg_rate = div_u64(agg_avg_rate, 100);
+			}
+
+			if (qp->ib_coeff) {
+				agg_peak_rate = qn->max_peak[i] * 100;
+				agg_peak_rate = div_u64(qn->max_peak[i], qp->ib_coeff);
+			} else {
+				agg_peak_rate = qn->max_peak[i];
+			}
+
+			agg_rate = max_t(u64, agg_avg_rate, agg_peak_rate);
 
 			agg_clk_rate[i] = max_t(u64, agg_clk_rate[i], agg_rate);
 		}
diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h
index eed3451af3e6..5e7d6a4fd2f3 100644
--- a/drivers/interconnect/qcom/icc-rpm.h
+++ b/drivers/interconnect/qcom/icc-rpm.h
@@ -44,6 +44,8 @@ struct rpm_clk_resource {
  * @type: the ICC provider type
  * @regmap: regmap for QoS registers read/write access
  * @qos_offset: offset to QoS registers
+ * @ab_coeff: a percentage-based coefficient for compensating the AB calculations
+ * @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
  * @bus_clk_rate: bus clock rate in Hz
  * @bus_clk_desc: a pointer to a rpm_clk_resource description of bus clocks
  * @bus_clk: a pointer to a HLOS-owned bus clock
@@ -57,6 +59,8 @@ struct qcom_icc_provider {
 	enum qcom_icc_type type;
 	struct regmap *regmap;
 	unsigned int qos_offset;
+	u16 ab_coeff;
+	u16 ib_coeff;
 	u32 bus_clk_rate[QCOM_SMD_RPM_STATE_NUM];
 	const struct rpm_clk_resource *bus_clk_desc;
 	struct clk *bus_clk;
@@ -123,6 +127,8 @@ struct qcom_icc_desc {
 	enum qcom_icc_type type;
 	const struct regmap_config *regmap_cfg;
 	unsigned int qos_offset;
+	u16 ab_coeff;
+	u16 ib_coeff;
 };
 
 /* Valid for all bus types */

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 02/10] interconnect: qcom: icc-rpm: Separate out clock rate calulcations
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 01/10] interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 03/10] interconnect: qcom: icc-rpm: Let nodes drive their own bus clock Konrad Dybcio
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

In preparation for also setting per-node clock rates, separate out the
logic that computes it.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/icc-rpm.c | 53 +++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index 8b02aa8aa96a..8c1bfd65d774 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -291,6 +291,32 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
 	return 0;
 }
 
+static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node *qn, int ctx)
+{
+	u64 agg_avg_rate, agg_peak_rate, agg_rate;
+
+	if (qn->channels)
+		agg_avg_rate = div_u64(qn->sum_avg[ctx], qn->channels);
+	else
+		agg_avg_rate = qn->sum_avg[ctx];
+
+	if (qp->ab_coeff) {
+		agg_avg_rate = agg_avg_rate * qp->ab_coeff;
+		agg_avg_rate = div_u64(agg_avg_rate, 100);
+	}
+
+	if (qp->ib_coeff) {
+		agg_peak_rate = qn->max_peak[ctx] * 100;
+		agg_peak_rate = div_u64(qn->max_peak[ctx], qp->ib_coeff);
+	} else {
+		agg_peak_rate = qn->max_peak[ctx];
+	}
+
+	agg_rate = max_t(u64, agg_avg_rate, agg_peak_rate);
+
+	return div_u64(agg_rate, qn->buswidth);
+}
+
 /**
  * qcom_icc_bus_aggregate - calculate bus clock rates by traversing all nodes
  * @provider: generic interconnect provider
@@ -299,10 +325,9 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
 static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_rate)
 {
 	struct qcom_icc_provider *qp = to_qcom_provider(provider);
-	u64 agg_avg_rate, agg_peak_rate, agg_rate;
 	struct qcom_icc_node *qn;
 	struct icc_node *node;
-	int i;
+	int ctx;
 
 	/*
 	 * Iterate nodes on the provider, aggregate bandwidth requests for
@@ -310,27 +335,9 @@ static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_r
 	 */
 	list_for_each_entry(node, &provider->nodes, node_list) {
 		qn = node->data;
-		for (i = 0; i < QCOM_SMD_RPM_STATE_NUM; i++) {
-			if (qn->channels)
-				agg_avg_rate = div_u64(qn->sum_avg[i], qn->channels);
-			else
-				agg_avg_rate = qn->sum_avg[i];
-
-			if (qp->ab_coeff) {
-				agg_avg_rate = agg_avg_rate * qp->ab_coeff;
-				agg_avg_rate = div_u64(agg_avg_rate, 100);
-			}
-
-			if (qp->ib_coeff) {
-				agg_peak_rate = qn->max_peak[i] * 100;
-				agg_peak_rate = div_u64(qn->max_peak[i], qp->ib_coeff);
-			} else {
-				agg_peak_rate = qn->max_peak[i];
-			}
-
-			agg_rate = max_t(u64, agg_avg_rate, agg_peak_rate);
-
-			agg_clk_rate[i] = max_t(u64, agg_clk_rate[i], agg_rate);
+		for (ctx = 0; ctx < QCOM_SMD_RPM_STATE_NUM; ctx++) {
+			agg_clk_rate[ctx] = max_t(u64, agg_clk_rate[ctx],
+						  qcom_icc_calc_rate(qp, qn, ctx));
 		}
 	}
 }

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 03/10] interconnect: qcom: icc-rpm: Let nodes drive their own bus clock
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 01/10] interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 02/10] interconnect: qcom: icc-rpm: Separate out clock rate calulcations Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients Konrad Dybcio
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

If this hardware couldn't get messier, some nodes are supposed to drive
their own bus clock.. Presumably to connect to some intermediate
interface between the node itself and the bus it's (supposed to be)
connected to.

Expand the node struct with the necessary data and hook up the
allocations & calculations.

Note that the node-specific AB/IB coefficients contribute (by design)
to both the node-level and the bus-level aggregation.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/icc-rpm.c | 27 +++++++++++++++++++++++++++
 drivers/interconnect/qcom/icc-rpm.h |  3 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index 8c1bfd65d774..1d3af4e9ead8 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -414,6 +414,33 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
 		qp->bus_clk_rate[QCOM_SMD_RPM_SLEEP_STATE] = sleep_rate;
 	}
 
+	/* Handle the node-specific clock */
+	if (!src_qn->bus_clk_desc)
+		return 0;
+
+	active_rate = qcom_icc_calc_rate(qp, src_qn, QCOM_SMD_RPM_ACTIVE_STATE);
+	sleep_rate = qcom_icc_calc_rate(qp, src_qn, QCOM_SMD_RPM_SLEEP_STATE);
+
+	if (active_rate != src_qn->bus_clk_rate[QCOM_SMD_RPM_ACTIVE_STATE]) {
+		ret = qcom_icc_rpm_set_bus_rate(src_qn->bus_clk_desc, QCOM_SMD_RPM_ACTIVE_STATE,
+						active_rate);
+		if (ret)
+			return ret;
+
+		/* Cache the rate after we've successfully committed it to RPM */
+		src_qn->bus_clk_rate[QCOM_SMD_RPM_ACTIVE_STATE] = active_rate;
+	}
+
+	if (sleep_rate != src_qn->bus_clk_rate[QCOM_SMD_RPM_SLEEP_STATE]) {
+		ret = qcom_icc_rpm_set_bus_rate(src_qn->bus_clk_desc, QCOM_SMD_RPM_SLEEP_STATE,
+						sleep_rate);
+		if (ret)
+			return ret;
+
+		/* Cache the rate after we've successfully committed it to RPM */
+		src_qn->bus_clk_rate[QCOM_SMD_RPM_SLEEP_STATE] = sleep_rate;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h
index 5e7d6a4fd2f3..f9ef16f570be 100644
--- a/drivers/interconnect/qcom/icc-rpm.h
+++ b/drivers/interconnect/qcom/icc-rpm.h
@@ -97,6 +97,7 @@ struct qcom_icc_qos {
  * @num_links: the total number of @links
  * @channels: number of channels at this node (e.g. DDR channels)
  * @buswidth: width of the interconnect between a node and the bus (bytes)
+ * @bus_clk_desc: a pointer to a rpm_clk_resource description of bus clocks
  * @sum_avg: current sum aggregate value of all avg bw requests
  * @max_peak: current max aggregate value of all peak bw requests
  * @mas_rpm_id:	RPM id for devices that are bus masters
@@ -110,11 +111,13 @@ struct qcom_icc_node {
 	u16 num_links;
 	u16 channels;
 	u16 buswidth;
+	const struct rpm_clk_resource *bus_clk_desc;
 	u64 sum_avg[QCOM_SMD_RPM_STATE_NUM];
 	u64 max_peak[QCOM_SMD_RPM_STATE_NUM];
 	int mas_rpm_id;
 	int slv_rpm_id;
 	struct qcom_icc_qos qos;
+	u32 bus_clk_rate[QCOM_SMD_RPM_STATE_NUM];
 };
 
 struct qcom_icc_desc {

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (2 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 03/10] interconnect: qcom: icc-rpm: Let nodes drive their own bus clock Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-10  7:26   ` Stephan Gerhold
  2023-08-08 11:43 ` [PATCH v3 05/10] interconnect: qcom: qcm2290: Hook up MAS_APPS_PROC's bus clock Konrad Dybcio
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

Some nodes may have different coefficients than the general values for
bus they're attached to. Check for that and use them if present. See
[1], [2] for reference.

[1] https://github.com/sonyxperiadev/kernel/commit/7456d9779af9ad6bb9c7ee6f33d5c5a8d3648e24
[2] https://github.com/artem/android_kernel_sony_msm8996/commit/bf7a8985dcaf0eab5bc2562d2d6775e7e29c0f30
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/icc-rpm.c | 14 ++++++++++----
 drivers/interconnect/qcom/icc-rpm.h |  5 +++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index 1d3af4e9ead8..9c40314e03b5 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -300,14 +300,14 @@ static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node
 	else
 		agg_avg_rate = qn->sum_avg[ctx];
 
-	if (qp->ab_coeff) {
-		agg_avg_rate = agg_avg_rate * qp->ab_coeff;
+	if (qn->ab_coeff) {
+		agg_avg_rate = agg_avg_rate * qn->ab_coeff;
 		agg_avg_rate = div_u64(agg_avg_rate, 100);
 	}
 
-	if (qp->ib_coeff) {
+	if (qn->ib_coeff) {
 		agg_peak_rate = qn->max_peak[ctx] * 100;
-		agg_peak_rate = div_u64(qn->max_peak[ctx], qp->ib_coeff);
+		agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff);
 	} else {
 		agg_peak_rate = qn->max_peak[ctx];
 	}
@@ -563,6 +563,12 @@ int qnoc_probe(struct platform_device *pdev)
 	for (i = 0; i < num_nodes; i++) {
 		size_t j;
 
+		if (!qnodes[i]->ab_coeff)
+			qnodes[i]->ab_coeff = qp->ab_coeff;
+
+		if (!qnodes[i]->ib_coeff)
+			qnodes[i]->ib_coeff = qp->ib_coeff;
+
 		node = icc_node_create(qnodes[i]->id);
 		if (IS_ERR(node)) {
 			ret = PTR_ERR(node);
diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h
index f9ef16f570be..4abf99ce2690 100644
--- a/drivers/interconnect/qcom/icc-rpm.h
+++ b/drivers/interconnect/qcom/icc-rpm.h
@@ -103,6 +103,9 @@ struct qcom_icc_qos {
  * @mas_rpm_id:	RPM id for devices that are bus masters
  * @slv_rpm_id:	RPM id for devices that are bus slaves
  * @qos: NoC QoS setting parameters
+ * @ab_coeff: a percentage-based coefficient for compensating the AB calculations
+ * @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
+ * @bus_clk_rate: a pointer to an array containing bus clock rates in Hz
  */
 struct qcom_icc_node {
 	unsigned char *name;
@@ -117,6 +120,8 @@ struct qcom_icc_node {
 	int mas_rpm_id;
 	int slv_rpm_id;
 	struct qcom_icc_qos qos;
+	u16 ab_coeff;
+	u16 ib_coeff;
 	u32 bus_clk_rate[QCOM_SMD_RPM_STATE_NUM];
 };
 

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 05/10] interconnect: qcom: qcm2290: Hook up MAS_APPS_PROC's bus clock
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (3 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 06/10] interconnect: qcom: qcm2290: Set AB coefficients Konrad Dybcio
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

This single node has its own clock which seems to be responsible for
transactions between CPUSS (CPU + some stuff) and the GNOC. See [1]
for reference.

Define it and hook it up.

[1] https://android.googlesource.com/kernel/msm-extra/devicetree/+/02f8c342b23c20a5cf967df649814be37a08227c%5E%21/#F0
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/icc-rpm-clocks.c | 6 ++++++
 drivers/interconnect/qcom/icc-rpm.h        | 1 +
 drivers/interconnect/qcom/qcm2290.c        | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/drivers/interconnect/qcom/icc-rpm-clocks.c b/drivers/interconnect/qcom/icc-rpm-clocks.c
index 63c82a91bbc7..ac1677de7dfd 100644
--- a/drivers/interconnect/qcom/icc-rpm-clocks.c
+++ b/drivers/interconnect/qcom/icc-rpm-clocks.c
@@ -25,6 +25,12 @@ const struct rpm_clk_resource bimc_clk = {
 };
 EXPORT_SYMBOL_GPL(bimc_clk);
 
+const struct rpm_clk_resource mem_1_clk = {
+	.resource_type = QCOM_SMD_RPM_MEM_CLK,
+	.clock_id = 1,
+};
+EXPORT_SYMBOL_GPL(mem_1_clk);
+
 const struct rpm_clk_resource bus_0_clk = {
 	.resource_type = QCOM_SMD_RPM_BUS_CLK,
 	.clock_id = 0,
diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h
index 4abf99ce2690..a13768cfd231 100644
--- a/drivers/interconnect/qcom/icc-rpm.h
+++ b/drivers/interconnect/qcom/icc-rpm.h
@@ -152,6 +152,7 @@ extern const struct rpm_clk_resource bimc_clk;
 extern const struct rpm_clk_resource bus_0_clk;
 extern const struct rpm_clk_resource bus_1_clk;
 extern const struct rpm_clk_resource bus_2_clk;
+extern const struct rpm_clk_resource mem_1_clk;
 extern const struct rpm_clk_resource mmaxi_0_clk;
 extern const struct rpm_clk_resource mmaxi_1_clk;
 extern const struct rpm_clk_resource qup_clk;
diff --git a/drivers/interconnect/qcom/qcm2290.c b/drivers/interconnect/qcom/qcm2290.c
index 3c3b24264a5b..52a6eb32e832 100644
--- a/drivers/interconnect/qcom/qcm2290.c
+++ b/drivers/interconnect/qcom/qcm2290.c
@@ -112,6 +112,9 @@ static struct qcom_icc_node mas_appss_proc = {
 	.qos.qos_mode = NOC_QOS_MODE_FIXED,
 	.qos.prio_level = 0,
 	.qos.areq_prio = 0,
+	.bus_clk_desc = &mem_1_clk,
+	.ab_coeff = 159,
+	.ib_coeff = 96,
 	.mas_rpm_id = 0,
 	.slv_rpm_id = -1,
 	.num_links = ARRAY_SIZE(mas_appss_proc_links),

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 06/10] interconnect: qcom: qcm2290: Set AB coefficients
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (4 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 05/10] interconnect: qcom: qcm2290: Hook up MAS_APPS_PROC's bus clock Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 07/10] interconnect: qcom: qcm2290: Update EBI channel configuration Konrad Dybcio
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

Some buses need additional manual adjustments atop the usual
calculations. Fill in the missing coefficients.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/qcm2290.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/interconnect/qcom/qcm2290.c b/drivers/interconnect/qcom/qcm2290.c
index 52a6eb32e832..42fa01c66e73 100644
--- a/drivers/interconnect/qcom/qcm2290.c
+++ b/drivers/interconnect/qcom/qcm2290.c
@@ -1201,6 +1201,7 @@ static const struct qcom_icc_desc qcm2290_bimc = {
 	.regmap_cfg = &qcm2290_bimc_regmap_config,
 	/* M_REG_BASE() in vendor msm_bus_bimc_adhoc driver */
 	.qos_offset = 0x8000,
+	.ab_coeff = 153,
 };
 
 static struct qcom_icc_node * const qcm2290_cnoc_nodes[] = {
@@ -1327,6 +1328,7 @@ static const struct qcom_icc_desc qcm2290_mmnrt_virt = {
 	.bus_clk_desc = &mmaxi_0_clk,
 	.regmap_cfg = &qcm2290_snoc_regmap_config,
 	.qos_offset = 0x15000,
+	.ab_coeff = 142,
 };
 
 static struct qcom_icc_node * const qcm2290_mmrt_virt_nodes[] = {
@@ -1342,6 +1344,7 @@ static const struct qcom_icc_desc qcm2290_mmrt_virt = {
 	.bus_clk_desc = &mmaxi_1_clk,
 	.regmap_cfg = &qcm2290_snoc_regmap_config,
 	.qos_offset = 0x15000,
+	.ab_coeff = 139,
 };
 
 static const struct of_device_id qcm2290_noc_of_match[] = {

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 07/10] interconnect: qcom: qcm2290: Update EBI channel configuration
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (5 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 06/10] interconnect: qcom: qcm2290: Set AB coefficients Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 08/10] interconnect: qcom: sdm660: Set AB/IB coefficients Konrad Dybcio
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

QCM2290 can support two memory configurations: single-channel, 32-bit
wide LPDDR3 @ up to 933MHz (bus clock) or dual-channel, 16-bit wide
LPDDR4X @ up to 1804 MHz. The interconnect driver in its current form
seems to gravitate towards the first one, however there are no LPDDR3-
equipped boards upstream and we still don't have a great way to discern
the DDR generations on the kernel side.

To make DDR scaling possible on the only currently-supported 2290
board, stick with the LPDDR4X config by default. The side effect on any
potential LPDDR3 board would be that the requested bus clock rate is
too high (but still capped to the firmware-configured FMAX).

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/qcm2290.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/interconnect/qcom/qcm2290.c b/drivers/interconnect/qcom/qcm2290.c
index 42fa01c66e73..3bd7ad67c569 100644
--- a/drivers/interconnect/qcom/qcm2290.c
+++ b/drivers/interconnect/qcom/qcm2290.c
@@ -678,7 +678,8 @@ static struct qcom_icc_node mas_gfx3d = {
 static struct qcom_icc_node slv_ebi1 = {
 	.name = "slv_ebi1",
 	.id = QCM2290_SLAVE_EBI1,
-	.buswidth = 8,
+	.buswidth = 4,
+	.channels = 2,
 	.mas_rpm_id = -1,
 	.slv_rpm_id = 0,
 };

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 08/10] interconnect: qcom: sdm660: Set AB/IB coefficients
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (6 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 07/10] interconnect: qcom: qcm2290: Update EBI channel configuration Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 09/10] interconnect: qcom: msm8996: " Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 10/10] clk: qcom: smd-rpm: Move CPUSS_GNoC clock to interconnect Konrad Dybcio
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

Some buses and nodes need additional manual adjustments atop the usual
calculations. Fill in the missing coefficients.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/sdm660.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/interconnect/qcom/sdm660.c b/drivers/interconnect/qcom/sdm660.c
index 36962f7bd7bb..7392bebba334 100644
--- a/drivers/interconnect/qcom/sdm660.c
+++ b/drivers/interconnect/qcom/sdm660.c
@@ -602,6 +602,7 @@ static struct qcom_icc_node mas_mdp_p0 = {
 	.name = "mas_mdp_p0",
 	.id = SDM660_MASTER_MDP_P0,
 	.buswidth = 16,
+	.ib_coeff = 50,
 	.mas_rpm_id = 8,
 	.slv_rpm_id = -1,
 	.qos.ap_owned = true,
@@ -621,6 +622,7 @@ static struct qcom_icc_node mas_mdp_p1 = {
 	.name = "mas_mdp_p1",
 	.id = SDM660_MASTER_MDP_P1,
 	.buswidth = 16,
+	.ib_coeff = 50,
 	.mas_rpm_id = 61,
 	.slv_rpm_id = -1,
 	.qos.ap_owned = true,
@@ -1540,6 +1542,7 @@ static const struct qcom_icc_desc sdm660_bimc = {
 	.num_nodes = ARRAY_SIZE(sdm660_bimc_nodes),
 	.bus_clk_desc = &bimc_clk,
 	.regmap_cfg = &sdm660_bimc_regmap_config,
+	.ab_coeff = 153,
 };
 
 static struct qcom_icc_node * const sdm660_cnoc_nodes[] = {
@@ -1659,6 +1662,7 @@ static const struct qcom_icc_desc sdm660_mnoc = {
 	.intf_clocks = mm_intf_clocks,
 	.num_intf_clocks = ARRAY_SIZE(mm_intf_clocks),
 	.regmap_cfg = &sdm660_mnoc_regmap_config,
+	.ab_coeff = 153,
 };
 
 static struct qcom_icc_node * const sdm660_snoc_nodes[] = {

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 09/10] interconnect: qcom: msm8996: Set AB/IB coefficients
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (7 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 08/10] interconnect: qcom: sdm660: Set AB/IB coefficients Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  2023-08-08 11:43 ` [PATCH v3 10/10] clk: qcom: smd-rpm: Move CPUSS_GNoC clock to interconnect Konrad Dybcio
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

Some buses and nodes need additional manual adjustments atop the usual
calculations. Fill in the missing coefficients.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/interconnect/qcom/msm8996.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/interconnect/qcom/msm8996.c b/drivers/interconnect/qcom/msm8996.c
index 88683dfa468f..b73566c9b21f 100644
--- a/drivers/interconnect/qcom/msm8996.c
+++ b/drivers/interconnect/qcom/msm8996.c
@@ -448,6 +448,7 @@ static struct qcom_icc_node mas_mdp_p0 = {
 	.name = "mas_mdp_p0",
 	.id = MSM8996_MASTER_MDP_PORT0,
 	.buswidth = 32,
+	.ib_coeff = 25,
 	.mas_rpm_id = 8,
 	.slv_rpm_id = -1,
 	.qos.ap_owned = true,
@@ -463,6 +464,7 @@ static struct qcom_icc_node mas_mdp_p1 = {
 	.name = "mas_mdp_p1",
 	.id = MSM8996_MASTER_MDP_PORT1,
 	.buswidth = 32,
+	.ib_coeff = 25,
 	.mas_rpm_id = 61,
 	.slv_rpm_id = -1,
 	.qos.ap_owned = true,
@@ -1889,7 +1891,8 @@ static const struct qcom_icc_desc msm8996_bimc = {
 	.nodes = bimc_nodes,
 	.num_nodes = ARRAY_SIZE(bimc_nodes),
 	.bus_clk_desc = &bimc_clk,
-	.regmap_cfg = &msm8996_bimc_regmap_config
+	.regmap_cfg = &msm8996_bimc_regmap_config,
+	.ab_coeff = 154,
 };
 
 static struct qcom_icc_node * const cnoc_nodes[] = {
@@ -2004,7 +2007,8 @@ static const struct qcom_icc_desc msm8996_mnoc = {
 	.bus_clk_desc = &mmaxi_0_clk,
 	.intf_clocks = mm_intf_clocks,
 	.num_intf_clocks = ARRAY_SIZE(mm_intf_clocks),
-	.regmap_cfg = &msm8996_mnoc_regmap_config
+	.regmap_cfg = &msm8996_mnoc_regmap_config,
+	.ab_coeff = 154,
 };
 
 static struct qcom_icc_node * const pnoc_nodes[] = {

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 10/10] clk: qcom: smd-rpm: Move CPUSS_GNoC clock to interconnect
  2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
                   ` (8 preceding siblings ...)
  2023-08-08 11:43 ` [PATCH v3 09/10] interconnect: qcom: msm8996: " Konrad Dybcio
@ 2023-08-08 11:43 ` Konrad Dybcio
  9 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-08 11:43 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd
  Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel, linux-clk,
	Konrad Dybcio

As it turns out, it's yet another interconnect bus clock. Move it
there. See [1] for reference.

[1] https://android.googlesource.com/kernel/msm-extra/devicetree/+/02f8c342b23c20a5cf967df649814be37a08227c%5E%21/#F0
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/clk/qcom/clk-smd-rpm.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
index 9b5411932594..4a23f6d3eddd 100644
--- a/drivers/clk/qcom/clk-smd-rpm.c
+++ b/drivers/clk/qcom/clk-smd-rpm.c
@@ -567,6 +567,16 @@ static const struct clk_smd_rpm *sm_qnoc_icc_clks[] = {
 	&clk_smd_rpm_bus_2_snoc_clk,
 };
 
+static const struct clk_smd_rpm *qcm2290_icc_clks[] = {
+	&clk_smd_rpm_bimc_clk,
+	&clk_smd_rpm_bus_1_cnoc_clk,
+	&clk_smd_rpm_mmnrt_clk,
+	&clk_smd_rpm_mmrt_clk,
+	&clk_smd_rpm_qup_clk,
+	&clk_smd_rpm_bus_2_snoc_clk,
+	&clk_smd_rpm_cpuss_gnoc_clk,
+};
+
 static struct clk_smd_rpm *msm8909_clks[] = {
 	[RPM_SMD_QPIC_CLK]		= &clk_smd_rpm_qpic_clk,
 	[RPM_SMD_QPIC_CLK_A]		= &clk_smd_rpm_qpic_a_clk,
@@ -1182,15 +1192,13 @@ static struct clk_smd_rpm *qcm2290_clks[] = {
 	[RPM_SMD_PKA_A_CLK] = &clk_smd_rpm_pka_a_clk,
 	[RPM_SMD_BIMC_GPU_CLK] = &clk_smd_rpm_bimc_gpu_clk,
 	[RPM_SMD_BIMC_GPU_A_CLK] = &clk_smd_rpm_bimc_gpu_a_clk,
-	[RPM_SMD_CPUSS_GNOC_CLK] = &clk_smd_rpm_cpuss_gnoc_clk,
-	[RPM_SMD_CPUSS_GNOC_A_CLK] = &clk_smd_rpm_cpuss_gnoc_a_clk,
 };
 
 static const struct rpm_smd_clk_desc rpm_clk_qcm2290 = {
 	.clks = qcm2290_clks,
 	.num_clks = ARRAY_SIZE(qcm2290_clks),
-	.icc_clks = sm_qnoc_icc_clks,
-	.num_icc_clks = ARRAY_SIZE(sm_qnoc_icc_clks)
+	.icc_clks = qcm2290_icc_clks,
+	.num_icc_clks = ARRAY_SIZE(qcm2290_icc_clks)
 };
 
 static const struct of_device_id rpm_smd_clk_match_table[] = {

-- 
2.41.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients
  2023-08-08 11:43 ` [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients Konrad Dybcio
@ 2023-08-10  7:26   ` Stephan Gerhold
  2023-08-10 13:28     ` Konrad Dybcio
  0 siblings, 1 reply; 13+ messages in thread
From: Stephan Gerhold @ 2023-08-10  7:26 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd, Marijn Suijten, linux-arm-msm, linux-pm,
	linux-kernel, linux-clk

On Tue, Aug 08, 2023 at 01:43:35PM +0200, Konrad Dybcio wrote:
> Some nodes may have different coefficients than the general values for
> bus they're attached to. Check for that and use them if present. See
> [1], [2] for reference.
> 
> [1] https://github.com/sonyxperiadev/kernel/commit/7456d9779af9ad6bb9c7ee6f33d5c5a8d3648e24
> [2] https://github.com/artem/android_kernel_sony_msm8996/commit/bf7a8985dcaf0eab5bc2562d2d6775e7e29c0f30
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>  drivers/interconnect/qcom/icc-rpm.c | 14 ++++++++++----
>  drivers/interconnect/qcom/icc-rpm.h |  5 +++++
>  2 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> index 1d3af4e9ead8..9c40314e03b5 100644
> --- a/drivers/interconnect/qcom/icc-rpm.c
> +++ b/drivers/interconnect/qcom/icc-rpm.c
> @@ -300,14 +300,14 @@ static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node
>  	else
>  		agg_avg_rate = qn->sum_avg[ctx];
>  
> -	if (qp->ab_coeff) {
> -		agg_avg_rate = agg_avg_rate * qp->ab_coeff;
> +	if (qn->ab_coeff) {
> +		agg_avg_rate = agg_avg_rate * qn->ab_coeff;
>  		agg_avg_rate = div_u64(agg_avg_rate, 100);
>  	}
>  
> -	if (qp->ib_coeff) {
> +	if (qn->ib_coeff) {
>  		agg_peak_rate = qn->max_peak[ctx] * 100;
> -		agg_peak_rate = div_u64(qn->max_peak[ctx], qp->ib_coeff);
> +		agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff);
>  	} else {
>  		agg_peak_rate = qn->max_peak[ctx];
>  	}
> @@ -563,6 +563,12 @@ int qnoc_probe(struct platform_device *pdev)
>  	for (i = 0; i < num_nodes; i++) {
>  		size_t j;
>  
> +		if (!qnodes[i]->ab_coeff)
> +			qnodes[i]->ab_coeff = qp->ab_coeff;
> +
> +		if (!qnodes[i]->ib_coeff)
> +			qnodes[i]->ib_coeff = qp->ib_coeff;
> +
>  		node = icc_node_create(qnodes[i]->id);
>  		if (IS_ERR(node)) {
>  			ret = PTR_ERR(node);
> diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h
> index f9ef16f570be..4abf99ce2690 100644
> --- a/drivers/interconnect/qcom/icc-rpm.h
> +++ b/drivers/interconnect/qcom/icc-rpm.h
> @@ -103,6 +103,9 @@ struct qcom_icc_qos {
>   * @mas_rpm_id:	RPM id for devices that are bus masters
>   * @slv_rpm_id:	RPM id for devices that are bus slaves
>   * @qos: NoC QoS setting parameters
> + * @ab_coeff: a percentage-based coefficient for compensating the AB calculations
> + * @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
> + * @bus_clk_rate: a pointer to an array containing bus clock rates in Hz

Nitpick: The doc comment needs to be moved to the earlier patch as well. :)

>   */
>  struct qcom_icc_node {
>  	unsigned char *name;
> @@ -117,6 +120,8 @@ struct qcom_icc_node {
>  	int mas_rpm_id;
>  	int slv_rpm_id;
>  	struct qcom_icc_qos qos;
> +	u16 ab_coeff;
> +	u16 ib_coeff;
>  	u32 bus_clk_rate[QCOM_SMD_RPM_STATE_NUM];
>  };
>  
> 
> -- 
> 2.41.0
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients
  2023-08-10  7:26   ` Stephan Gerhold
@ 2023-08-10 13:28     ` Konrad Dybcio
  0 siblings, 0 replies; 13+ messages in thread
From: Konrad Dybcio @ 2023-08-10 13:28 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Andy Gross, Bjorn Andersson, Georgi Djakov, Michael Turquette,
	Stephen Boyd, Marijn Suijten, linux-arm-msm, linux-pm,
	linux-kernel, linux-clk

On 10.08.2023 09:26, Stephan Gerhold wrote:
> On Tue, Aug 08, 2023 at 01:43:35PM +0200, Konrad Dybcio wrote:
>> Some nodes may have different coefficients than the general values for
>> bus they're attached to. Check for that and use them if present. See
>> [1], [2] for reference.
>>
>> [1] https://github.com/sonyxperiadev/kernel/commit/7456d9779af9ad6bb9c7ee6f33d5c5a8d3648e24
>> [2] https://github.com/artem/android_kernel_sony_msm8996/commit/bf7a8985dcaf0eab5bc2562d2d6775e7e29c0f30
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>  drivers/interconnect/qcom/icc-rpm.c | 14 ++++++++++----
>>  drivers/interconnect/qcom/icc-rpm.h |  5 +++++
>>  2 files changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
>> index 1d3af4e9ead8..9c40314e03b5 100644
>> --- a/drivers/interconnect/qcom/icc-rpm.c
>> +++ b/drivers/interconnect/qcom/icc-rpm.c
>> @@ -300,14 +300,14 @@ static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node
>>  	else
>>  		agg_avg_rate = qn->sum_avg[ctx];
>>  
>> -	if (qp->ab_coeff) {
>> -		agg_avg_rate = agg_avg_rate * qp->ab_coeff;
>> +	if (qn->ab_coeff) {
>> +		agg_avg_rate = agg_avg_rate * qn->ab_coeff;
>>  		agg_avg_rate = div_u64(agg_avg_rate, 100);
>>  	}
>>  
>> -	if (qp->ib_coeff) {
>> +	if (qn->ib_coeff) {
>>  		agg_peak_rate = qn->max_peak[ctx] * 100;
>> -		agg_peak_rate = div_u64(qn->max_peak[ctx], qp->ib_coeff);
>> +		agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff);
>>  	} else {
>>  		agg_peak_rate = qn->max_peak[ctx];
>>  	}
>> @@ -563,6 +563,12 @@ int qnoc_probe(struct platform_device *pdev)
>>  	for (i = 0; i < num_nodes; i++) {
>>  		size_t j;
>>  
>> +		if (!qnodes[i]->ab_coeff)
>> +			qnodes[i]->ab_coeff = qp->ab_coeff;
>> +
>> +		if (!qnodes[i]->ib_coeff)
>> +			qnodes[i]->ib_coeff = qp->ib_coeff;
>> +
>>  		node = icc_node_create(qnodes[i]->id);
>>  		if (IS_ERR(node)) {
>>  			ret = PTR_ERR(node);
>> diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h
>> index f9ef16f570be..4abf99ce2690 100644
>> --- a/drivers/interconnect/qcom/icc-rpm.h
>> +++ b/drivers/interconnect/qcom/icc-rpm.h
>> @@ -103,6 +103,9 @@ struct qcom_icc_qos {
>>   * @mas_rpm_id:	RPM id for devices that are bus masters
>>   * @slv_rpm_id:	RPM id for devices that are bus slaves
>>   * @qos: NoC QoS setting parameters
>> + * @ab_coeff: a percentage-based coefficient for compensating the AB calculations
>> + * @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
>> + * @bus_clk_rate: a pointer to an array containing bus clock rates in Hz
> 
> Nitpick: The doc comment needs to be moved to the earlier patch as well. :)
Gah :P

Konrad

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-08-10 13:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08 11:43 [PATCH v3 00/10] Fix up icc clock rate calculation on some platforms Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 01/10] interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 02/10] interconnect: qcom: icc-rpm: Separate out clock rate calulcations Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 03/10] interconnect: qcom: icc-rpm: Let nodes drive their own bus clock Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 04/10] interconnect: qcom: icc-rpm: Check for node-specific rate coefficients Konrad Dybcio
2023-08-10  7:26   ` Stephan Gerhold
2023-08-10 13:28     ` Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 05/10] interconnect: qcom: qcm2290: Hook up MAS_APPS_PROC's bus clock Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 06/10] interconnect: qcom: qcm2290: Set AB coefficients Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 07/10] interconnect: qcom: qcm2290: Update EBI channel configuration Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 08/10] interconnect: qcom: sdm660: Set AB/IB coefficients Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 09/10] interconnect: qcom: msm8996: " Konrad Dybcio
2023-08-08 11:43 ` [PATCH v3 10/10] clk: qcom: smd-rpm: Move CPUSS_GNoC clock to interconnect Konrad Dybcio

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).