* [PATCH v2 0/2] Improve enable_mask handling
@ 2023-08-11 23:16 Konrad Dybcio
2023-08-11 23:16 ` [PATCH v2 1/2] interconnect: qcom: bcm-voter: " Konrad Dybcio
2023-08-11 23:16 ` [PATCH v2 2/2] interconnect: qcom: bcm-voter: Use enable_maks for keepalive voting Konrad Dybcio
0 siblings, 2 replies; 3+ messages in thread
From: Konrad Dybcio @ 2023-08-11 23:16 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Georgi Djakov, Mike Tipton,
Neil Armstrong
Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel,
Konrad Dybcio, Bjorn Andersson
As pointed out by Bjorn and Mike in [1], we can simplify the handling
of enable_mask-based BCMs. This series attempts to do so and fixes a bug
that snuck in.
Gave a quick spin on 8450, doesn't seem to have exploded.
[1] https://lore.kernel.org/linux-arm-msm/113b50f8-35f6-73fc-4fc9-302262927c5e@quicinc.com/
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
Changes in v2:
- Rename bcm_aggregate_1he to bcm_aggregate_mask (Mike)
- Fix never clearing enable_mask that was once enabled (Mike)
- Pick up tags (Bjorn)
- Link to v1: https://lore.kernel.org/r/20230811-topic-icc_fix_1he-v1-0-5c96ccef3399@linaro.org
---
Konrad Dybcio (2):
interconnect: qcom: bcm-voter: Improve enable_mask handling
interconnect: qcom: bcm-voter: Use enable_maks for keepalive voting
drivers/interconnect/qcom/bcm-voter.c | 43 +++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 7 deletions(-)
---
base-commit: 535e616fd036bf8f2307b0f02a1912cf81deed4c
change-id: 20230811-topic-icc_fix_1he-40a3948b08f7
Best regards,
--
Konrad Dybcio <konrad.dybcio@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] interconnect: qcom: bcm-voter: Improve enable_mask handling
2023-08-11 23:16 [PATCH v2 0/2] Improve enable_mask handling Konrad Dybcio
@ 2023-08-11 23:16 ` Konrad Dybcio
2023-08-11 23:16 ` [PATCH v2 2/2] interconnect: qcom: bcm-voter: Use enable_maks for keepalive voting Konrad Dybcio
1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2023-08-11 23:16 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Georgi Djakov, Mike Tipton,
Neil Armstrong
Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel,
Konrad Dybcio, Bjorn Andersson
We don't need all the complex arithmetic for BCMs utilizing enable_mask,
as all we need to do is to determine whether there's any user (or
keepalive) asking for it to be on.
Separate the logic for such BCMs for a small speed boost.
Suggested-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
drivers/interconnect/qcom/bcm-voter.c | 43 +++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
index d5f2a6b5376b..d857eb8838b9 100644
--- a/drivers/interconnect/qcom/bcm-voter.c
+++ b/drivers/interconnect/qcom/bcm-voter.c
@@ -58,6 +58,36 @@ static u64 bcm_div(u64 num, u32 base)
return num;
}
+/* BCMs with enable_mask use one-hot-encoding for on/off signaling */
+static void bcm_aggregate_mask(struct qcom_icc_bcm *bcm)
+{
+ struct qcom_icc_node *node;
+ int bucket, i;
+
+ for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
+ bcm->vote_x[bucket] = 0;
+ bcm->vote_y[bucket] = 0;
+
+ for (i = 0; i < bcm->num_nodes; i++) {
+ node = bcm->nodes[i];
+
+ /* If any vote in this bucket exists, keep the BCM enabled */
+ if (node->sum_avg[bucket] || node->max_peak[bucket]) {
+ bcm->vote_x[bucket] = 0;
+ bcm->vote_y[bucket] = bcm->enable_mask;
+ break;
+ }
+ }
+ }
+
+ if (bcm->keepalive) {
+ bcm->vote_x[QCOM_ICC_BUCKET_AMC] = 1;
+ bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = 1;
+ bcm->vote_y[QCOM_ICC_BUCKET_AMC] = 1;
+ bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = 1;
+ }
+}
+
static void bcm_aggregate(struct qcom_icc_bcm *bcm)
{
struct qcom_icc_node *node;
@@ -83,11 +113,6 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)
temp = agg_peak[bucket] * bcm->vote_scale;
bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
-
- if (bcm->enable_mask && (bcm->vote_x[bucket] || bcm->vote_y[bucket])) {
- bcm->vote_x[bucket] = 0;
- bcm->vote_y[bucket] = bcm->enable_mask;
- }
}
if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&
@@ -260,8 +285,12 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
return 0;
mutex_lock(&voter->lock);
- list_for_each_entry(bcm, &voter->commit_list, list)
- bcm_aggregate(bcm);
+ list_for_each_entry(bcm, &voter->commit_list, list) {
+ if (bcm->enable_mask)
+ bcm_aggregate_mask(bcm);
+ else
+ bcm_aggregate(bcm);
+ }
/*
* Pre sort the BCMs based on VCD for ease of generating a command list
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] interconnect: qcom: bcm-voter: Use enable_maks for keepalive voting
2023-08-11 23:16 [PATCH v2 0/2] Improve enable_mask handling Konrad Dybcio
2023-08-11 23:16 ` [PATCH v2 1/2] interconnect: qcom: bcm-voter: " Konrad Dybcio
@ 2023-08-11 23:16 ` Konrad Dybcio
1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2023-08-11 23:16 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Georgi Djakov, Mike Tipton,
Neil Armstrong
Cc: Marijn Suijten, linux-arm-msm, linux-pm, linux-kernel,
Konrad Dybcio, Bjorn Andersson
BCMs with an enable_mask expect to only have that specific value written
to them. The current implementation only works by miracle for BCMs with
enable mask == BIT(0), as the minimal vote we've been using so far just
so happens to be equal to that.
Use the correct value with keepalive voting.
Fixes: d8630f050d3f ("interconnect: qcom: Add support for mask-based BCMs")
Reported-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
drivers/interconnect/qcom/bcm-voter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
index d857eb8838b9..a2d437a05a11 100644
--- a/drivers/interconnect/qcom/bcm-voter.c
+++ b/drivers/interconnect/qcom/bcm-voter.c
@@ -81,10 +81,10 @@ static void bcm_aggregate_mask(struct qcom_icc_bcm *bcm)
}
if (bcm->keepalive) {
- bcm->vote_x[QCOM_ICC_BUCKET_AMC] = 1;
- bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = 1;
- bcm->vote_y[QCOM_ICC_BUCKET_AMC] = 1;
- bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = 1;
+ bcm->vote_x[QCOM_ICC_BUCKET_AMC] = bcm->enable_mask;
+ bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = bcm->enable_mask;
+ bcm->vote_y[QCOM_ICC_BUCKET_AMC] = bcm->enable_mask;
+ bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = bcm->enable_mask;
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-11 23:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 23:16 [PATCH v2 0/2] Improve enable_mask handling Konrad Dybcio
2023-08-11 23:16 ` [PATCH v2 1/2] interconnect: qcom: bcm-voter: " Konrad Dybcio
2023-08-11 23:16 ` [PATCH v2 2/2] interconnect: qcom: bcm-voter: Use enable_maks for keepalive voting 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).