From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBB97C43334 for ; Tue, 12 Jul 2022 02:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231844AbiGLCAb (ORCPT ); Mon, 11 Jul 2022 22:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiGLCAU (ORCPT ); Mon, 11 Jul 2022 22:00:20 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 285768E1FC for ; Mon, 11 Jul 2022 19:00:17 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id q82so6298303pgq.6 for ; Mon, 11 Jul 2022 19:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JrLh+9lwzn/hVK+x3i4SIxhqvOdLJGufkP7mGEFOm9c=; b=JyNI/FbvGc5ZUsCcMu6of1CIJXsDPu4qESFa1L5GYZGcSmZSGD8HmF22chR05DLpNR IwQQMOPJil0jwSX2iHcKnJ3iSxEYyRuknAPgeLLG+j2fHk9ZexDrMQ/XNY4hF7QLAtMg Kc3IPFq3PPIYubiXI8KZjFtz33sD55mf++AVbQPYU9y9Su/kRVTpr+H6kPLBSZ/owavj JmyCUWr9oqqYOK8yVHEcoI+dEgjMzxaqTnjaUCJ5/E4wvrRLMhcI1JQApHRZj7G1E7lZ oTLUus32jmtgFUQkaDf3Wt4+nVFSKLzuCu+y6hHUOpx24WdzxWfRYgj1d3NriUnmOJMB xNow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JrLh+9lwzn/hVK+x3i4SIxhqvOdLJGufkP7mGEFOm9c=; b=j4LzhRVZJtSbdYBO34k1G+n4X9QU2x+C/iNRdUnE2ToDqtnyG46WlUxTXhXT5iMVLe oH+srl+Jmt8SFdMQIsQ5duVumoiF3NykZYpJTNBNsXPmKwncro8VYRiL95baYdlpJZko QX3uc0RXNuW0I8emWtofLAKeck5IWeeD4bCL+JsDjgPu8MY8O4tJJUlI6dVek3FjP7wo nano89r9CLxo4z1iq8QKk6LuvxFYg2cTgzDi+KBrIDrHmwrRX+qhxAY8XoRvUrviWWiU D9AoXxMqpnZR0ICiw9G5IhgNuHwMHtpbxvATWZ1WB0scOC4dagA79YJLfHqOhnmikD3a qAsw== X-Gm-Message-State: AJIora/hu+OhNc6Nhk9nEj6waKDlyKWJ9vJn4YWnA83pBJFj+Twh3ik8 GLuxsEKZkRFuXq0kaJGZ9DfvvA== X-Google-Smtp-Source: AGRyM1vvGyt5VystS+i0DJ7EvZGc01AZoMkAN3JlckCOtoxswxdxThw9EmkygDkwOIo8HzjlAeHQuA== X-Received: by 2002:a62:5bc5:0:b0:528:c346:9632 with SMTP id p188-20020a625bc5000000b00528c3469632mr21427527pfb.48.1657591216051; Mon, 11 Jul 2022 19:00:16 -0700 (PDT) Received: from leo-build-box.lan (n058152077182.netvigator.com. [58.152.77.182]) by smtp.gmail.com with ESMTPSA id x5-20020a17090a6b4500b001ef76dbae28sm5425821pjl.36.2022.07.11.19.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 19:00:15 -0700 (PDT) From: Leo Yan To: Georgi Djakov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v6 5/5] interconnect: qcom: icc-rpm: Set bandwidth and clock for bucket values Date: Tue, 12 Jul 2022 09:59:29 +0800 Message-Id: <20220712015929.2789881-6-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712015929.2789881-1-leo.yan@linaro.org> References: <20220712015929.2789881-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 value of aggregated average bandwidth across all buckets. The maximum aggregated average is 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 --- drivers/interconnect/qcom/icc-rpm.c | 75 +++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index d27b1582521f..7f6a70e0256a 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -302,18 +302,57 @@ 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 + */ +static void qcom_icc_bus_aggregate(struct icc_provider *provider, + u64 *agg_avg, u64 *agg_peak, + u64 *max_agg_avg) +{ + 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; + + /* + * 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]); +} + 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; int ret, i; + int bucket; src_qn = src->data; if (dst) @@ -321,12 +360,9 @@ 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); - 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); ret = __qcom_icc_set(src, src_qn, sum_bw); if (ret) @@ -337,12 +373,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