mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: iris: fix 64-bit division in iris_set_slice_count()
@ 2026-10-02  7:44 ` Sachin Kumar Garg
  2026-10-02  8:52   ` Bryan O'Donoghue
  0 siblings, 1 reply; 4+ messages in thread
From: Sachin Kumar Garg @ 2026-10-02  7:44 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel, kernel test robot,
	Sachin Kumar Garg

inst->fw_caps[BITRATE].value is an s64, so dividing it by the frame
rate is a 64-bit division. On 32-bit architectures the compiler turns
this into a call to the libgcc helper __divdi3, which the kernel does
not provide, so the module fails to link.

The bitrate always fits in a u32, so copy it into a u32 local before
dividing, as iris_set_peak_bitrate() already does.

Fixes: 9abcab03dbf8 ("media: iris: add support for multi_slice in iris encoder")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202610020426.oUzBZ3mH-lkp@intel.com/

Signed-off-by: Sachin Kumar Garg <sachin.garg@oss.qualcomm.com>
---
The original commit is 5f21cd9a4ae4 in next-20261001 and is
9abcab03dbf8 in the current venus-iris-next branch.
---
 drivers/media/platform/qcom/iris/iris_ctrls.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
index 8c4c47944f22..06d99b18310b 100644
--- a/drivers/media/platform/qcom/iris/iris_ctrls.c
+++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
@@ -1548,6 +1548,7 @@ int iris_set_slice_count(struct iris_inst *inst, enum platform_inst_fw_cap_type
 	u32 mbpf = NUM_MBS_PER_FRAME(output_height, output_width);
 	u32 max_width, max_height, min_width, min_height;
 	u32 slice_mode = inst->fw_caps[cap_id].value;
+	u32 bitrate = inst->fw_caps[BITRATE].value;
 	u32 max_avg_slicesize, hfi_value, hfi_id;
 	u32 rc_type = inst->hfi_rc_type;
 	u32 fps = inst->frame_rate;
@@ -1588,7 +1589,7 @@ 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,
+			max_avg_slicesize = DIV_ROUND_UP((bitrate / fps) / 8,
 							 slice_caps->max_slices_per_frame);
 		} else {
 			/*

---
base-commit: 9abcab03dbf81439e18d09f1f3869bc39290ce4d
change-id: 20261002-iris-fix-divdi3-44b1974118d8

Best regards,
-- 
Sachin Kumar Garg <sachin.garg@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: iris: fix 64-bit division in iris_set_slice_count()
  2026-10-02  7:44 ` [PATCH] media: iris: fix 64-bit division in iris_set_slice_count() Sachin Kumar Garg
@ 2026-10-02  8:52   ` Bryan O'Donoghue
  0 siblings, 0 replies; 4+ messages in thread
From: Bryan O'Donoghue @ 2026-10-02  8:52 UTC (permalink / raw)
  To: Sachin Kumar Garg, Vikash Garodia, Dikshita Agarwal,
	Abhinav Kumar, Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, linux-kernel, kernel test robot

On 02/10/2026 08:44, Sachin Kumar Garg wrote:
> inst->fw_caps[BITRATE].value is an s64, so dividing it by the frame
> rate is a 64-bit division. On 32-bit architectures the compiler turns
> this into a call to the libgcc helper __divdi3, which the kernel does
> not provide, so the module fails to link.
> 
> The bitrate always fits in a u32, so copy it into a u32 local before
> dividing, as iris_set_peak_bitrate() already does.
> 
> Fixes: 9abcab03dbf8 ("media: iris: add support for multi_slice in iris encoder")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202610020426.oUzBZ3mH-lkp@intel.com/
> 
> Signed-off-by: Sachin Kumar Garg <sachin.garg@oss.qualcomm.com>
> ---
> The original commit is 5f21cd9a4ae4 in next-20261001 and is
> 9abcab03dbf8 in the current venus-iris-next branch.
> ---
>   drivers/media/platform/qcom/iris/iris_ctrls.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
> index 8c4c47944f22..06d99b18310b 100644
> --- a/drivers/media/platform/qcom/iris/iris_ctrls.c
> +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
> @@ -1548,6 +1548,7 @@ int iris_set_slice_count(struct iris_inst *inst, enum platform_inst_fw_cap_type
>   	u32 mbpf = NUM_MBS_PER_FRAME(output_height, output_width);
>   	u32 max_width, max_height, min_width, min_height;
>   	u32 slice_mode = inst->fw_caps[cap_id].value;
> +	u32 bitrate = inst->fw_caps[BITRATE].value;
>   	u32 max_avg_slicesize, hfi_value, hfi_id;
>   	u32 rc_type = inst->hfi_rc_type;
>   	u32 fps = inst->frame_rate;
> @@ -1588,7 +1589,7 @@ 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,
> +			max_avg_slicesize = DIV_ROUND_UP((bitrate / fps) / 8,
>   							 slice_caps->max_slices_per_frame);
>   		} else {
>   			/*
> 
> ---
> base-commit: 9abcab03dbf81439e18d09f1f3869bc39290ce4d
> change-id: 20261002-iris-fix-divdi3-44b1974118d8
> 
> Best regards,
> --
> Sachin Kumar Garg <sachin.garg@oss.qualcomm.com>
> 

20261001004619.2230849-1-sashal@kernel.org

Already queued.

---
bod

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: iris: fix 64-bit division in iris_set_slice_count()
  2026-10-01  0:46 ` Sasha Levin
@ 2026-10-01  0:49   ` Bryan O'Donoghue
  0 siblings, 0 replies; 4+ messages in thread
From: Bryan O'Donoghue @ 2026-10-01  0:49 UTC (permalink / raw)
  To: Sasha Levin, Vikash Garodia, Dikshita Agarwal,
	Mauro Carvalho Chehab, Sachin Kumar Garg
  Cc: kernelci.org bot, Abhinav Kumar, linux-media, linux-arm-msm,
	linux-kernel

On 01/10/2026 01:46, Sasha Levin wrote:
> 32-bit ARM builds fail at modpost:
> 
>    ERROR: modpost: drivers/media/platform/qcom/iris/qcom-iris.ko:
>    symbol '__aeabi_ldivmod' undefined!
> 
> The maximum average slice size in MAX_BYTES mode is derived from the
> BITRATE capability, whose value is an s64, so both the division by
> the frame rate and the DIV_ROUND_UP() by the number of slices are
> 64-bit divisions. 32-bit ARM has no instruction for these and the
> compiler emits calls to __aeabi_ldivmod(), which the kernel does not
> provide.
> 
> The bitrate is always positive, so use div_u64() for the division by
> the frame rate and DIV_ROUND_UP_ULL() for the rounding. Include
> <linux/math64.h> for div_u64() instead of relying on it being pulled
> in indirectly.
> 
> Reported-by: kernelci.org bot <bot@kernelci.org>
> Closes: https://d.kernelci.org/i/maestro:4935f1aae20e7f957e60f8fde09c4e6d153c7909
> Fixes: 5f21cd9a4ae4 ("media: iris: add support for multi_slice in iris encoder")
> Assisted-by: LLM
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>   drivers/media/platform/qcom/iris/iris_ctrls.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
> index 8c4c47944f22f..4f2633bbb49f8 100644
> --- a/drivers/media/platform/qcom/iris/iris_ctrls.c
> +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
> @@ -3,6 +3,7 @@
>    * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
>    */
> 
> +#include <linux/math64.h>
>   #include <linux/types.h>
>   #include <media/v4l2-mem2mem.h>
> 
> @@ -1588,8 +1589,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_ROUND_UP_ULL(div_u64(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
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] media: iris: fix 64-bit division in iris_set_slice_count()
@ 2026-10-01  0:46 ` Sasha Levin
  2026-10-01  0:49   ` Bryan O'Donoghue
  0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2026-10-01  0:46 UTC (permalink / raw)
  To: Vikash Garodia, Dikshita Agarwal, Bryan O'Donoghue,
	Mauro Carvalho Chehab, Sachin Kumar Garg
  Cc: Sasha Levin, kernelci.org bot, Abhinav Kumar, linux-media,
	linux-arm-msm, linux-kernel

32-bit ARM builds fail at modpost:

  ERROR: modpost: drivers/media/platform/qcom/iris/qcom-iris.ko:
  symbol '__aeabi_ldivmod' undefined!

The maximum average slice size in MAX_BYTES mode is derived from the
BITRATE capability, whose value is an s64, so both the division by
the frame rate and the DIV_ROUND_UP() by the number of slices are
64-bit divisions. 32-bit ARM has no instruction for these and the
compiler emits calls to __aeabi_ldivmod(), which the kernel does not
provide.

The bitrate is always positive, so use div_u64() for the division by
the frame rate and DIV_ROUND_UP_ULL() for the rounding. Include
<linux/math64.h> for div_u64() instead of relying on it being pulled
in indirectly.

Reported-by: kernelci.org bot <bot@kernelci.org>
Closes: https://d.kernelci.org/i/maestro:4935f1aae20e7f957e60f8fde09c4e6d153c7909
Fixes: 5f21cd9a4ae4 ("media: iris: add support for multi_slice in iris encoder")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/platform/qcom/iris/iris_ctrls.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
index 8c4c47944f22f..4f2633bbb49f8 100644
--- a/drivers/media/platform/qcom/iris/iris_ctrls.c
+++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
+#include <linux/math64.h>
 #include <linux/types.h>
 #include <media/v4l2-mem2mem.h>
 
@@ -1588,8 +1589,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_ROUND_UP_ULL(div_u64(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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-02  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AgJq_ESuBnuRTD-nBYJ68Y7_6aBNuPB2wIzsm4CsQ7fkkkz1ZwjSkUsF8qior3pVbYSS26UV9MGkVBy0Nfu0cA==@protonmail.internalid>
2026-10-02  7:44 ` [PATCH] media: iris: fix 64-bit division in iris_set_slice_count() Sachin Kumar Garg
2026-10-02  8:52   ` Bryan O'Donoghue
     [not found] <WGjCcYNrTTl1nX0egc4fFtnjES8VeY1nYXm4v7kHVBNOSkChhctiUs2iU0KupHeUVt5uzgS6b3Re1MNJNK9riQ==@protonmail.internalid>
2026-10-01  0:46 ` Sasha Levin
2026-10-01  0:49   ` Bryan O'Donoghue

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®