Skip to content

Commit

Permalink
Merge branch 'icc-enable-mask' into icc-next
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Georgi Djakov committed Aug 21, 2023
2 parents 1361917 + 1a70ca7 commit e0d855b
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions drivers/interconnect/qcom/bcm-voter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = 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;
}
}

static void bcm_aggregate(struct qcom_icc_bcm *bcm)
{
struct qcom_icc_node *node;
Expand All @@ -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 &&
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e0d855b

Please sign in to comment.