Skip to content

Commit 91e045b

Browse files
Mike TiptonGeorgi Djakov
authored andcommitted
interconnect: qcom: Fix small BW votes being truncated to zero
Small BW votes that translate to less than a single BCM unit are currently truncated to zero. Ensure that non-zero BW requests always result in at least a vote of 1 to BCM. Fixes: 976daac ("interconnect: qcom: Consolidate interconnect RPMh support") Signed-off-by: Mike Tipton <mdtipton@codeaurora.org> Link: https://lore.kernel.org/r/20200903192149.30385-2-mdtipton@codeaurora.org Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
1 parent b1910c6 commit 91e045b

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/interconnect/qcom/bcm-voter.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,42 @@ static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
5252
return 1;
5353
}
5454

55+
static u64 bcm_div(u64 num, u32 base)
56+
{
57+
/* Ensure that small votes aren't lost. */
58+
if (num && num < base)
59+
return 1;
60+
61+
do_div(num, base);
62+
63+
return num;
64+
}
65+
5566
static void bcm_aggregate(struct qcom_icc_bcm *bcm)
5667
{
68+
struct qcom_icc_node *node;
5769
size_t i, bucket;
5870
u64 agg_avg[QCOM_ICC_NUM_BUCKETS] = {0};
5971
u64 agg_peak[QCOM_ICC_NUM_BUCKETS] = {0};
6072
u64 temp;
6173

6274
for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
6375
for (i = 0; i < bcm->num_nodes; i++) {
64-
temp = bcm->nodes[i]->sum_avg[bucket] * bcm->aux_data.width;
65-
do_div(temp, bcm->nodes[i]->buswidth * bcm->nodes[i]->channels);
76+
node = bcm->nodes[i];
77+
temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,
78+
node->buswidth * node->channels);
6679
agg_avg[bucket] = max(agg_avg[bucket], temp);
6780

68-
temp = bcm->nodes[i]->max_peak[bucket] * bcm->aux_data.width;
69-
do_div(temp, bcm->nodes[i]->buswidth);
81+
temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,
82+
node->buswidth);
7083
agg_peak[bucket] = max(agg_peak[bucket], temp);
7184
}
7285

7386
temp = agg_avg[bucket] * 1000ULL;
74-
do_div(temp, bcm->aux_data.unit);
75-
bcm->vote_x[bucket] = temp;
87+
bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);
7688

7789
temp = agg_peak[bucket] * 1000ULL;
78-
do_div(temp, bcm->aux_data.unit);
79-
bcm->vote_y[bucket] = temp;
90+
bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
8091
}
8192

8293
if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&

0 commit comments

Comments
 (0)