2023-07-31 13:00:23

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2 00/10] Fix up icc clock rate calculation on some platforms

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 <[email protected]>
---
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/[email protected]

---
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 | 92 ++++++++++++++++++++++++------
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, 124 insertions(+), 26 deletions(-)
---
base-commit: ec89391563792edd11d138a853901bce76d11f44
change-id: 20230726-topic-icc_coeff-b053d5409b9f

Best regards,
--
Konrad Dybcio <[email protected]>



2023-07-31 13:51:13

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2 02/10] interconnect: qcom: icc-rpm: Separate out clock rate calulcations

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

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/interconnect/qcom/icc-rpm.c | 46 ++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index a837d20af79e..f1d8ed354718 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -291,6 +291,29 @@ 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];
+
+ /* Check if the node has a specific coefficient first*/
+ if (qp->ab_coeff)
+ agg_avg_rate = mult_frac(qp->ab_coeff, agg_avg_rate, 100);
+
+ if (qp->ib_coeff)
+ agg_peak_rate = mult_frac(100, 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 +322,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,23 +332,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 = mult_frac(qp->ab_coeff, agg_avg_rate, 100);
-
- if (qp->ib_coeff)
- agg_peak_rate = mult_frac(100, 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


2023-08-04 18:00:56

by Georgi Djakov

[permalink] [raw]
Subject: Re: [PATCH v2 00/10] Fix up icc clock rate calculation on some platforms

Hi Konrad,

On 31.07.23 13:52, Konrad Dybcio wrote:
> 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".

Maybe some links to the downstream code would help to better check and
understand this. Adding also Odelu in case he has any comments on the
patches.

Thanks,
Georgi

> Add the framework for it and utilize it on a couple SoCs.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> 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/[email protected]
>
> ---
> 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 | 92 ++++++++++++++++++++++++------
> 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, 124 insertions(+), 26 deletions(-)
> ---
> base-commit: ec89391563792edd11d138a853901bce76d11f44
> change-id: 20230726-topic-icc_coeff-b053d5409b9f
>
> Best regards,