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

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/113b50f8-35f6-73fc-4fc9-302262927c5e@quicinc.com/

Link: https://lore.kernel.org/r/20230811-topic-icc_fix_1he-v2-0-0620af8ac133@linaro.org
Signed-off-by: Georgi Djakov <djakov@kernel.org>

+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] = 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 + 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