Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <quic_bjorande@quicinc.com>
Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230811-topic-icc_fix_1he-v2-1-0620af8ac133@linaro.org
Signed-off-by: Georgi Djakov <djakov@kernel.org>

authored by

Konrad Dybcio and committed by
Georgi Djakov
a1f4170d 2ccdd1b1

+36 -7
+36 -7
drivers/interconnect/qcom/bcm-voter.c
··· 58 58 return num; 59 59 } 60 60 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 + 61 91 static void bcm_aggregate(struct qcom_icc_bcm *bcm) 62 92 { 63 93 struct qcom_icc_node *node; ··· 113 83 114 84 temp = agg_peak[bucket] * bcm->vote_scale; 115 85 bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit); 116 - 117 - if (bcm->enable_mask && (bcm->vote_x[bucket] || bcm->vote_y[bucket])) { 118 - bcm->vote_x[bucket] = 0; 119 - bcm->vote_y[bucket] = bcm->enable_mask; 120 - } 121 86 } 122 87 123 88 if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 && ··· 285 260 return 0; 286 261 287 262 mutex_lock(&voter->lock); 288 - list_for_each_entry(bcm, &voter->commit_list, list) 289 - bcm_aggregate(bcm); 263 + list_for_each_entry(bcm, &voter->commit_list, list) { 264 + if (bcm->enable_mask) 265 + bcm_aggregate_mask(bcm); 266 + else 267 + bcm_aggregate(bcm); 268 + } 290 269 291 270 /* 292 271 * Pre sort the BCMs based on VCD for ease of generating a command list