This patch set is to support bucket in icc-rpm driver, so it implements
the similar mechanism in the icc-rpmh driver.
We can use interconnect path tag to indicate the bandwidth voting is for
which buckets, and there have three kinds of buckets: AWC, WAKE and
SLEEP, finally the wake and sleep bucket values are used to set the
corresponding clock (active and sleep clocks). So far, we keep the AWC
bucket but doesn't really use it.
Patches 01, 02, 03 enable interconnect path tag and update the DT
binding document; patches 04 and 05 support bucket and use bucket values
to set the bandwidth and clock rates.
Changes from v3:
- Removed $ref and redundant sentence in DT binding document for
'#interconnect-cells' (Krzysztof Kozlowski).
Changes from v2:
- Fixed for DT checker error for command ''make DT_CHECKER_FLAGS=-m
dt_binding_check' (Rob Herring).
Changes from v1:
- Added description for property "#interconnect-cells" (Rob Herring);
- Added Dimtry's reviewed tags for patches 02 and 03 (Dmitry Baryshkov);
- Rebased on the latest mainline kernel and resolved conflict.
Leo Yan (5):
dt-bindings: interconnect: Update property for icc-rpm path tag
interconnect: qcom: Move qcom_icc_xlate_extended() to a common file
interconnect: qcom: icc-rpm: Change to use qcom_icc_xlate_extended()
interconnect: qcom: icc-rpm: Support multiple buckets
interconnect: qcom: icc-rpm: Set bandwidth and clock for bucket values
.../bindings/interconnect/qcom,rpm.yaml | 6 +-
drivers/interconnect/qcom/Makefile | 3 +
drivers/interconnect/qcom/icc-common.c | 34 +++++
drivers/interconnect/qcom/icc-common.h | 13 ++
drivers/interconnect/qcom/icc-rpm.c | 134 ++++++++++++++++--
drivers/interconnect/qcom/icc-rpm.h | 6 +
drivers/interconnect/qcom/icc-rpmh.c | 26 +---
drivers/interconnect/qcom/icc-rpmh.h | 1 -
drivers/interconnect/qcom/sm8450.c | 1 +
9 files changed, 182 insertions(+), 42 deletions(-)
create mode 100644 drivers/interconnect/qcom/icc-common.c
create mode 100644 drivers/interconnect/qcom/icc-common.h
--
2.25.1
This commit uses buckets for support bandwidth and clock rates. It
introduces a new function qcom_icc_bus_aggregate() to calculate the
aggregate average and peak bandwidths for every bucket, and also it
calculates the maximum aggregate values across all buckets.
The maximum aggregate values are used to calculate the final bandwidth
requests. And we can set the clock rate per bucket, we use SLEEP bucket
as default bucket if a platform doesn't enable the interconnect path
tags in DT binding; otherwise, we use WAKE bucket to set active clock
and use SLEEP bucket for other clocks. So far we don't use AMC bucket.
Signed-off-by: Leo Yan <[email protected]>
---
drivers/interconnect/qcom/icc-rpm.c | 80 ++++++++++++++++++++++++-----
1 file changed, 67 insertions(+), 13 deletions(-)
diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index b025fc6b97c9..4b932eb807c7 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -302,18 +302,62 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
return 0;
}
+/**
+ * qcom_icc_bus_aggregate - aggregate bandwidth by traversing all nodes
+ * @provider: generic interconnect provider
+ * @agg_avg: an array for aggregated average bandwidth of buckets
+ * @agg_peak: an array for aggregated peak bandwidth of buckets
+ * @max_agg_avg: pointer to max value of aggregated average bandwidth
+ * @max_agg_peak: pointer to max value of aggregated peak bandwidth
+ */
+static void qcom_icc_bus_aggregate(struct icc_provider *provider,
+ u64 *agg_avg, u64 *agg_peak,
+ u64 *max_agg_avg, u64 *max_agg_peak)
+{
+ struct icc_node *node;
+ struct qcom_icc_node *qn;
+ int i;
+
+ /* Initialise aggregate values */
+ for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
+ agg_avg[i] = 0;
+ agg_peak[i] = 0;
+ }
+
+ *max_agg_avg = 0;
+ *max_agg_peak = 0;
+
+ /*
+ * Iterate nodes on the interconnect and aggregate bandwidth
+ * requests for every bucket.
+ */
+ list_for_each_entry(node, &provider->nodes, node_list) {
+ qn = node->data;
+ for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
+ agg_avg[i] += qn->sum_avg[i];
+ agg_peak[i] = max_t(u64, agg_peak[i], qn->max_peak[i]);
+ }
+ }
+
+ /* Find maximum values across all buckets */
+ for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
+ *max_agg_avg = max_t(u64, *max_agg_avg, agg_avg[i]);
+ *max_agg_peak = max_t(u64, *max_agg_peak, agg_peak[i]);
+ }
+}
+
static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
{
struct qcom_icc_provider *qp;
struct qcom_icc_node *src_qn = NULL, *dst_qn = NULL;
struct icc_provider *provider;
- struct icc_node *n;
u64 sum_bw;
u64 max_peak_bw;
u64 rate;
- u32 agg_avg = 0;
- u32 agg_peak = 0;
+ u64 agg_avg[QCOM_ICC_NUM_BUCKETS], agg_peak[QCOM_ICC_NUM_BUCKETS];
+ u64 max_agg_avg, max_agg_peak;
int ret, i;
+ int bucket;
src_qn = src->data;
if (dst)
@@ -321,12 +365,11 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
provider = src->provider;
qp = to_qcom_provider(provider);
- list_for_each_entry(n, &provider->nodes, node_list)
- provider->aggregate(n, 0, n->avg_bw, n->peak_bw,
- &agg_avg, &agg_peak);
+ qcom_icc_bus_aggregate(provider, agg_avg, agg_peak, &max_agg_avg,
+ &max_agg_peak);
- sum_bw = icc_units_to_bps(agg_avg);
- max_peak_bw = icc_units_to_bps(agg_peak);
+ sum_bw = icc_units_to_bps(max_agg_avg);
+ max_peak_bw = icc_units_to_bps(max_agg_peak);
ret = __qcom_icc_set(src, src_qn, sum_bw);
if (ret)
@@ -337,12 +380,23 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
return ret;
}
- rate = max(sum_bw, max_peak_bw);
-
- do_div(rate, src_qn->buswidth);
- rate = min_t(u64, rate, LONG_MAX);
-
for (i = 0; i < qp->num_clks; i++) {
+ /*
+ * Use WAKE bucket for active clock, otherwise, use SLEEP bucket
+ * for other clocks. If a platform doesn't set interconnect
+ * path tags, by default use sleep bucket for all clocks.
+ *
+ * Note, AMC bucket is not supported yet.
+ */
+ if (!strcmp(qp->bus_clks[i].id, "bus_a"))
+ bucket = QCOM_ICC_BUCKET_WAKE;
+ else
+ bucket = QCOM_ICC_BUCKET_SLEEP;
+
+ rate = icc_units_to_bps(max(agg_avg[bucket], agg_peak[bucket]));
+ do_div(rate, src_qn->buswidth);
+ rate = min_t(u64, rate, LONG_MAX);
+
if (qp->bus_clk_rate[i] == rate)
continue;
--
2.25.1
On 5.07.22 10:23, Leo Yan wrote:
> This patch set is to support bucket in icc-rpm driver, so it implements
> the similar mechanism in the icc-rpmh driver.
>
> We can use interconnect path tag to indicate the bandwidth voting is for
> which buckets, and there have three kinds of buckets: AWC, WAKE and
> SLEEP, finally the wake and sleep bucket values are used to set the
> corresponding clock (active and sleep clocks). So far, we keep the AWC
> bucket but doesn't really use it.
>
> Patches 01, 02, 03 enable interconnect path tag and update the DT
> binding document; patches 04 and 05 support bucket and use bucket values
> to set the bandwidth and clock rates.
>
> Changes from v3:
> - Removed $ref and redundant sentence in DT binding document for
> '#interconnect-cells' (Krzysztof Kozlowski).
>
> Changes from v2:
> - Fixed for DT checker error for command ''make DT_CHECKER_FLAGS=-m
> dt_binding_check' (Rob Herring).
>
> Changes from v1:
> - Added description for property "#interconnect-cells" (Rob Herring);
> - Added Dimtry's reviewed tags for patches 02 and 03 (Dmitry Baryshkov);
> - Rebased on the latest mainline kernel and resolved conflict.
>
>
> Leo Yan (5):
> dt-bindings: interconnect: Update property for icc-rpm path tag
> interconnect: qcom: Move qcom_icc_xlate_extended() to a common file
> interconnect: qcom: icc-rpm: Change to use qcom_icc_xlate_extended()
> interconnect: qcom: icc-rpm: Support multiple buckets
> interconnect: qcom: icc-rpm: Set bandwidth and clock for bucket values
Hi Leo,
Some patches do not apply clean on next. On which tree is this based? Do you have any additional
patches?
Thanks,
Georgi
Hi Georgi,
On Tue, Jul 05, 2022 at 05:03:21PM +0300, Georgi Djakov wrote:
[...]
> Hi Leo,
>
> Some patches do not apply clean on next. On which tree is this based? Do you
> have any additional patches?
When rebased I included an out of tree patch, let me check a bit and
resend the new patch set. Sorry for inconvenience.
Thanks,
Leo
Hi Georgi,
On Thu, Jul 07, 2022 at 10:52:33AM +0800, Leo Yan wrote:
[...]
> > Some patches do not apply clean on next. On which tree is this based? Do you
> > have any additional patches?
>
> When rebased I included an out of tree patch, let me check a bit and
> resend the new patch set. Sorry for inconvenience.
Bryan has sent out the patch
"interconnect: icc-rpm: Set destination bandwidth as well as source
bandwidth" [1]. My patch series was based on Bryan's patch, you could
apply them cleanly after applying Bryan's patch.
Please let us know what's your preference for picking patches order, if
you prefer to apply my patch series before Bryan's fixing patch, I will
rebase the patch set on the mainline kernel with dropping Bryan's patch
(which means Bryan needs to rebase his patch).
Thanks,
Leo
[1] https://lore.kernel.org/linux-pm/[email protected]/T/#r304f7b103c806e1570d555a0f5aaf83ae3990ac0
On 5.07.22 10:23, Leo Yan wrote:
> This commit uses buckets for support bandwidth and clock rates. It
> introduces a new function qcom_icc_bus_aggregate() to calculate the
> aggregate average and peak bandwidths for every bucket, and also it
> calculates the maximum aggregate values across all buckets.
>
> The maximum aggregate values are used to calculate the final bandwidth
> requests. And we can set the clock rate per bucket, we use SLEEP bucket
> as default bucket if a platform doesn't enable the interconnect path
> tags in DT binding; otherwise, we use WAKE bucket to set active clock
> and use SLEEP bucket for other clocks. So far we don't use AMC bucket.
>
> Signed-off-by: Leo Yan <[email protected]>
> ---
> drivers/interconnect/qcom/icc-rpm.c | 80 ++++++++++++++++++++++++-----
> 1 file changed, 67 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> index b025fc6b97c9..4b932eb807c7 100644
> --- a/drivers/interconnect/qcom/icc-rpm.c
> +++ b/drivers/interconnect/qcom/icc-rpm.c
> @@ -302,18 +302,62 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
> return 0;
> }
>
> +/**
> + * qcom_icc_bus_aggregate - aggregate bandwidth by traversing all nodes
> + * @provider: generic interconnect provider
> + * @agg_avg: an array for aggregated average bandwidth of buckets
> + * @agg_peak: an array for aggregated peak bandwidth of buckets
> + * @max_agg_avg: pointer to max value of aggregated average bandwidth
> + * @max_agg_peak: pointer to max value of aggregated peak bandwidth
> + */
> +static void qcom_icc_bus_aggregate(struct icc_provider *provider,
> + u64 *agg_avg, u64 *agg_peak,
> + u64 *max_agg_avg, u64 *max_agg_peak)
> +{
> + struct icc_node *node;
> + struct qcom_icc_node *qn;
> + int i;
> +
> + /* Initialise aggregate values */
> + for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
> + agg_avg[i] = 0;
> + agg_peak[i] = 0;
> + }
> +
> + *max_agg_avg = 0;
> + *max_agg_peak = 0;
> +
> + /*
> + * Iterate nodes on the interconnect and aggregate bandwidth
> + * requests for every bucket.
> + */
> + list_for_each_entry(node, &provider->nodes, node_list) {
> + qn = node->data;
> + for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
> + agg_avg[i] += qn->sum_avg[i];
> + agg_peak[i] = max_t(u64, agg_peak[i], qn->max_peak[i]);
> + }
> + }
> +
> + /* Find maximum values across all buckets */
> + for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
> + *max_agg_avg = max_t(u64, *max_agg_avg, agg_avg[i]);
> + *max_agg_peak = max_t(u64, *max_agg_peak, agg_peak[i]);
> + }
> +}
> +
> static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
> {
> struct qcom_icc_provider *qp;
> struct qcom_icc_node *src_qn = NULL, *dst_qn = NULL;
> struct icc_provider *provider;
> - struct icc_node *n;
> u64 sum_bw;
> u64 max_peak_bw;
> u64 rate;
> - u32 agg_avg = 0;
> - u32 agg_peak = 0;
> + u64 agg_avg[QCOM_ICC_NUM_BUCKETS], agg_peak[QCOM_ICC_NUM_BUCKETS];
> + u64 max_agg_avg, max_agg_peak;
> int ret, i;
> + int bucket;
>
> src_qn = src->data;
> if (dst)
> @@ -321,12 +365,11 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
> provider = src->provider;
> qp = to_qcom_provider(provider);
>
> - list_for_each_entry(n, &provider->nodes, node_list)
> - provider->aggregate(n, 0, n->avg_bw, n->peak_bw,
> - &agg_avg, &agg_peak);
> + qcom_icc_bus_aggregate(provider, agg_avg, agg_peak, &max_agg_avg,
> + &max_agg_peak);
>
> - sum_bw = icc_units_to_bps(agg_avg);
> - max_peak_bw = icc_units_to_bps(agg_peak);
> + sum_bw = icc_units_to_bps(max_agg_avg);
> + max_peak_bw = icc_units_to_bps(max_agg_peak);
>
> ret = __qcom_icc_set(src, src_qn, sum_bw);
> if (ret)
> @@ -337,12 +380,23 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
> return ret;
> }
>
> - rate = max(sum_bw, max_peak_bw);
Looks like max_peak_bw is unused now?
> - do_div(rate, src_qn->buswidth);
> - rate = min_t(u64, rate, LONG_MAX);
> -
> for (i = 0; i < qp->num_clks; i++) {
> + /*
> + * Use WAKE bucket for active clock, otherwise, use SLEEP bucket
> + * for other clocks. If a platform doesn't set interconnect
> + * path tags, by default use sleep bucket for all clocks.
> + *
> + * Note, AMC bucket is not supported yet.
> + */
> + if (!strcmp(qp->bus_clks[i].id, "bus_a"))
> + bucket = QCOM_ICC_BUCKET_WAKE;
> + else
> + bucket = QCOM_ICC_BUCKET_SLEEP;
> +
> + rate = icc_units_to_bps(max(agg_avg[bucket], agg_peak[bucket]));
> + do_div(rate, src_qn->buswidth);
> + rate = min_t(u64, rate, LONG_MAX);
> +
> if (qp->bus_clk_rate[i] == rate)
> continue;
Thanks,
Georgi
On Thu, Jul 07, 2022 at 05:33:58PM +0300, Georgi Djakov wrote:
[...]
> > @@ -321,12 +365,11 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
> > provider = src->provider;
> > qp = to_qcom_provider(provider);
> > - list_for_each_entry(n, &provider->nodes, node_list)
> > - provider->aggregate(n, 0, n->avg_bw, n->peak_bw,
> > - &agg_avg, &agg_peak);
> > + qcom_icc_bus_aggregate(provider, agg_avg, agg_peak, &max_agg_avg,
> > + &max_agg_peak);
> > - sum_bw = icc_units_to_bps(agg_avg);
> > - max_peak_bw = icc_units_to_bps(agg_peak);
> > + sum_bw = icc_units_to_bps(max_agg_avg);
> > + max_peak_bw = icc_units_to_bps(max_agg_peak);
> > ret = __qcom_icc_set(src, src_qn, sum_bw);
> > if (ret)
> > @@ -337,12 +380,23 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
> > return ret;
> > }
> > - rate = max(sum_bw, max_peak_bw);
>
> Looks like max_peak_bw is unused now?
Yes, will drop it in next spin.
Thanks for review.
Leo