From: Arnd Bergmann <arnd@kernel.org>
To: Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
"Bryan O'Donoghue" <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sachin Kumar Garg <sachin.garg@oss.qualcomm.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Wangao Wang <wangao.wang@oss.qualcomm.com>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Deepa Guthyappa Madivalara <deepa.madivalara@oss.qualcomm.com>,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] media: iris: avoid plain 64-bit division
Date: Fri, 2 Oct 2026 14:44:22 +0200 [thread overview]
Message-ID: <20261002124435.3435628-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
inst->fw_caps[BITRATE].value is a 64-bit integer, which on 32-bit
architectures cannot be divided:
ERROR: modpost: drivers/media/platform/qcom/iris/qcom-iris.ko: symbol '__divdi3' undefined!
In particular, doing three divisions in a row is particularly slow,
even on 64-bit CPUs.
Rework the calculation to replace it with a single division, thus
avoiding the build failure.
Fixes: 5f21cd9a4ae4 ("media: iris: add support for multi_slice in iris encoder")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Please check the math, as I'm not sure if this is the intended
amount of rounding. Previously it was rounding down twice and up
once, now it just rounds up during the combined division.
Ideally this would be replaced with a cast of the incoming value
to u32, but doing this requires to prove that this does not overflow.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/media/platform/qcom/iris/iris_ctrls.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
index 8c4c47944f22..5294999fdf7b 100644
--- a/drivers/media/platform/qcom/iris/iris_ctrls.c
+++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
@@ -1588,8 +1588,9 @@ int iris_set_slice_count(struct iris_inst *inst, enum platform_inst_fw_cap_type
} else if (slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_BYTES) {
hfi_value = inst->fw_caps[SLICE_MAX_BYTES].value;
if (rc_type != HFI_RC_OFF) {
- max_avg_slicesize = DIV_ROUND_UP((inst->fw_caps[BITRATE].value / fps) / 8,
- slice_caps->max_slices_per_frame);
+ max_avg_slicesize = DIV_U64_ROUND_UP(inst->fw_caps[BITRATE].value,
+ fps * 8 *
+ slice_caps->max_slices_per_frame);
} else {
/*
* No bitrate target exists under RC_OFF, so approximate a
--
2.53.0
next reply other threads:[~2026-10-02 12:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 12:44 Arnd Bergmann [this message]
2026-10-03 17:37 ` David Laight
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=20261002124435.3435628-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=abhinav.kumar@linux.dev \
--cc=arnd@arndb.de \
--cc=bod@kernel.org \
--cc=deepa.madivalara@oss.qualcomm.com \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sachin.garg@oss.qualcomm.com \
--cc=vikash.garodia@oss.qualcomm.com \
--cc=wangao.wang@oss.qualcomm.com \
/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®