From: Rosen Penev <rosenp@gmail.com>
To: linux-pm@vger.kernel.org
Cc: Georgi Djakov <djakov@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Rosen Penev <rosenp@gmail.com>,
linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM MAILING
LIST), linux-kernel@vger.kernel.org (open list)
Subject: [PATCHv2] interconnect: qcom: fix endian annotations of BCM aux data
Date: Wed, 23 Sep 2026 11:50:59 -0700 [thread overview]
Message-ID: <20260923185059.25196-1-rosenp@gmail.com> (raw)
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 <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202609221350.3Y8MOce9-lkp@intel.com/
Assisted-by: LLM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
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(-)
diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
index 6c7e9a7c17e2..0880a287b0c0 100644
--- a/drivers/interconnect/qcom/bcm-voter.c
+++ b/drivers/interconnect/qcom/bcm-voter.c
@@ -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 &&
diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c
index 7f2b5673629b..45662d1a2060 100644
--- a/drivers/interconnect/qcom/icc-rpmh.c
+++ b/drivers/interconnect/qcom/icc-rpmh.c
@@ -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);
--
2.55.0
reply other threads:[~2026-09-23 18:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923185059.25196-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=djakov@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®