Skip to content

Commit e0d855b

Browse files
author
Georgi Djakov
committed
Merge branch 'icc-enable-mask' into icc-next
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/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Georgi Djakov <[email protected]>
2 parents 1361917 + 1a70ca7 commit e0d855b

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] = bcm->enable_mask;
85+
bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = bcm->enable_mask;
86+
bcm->vote_y[QCOM_ICC_BUCKET_AMC] = bcm->enable_mask;
87+
bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = bcm->enable_mask;
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)