Skip to content

Commit a1f4170

Browse files
konradybcioGeorgi Djakov
authored andcommitted
interconnect: qcom: bcm-voter: Improve enable_mask handling
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 <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Konrad Dybcio <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Georgi Djakov <[email protected]>
1 parent 2ccdd1b commit a1f4170

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

drivers/interconnect/qcom/bcm-voter.c

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,36 @@ static u64 bcm_div(u64 num, u32 base)
5858
return num;
5959
}
6060

61+
/* BCMs with enable_mask use one-hot-encoding for on/off signaling */
62+
static void bcm_aggregate_mask(struct qcom_icc_bcm *bcm)
63+
{
64+
struct qcom_icc_node *node;
65+
int bucket, i;
66+
67+
for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
68+
bcm->vote_x[bucket] = 0;
69+
bcm->vote_y[bucket] = 0;
70+
71+
for (i = 0; i < bcm->num_nodes; i++) {
72+
node = bcm->nodes[i];
73+
74+
/* If any vote in this bucket exists, keep the BCM enabled */
75+
if (node->sum_avg[bucket] || node->max_peak[bucket]) {
76+
bcm->vote_x[bucket] = 0;
77+
bcm->vote_y[bucket] = bcm->enable_mask;
78+
break;
79+
}
80+
}
81+
}
82+
83+
if (bcm->keepalive) {
84+
bcm->vote_x[QCOM_ICC_BUCKET_AMC] = 1;
85+
bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = 1;
86+
bcm->vote_y[QCOM_ICC_BUCKET_AMC] = 1;
87+
bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = 1;
88+
}
89+
}
90+
6191
static void bcm_aggregate(struct qcom_icc_bcm *bcm)
6292
{
6393
struct qcom_icc_node *node;
@@ -83,11 +113,6 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)
83113

84114
temp = agg_peak[bucket] * bcm->vote_scale;
85115
bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
86-
87-
if (bcm->enable_mask && (bcm->vote_x[bucket] || bcm->vote_y[bucket])) {
88-
bcm->vote_x[bucket] = 0;
89-
bcm->vote_y[bucket] = bcm->enable_mask;
90-
}
91116
}
92117

93118
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)
260285
return 0;
261286

262287
mutex_lock(&voter->lock);
263-
list_for_each_entry(bcm, &voter->commit_list, list)
264-
bcm_aggregate(bcm);
288+
list_for_each_entry(bcm, &voter->commit_list, list) {
289+
if (bcm->enable_mask)
290+
bcm_aggregate_mask(bcm);
291+
else
292+
bcm_aggregate(bcm);
293+
}
265294

266295
/*
267296
* Pre sort the BCMs based on VCD for ease of generating a command list

0 commit comments

Comments
 (0)