interconnect: qcom: fix endian annotations of BCM aux data
Subsystems (2)
PATCH v2 1/1 interconnect: qcom: fix endian annotations of BCM aux data
struct qcom_icc_bcm::aux_data keeps a copy of the struct bcm_db read from the command db, whose unit and width fields are annotated as __le32/__le16 to describe the little-endian on-disk format. Using those restricted types directly in bandwidth calculations makes sparse complain about endianness.
Keep aux_data typed as struct bcm_db, copied verbatim from the command db buffer, and convert the fields with le32_to_cpu()/le16_to_cpu() at the places where unit and width are used. No functional change.
Fixes c96fc14322ce ("interconnect: qcom: add COMPILE_TEST")
Reported-by kernel test robot <[email protected]>
Assisted-by LLM
Signed-off-by Rosen Penev <[email protected]>
---
v2: don't use a separate struct
drivers/interconnect/qcom/bcm-voter.c | 8 ++++---- drivers/interconnect/qcom/icc-rpmh.c | 13 +++++-------- 2 files changed, 9 insertions(+), 12 deletions(-)
drivers/interconnect/qcom/bcm-voter.c +4 -4
@@ -88,20 +88,20 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)for (bucket =0 ; bucket <QCOM_ICC_NUM_BUCKETS ; bucket++) {for (i =0 ; i < bcm->num_nodes; i++) { node = bcm->nodes[i]; - temp =qcom_bw_div (node->sum_avg[bucket] * bcm->aux_data.width, + temp =qcom_bw_div (node->sum_avg[bucket] *le16_to_cpu (bcm->aux_data.width), node->buswidth * node->channels); agg_avg[bucket] =max (agg_avg[bucket], temp); - temp =qcom_bw_div (node->max_peak[bucket] * bcm->aux_data.width, + temp =qcom_bw_div (node->max_peak[bucket] *le16_to_cpu (bcm->aux_data.width), node->buswidth); agg_peak[bucket] =max (agg_peak[bucket], temp); } temp = agg_avg[bucket] * bcm->vote_scale; - bcm->vote_x[bucket] =qcom_bw_div (temp, bcm->aux_data.unit); + bcm->vote_x[bucket] =qcom_bw_div (temp,le32_to_cpu (bcm->aux_data.unit)); temp = agg_peak[bucket] * bcm->vote_scale; - bcm->vote_y[bucket] =qcom_bw_div (temp, bcm->aux_data.unit); + bcm->vote_y[bucket] =qcom_bw_div (temp,le32_to_cpu (bcm->aux_data.unit)); } if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&
drivers/interconnect/qcom/icc-rpmh.c +5 -8
@@ -166,19 +166,19 @@ static int qcom_icc_get_bw(struct icc_node *node, u32 *avg, u32 *peak) peak_max =INT_MAX ; }else {if (x) { - x *= bcm->aux_data.unit; + x *=le32_to_cpu (bcm->aux_data.unit);do_div (x, bcm->vote_scale); x *= qn->buswidth * qn->channels; -do_div (x, bcm->aux_data.width); +do_div (x,le16_to_cpu (bcm->aux_data.width)); avg_max =max (avg_max, x); }if (y) { - y *= bcm->aux_data.unit; + y *=le32_to_cpu (bcm->aux_data.unit);do_div (y, bcm->vote_scale); y *= qn->buswidth; -do_div (y, bcm->aux_data.width); +do_div (y,le16_to_cpu (bcm->aux_data.width)); peak_max =max (peak_max, y); }
@@ -228,10 +228,7 @@ int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev)return -EINVAL ; } - bcm->aux_data.unit =le32_to_cpu (data->unit); - bcm->aux_data.width =le16_to_cpu (data->width); - bcm->aux_data.vcd = data->vcd; - bcm->aux_data.reserved = data->reserved; + bcm->aux_data = *data;INIT_LIST_HEAD (&bcm->list);INIT_LIST_HEAD (&bcm->ws_list);
Signature · 1 line
2.55.0