Commit 91e045b9 authored by Mike Tipton's avatar Mike Tipton Committed by Georgi Djakov

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: 976daac4 ("interconnect: qcom: Consolidate interconnect RPMh support")
Signed-off-by: default avatarMike Tipton <mdtipton@codeaurora.org>
Link: https://lore.kernel.org/r/20200903192149.30385-2-mdtipton@codeaurora.orgSigned-off-by: default avatarGeorgi Djakov <georgi.djakov@linaro.org>
parent b1910c6b
...@@ -52,8 +52,20 @@ static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b) ...@@ -52,8 +52,20 @@ static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
return 1; return 1;
} }
static u64 bcm_div(u64 num, u32 base)
{
/* Ensure that small votes aren't lost. */
if (num && num < base)
return 1;
do_div(num, base);
return num;
}
static void bcm_aggregate(struct qcom_icc_bcm *bcm) static void bcm_aggregate(struct qcom_icc_bcm *bcm)
{ {
struct qcom_icc_node *node;
size_t i, bucket; size_t i, bucket;
u64 agg_avg[QCOM_ICC_NUM_BUCKETS] = {0}; u64 agg_avg[QCOM_ICC_NUM_BUCKETS] = {0};
u64 agg_peak[QCOM_ICC_NUM_BUCKETS] = {0}; u64 agg_peak[QCOM_ICC_NUM_BUCKETS] = {0};
...@@ -61,22 +73,21 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm) ...@@ -61,22 +73,21 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)
for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) { for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
for (i = 0; i < bcm->num_nodes; i++) { for (i = 0; i < bcm->num_nodes; i++) {
temp = bcm->nodes[i]->sum_avg[bucket] * bcm->aux_data.width; node = bcm->nodes[i];
do_div(temp, bcm->nodes[i]->buswidth * bcm->nodes[i]->channels); temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,
node->buswidth * node->channels);
agg_avg[bucket] = max(agg_avg[bucket], temp); agg_avg[bucket] = max(agg_avg[bucket], temp);
temp = bcm->nodes[i]->max_peak[bucket] * bcm->aux_data.width; temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,
do_div(temp, bcm->nodes[i]->buswidth); node->buswidth);
agg_peak[bucket] = max(agg_peak[bucket], temp); agg_peak[bucket] = max(agg_peak[bucket], temp);
} }
temp = agg_avg[bucket] * 1000ULL; temp = agg_avg[bucket] * 1000ULL;
do_div(temp, bcm->aux_data.unit); bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);
bcm->vote_x[bucket] = temp;
temp = agg_peak[bucket] * 1000ULL; temp = agg_peak[bucket] * 1000ULL;
do_div(temp, bcm->aux_data.unit); bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
bcm->vote_y[bucket] = temp;
} }
if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 && if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment