Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH 0/3] media: Fix CI warnings for 6.19
@ 2025-12-03  8:55 Ricardo Ribalda
  2025-12-03  8:55 ` [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning Ricardo Ribalda
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ricardo Ribalda @ 2025-12-03  8:55 UTC (permalink / raw)
  To: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, linux-kernel, linux-arm-msm,
	Ricardo Ribalda, Stephen Rothwell, stable

New kernel version, new warnings.

This series only introduces a new patch:
media: iris: Document difference in size during allocation

The other two have been already sent to linux-media or linux-next ML,
but they have not found their way into the tree.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Jacopo Mondi (1):
      media: uapi: c3-isp: Fix documentation warning

Ricardo Ribalda (2):
      media: iris: Document difference in size during allocation
      media: iris: Fix fps calculation

 drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 10 +++++++++-
 drivers/media/platform/qcom/iris/iris_venc.c             |  5 ++---
 include/uapi/linux/media/amlogic/c3-isp-config.h         |  2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)
---
base-commit: 47b7b5e32bb7264b51b89186043e1ada4090b558
change-id: 20251202-warnings-6-19-960d9b686cff

Best regards,
-- 
Ricardo Ribalda <ribalda@chromium.org>


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

* [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning
  2025-12-03  8:55 [PATCH 0/3] media: Fix CI warnings for 6.19 Ricardo Ribalda
@ 2025-12-03  8:55 ` Ricardo Ribalda
  2025-12-03  9:13   ` Mauro Carvalho Chehab
  2025-12-03  8:55 ` [PATCH 2/3] media: iris: Document difference in size during allocation Ricardo Ribalda
  2025-12-03  8:55 ` [PATCH 3/3] media: iris: Fix fps calculation Ricardo Ribalda
  2 siblings, 1 reply; 9+ messages in thread
From: Ricardo Ribalda @ 2025-12-03  8:55 UTC (permalink / raw)
  To: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, linux-kernel, linux-arm-msm,
	Ricardo Ribalda, Stephen Rothwell, stable

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Building htmldocs generates a warning:

WARNING: include/uapi/linux/media/amlogic/c3-isp-config.h:199
error: Cannot parse struct or union!

Which correctly highlights that the c3_isp_params_block_header symbol
is wrongly documented as a struct while it's a plain #define instead.

Fix this by removing the 'struct' identifier from the documentation of
the c3_isp_params_block_header symbol.

[ribalda: Add Closes:]

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/all/20251127131425.4b5b6644@canb.auug.org.au/
Fixes: 45662082855c ("media: uapi: Convert Amlogic C3 to V4L2 extensible params")
Cc: stable@vger.kernel.org
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 include/uapi/linux/media/amlogic/c3-isp-config.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/media/amlogic/c3-isp-config.h b/include/uapi/linux/media/amlogic/c3-isp-config.h
index 0a3c1cc55ccbbad12f18037d65f32ec9ca1a4ec0..92db5dcdda181cb31665e230cc56b443fa37a0be 100644
--- a/include/uapi/linux/media/amlogic/c3-isp-config.h
+++ b/include/uapi/linux/media/amlogic/c3-isp-config.h
@@ -186,7 +186,7 @@ enum c3_isp_params_block_type {
 #define C3_ISP_PARAMS_BLOCK_FL_ENABLE	V4L2_ISP_PARAMS_FL_BLOCK_ENABLE
 
 /**
- * struct c3_isp_params_block_header - C3 ISP parameter block header
+ * c3_isp_params_block_header - C3 ISP parameter block header
  *
  * This structure represents the common part of all the ISP configuration
  * blocks and is identical to :c:type:`v4l2_isp_params_block_header`.

-- 
2.52.0.158.g65b55ccf14-goog


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

* [PATCH 2/3] media: iris: Document difference in size during allocation
  2025-12-03  8:55 [PATCH 0/3] media: Fix CI warnings for 6.19 Ricardo Ribalda
  2025-12-03  8:55 ` [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning Ricardo Ribalda
@ 2025-12-03  8:55 ` Ricardo Ribalda
  2025-12-03  9:16   ` Laurent Pinchart
  2025-12-03  8:55 ` [PATCH 3/3] media: iris: Fix fps calculation Ricardo Ribalda
  2 siblings, 1 reply; 9+ messages in thread
From: Ricardo Ribalda @ 2025-12-03  8:55 UTC (permalink / raw)
  To: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, linux-kernel, linux-arm-msm,
	Ricardo Ribalda

As we get ready for kzalloc checking for invalid sizes, let's add
documentation for the cases where the size is different but valid.

This patch fixes this cocci warning:
./platform/qcom/iris/iris_hfi_gen2_command.c:1215:9-25: WARNING: casting value returned by memory allocation function to (struct iris_inst *) is useless.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
index f9129553209922fda548ca320494ae6ae797854c..ab91afd0597045bd876d0411b08b5a3421b12c70 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
@@ -1212,5 +1212,13 @@ void iris_hfi_gen2_command_ops_init(struct iris_core *core)
 
 struct iris_inst *iris_hfi_gen2_get_instance(void)
 {
-	return (struct iris_inst *)kzalloc(sizeof(struct iris_inst_hfi_gen2), GFP_KERNEL);
+	struct iris_inst_hfi_gen2 *out;
+
+	/*
+	 * The allocation is intentionally larger. The first member of
+	 * struct iris_hfi_gen2 is struct iris_inst.
+	 */
+	out = kzalloc(sizeof(*out), GFP_KERNEL);
+
+	return (struct iris_inst *)out;
 }

-- 
2.52.0.158.g65b55ccf14-goog


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

* [PATCH 3/3] media: iris: Fix fps calculation
  2025-12-03  8:55 [PATCH 0/3] media: Fix CI warnings for 6.19 Ricardo Ribalda
  2025-12-03  8:55 ` [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning Ricardo Ribalda
  2025-12-03  8:55 ` [PATCH 2/3] media: iris: Document difference in size during allocation Ricardo Ribalda
@ 2025-12-03  8:55 ` Ricardo Ribalda
  2025-12-06  4:06   ` Dmitry Baryshkov
  2 siblings, 1 reply; 9+ messages in thread
From: Ricardo Ribalda @ 2025-12-03  8:55 UTC (permalink / raw)
  To: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, linux-kernel, linux-arm-msm,
	Ricardo Ribalda

iris_venc_s_param() uses do_div to divide two 64 bits operators, this is
wrong. Luckily for us, both of the operators fit in 32 bits, so we can use
a normal division.

Now that we are at it, mark the fps smaller than 1 as invalid, the code
does not seem to handle them properly.

The following cocci warning is fixed with this patch:
./platform/qcom/iris/iris_venc.c:378:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead

Fixes: 4ff586ff28e3 ("media: iris: Add support for G/S_PARM for encoder video device")
Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/qcom/iris/iris_venc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/platform/qcom/iris/iris_venc.c
index 5830eba93c68b27fa9db87bac63a691eaca338d2..730f2aa1a83b2f4f90227ab9a7e04aee7c2c3cfe 100644
--- a/drivers/media/platform/qcom/iris/iris_venc.c
+++ b/drivers/media/platform/qcom/iris/iris_venc.c
@@ -408,11 +408,10 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm)
 	us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC;
 	do_div(us_per_frame, timeperframe->denominator);
 
-	if (!us_per_frame)
+	if (!us_per_frame || us_per_frame > USEC_PER_SEC)
 		return -EINVAL;
 
-	fps = (u64)USEC_PER_SEC;
-	do_div(fps, us_per_frame);
+	fps = USEC_PER_SEC / (u32)us_per_frame;
 	if (fps > max_rate) {
 		ret = -ENOMEM;
 		goto reset_rate;

-- 
2.52.0.158.g65b55ccf14-goog


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

* Re: [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning
  2025-12-03  8:55 ` [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning Ricardo Ribalda
@ 2025-12-03  9:13   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2025-12-03  9:13 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Sakari Ailus,
	linux-media, linux-kernel, linux-arm-msm, Stephen Rothwell,
	stable

Em Wed, 03 Dec 2025 08:55:34 +0000
Ricardo Ribalda <ribalda@chromium.org> escreveu:

> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> 
> Building htmldocs generates a warning:
> 
> WARNING: include/uapi/linux/media/amlogic/c3-isp-config.h:199
> error: Cannot parse struct or union!
> 
> Which correctly highlights that the c3_isp_params_block_header symbol
> is wrongly documented as a struct while it's a plain #define instead.
> 
> Fix this by removing the 'struct' identifier from the documentation of
> the c3_isp_params_block_header symbol.
> 
> [ribalda: Add Closes:]
> 
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Closes: https://lore.kernel.org/all/20251127131425.4b5b6644@canb.auug.org.au/
> Fixes: 45662082855c ("media: uapi: Convert Amlogic C3 to V4L2 extensible params")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  include/uapi/linux/media/amlogic/c3-isp-config.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/media/amlogic/c3-isp-config.h b/include/uapi/linux/media/amlogic/c3-isp-config.h
> index 0a3c1cc55ccbbad12f18037d65f32ec9ca1a4ec0..92db5dcdda181cb31665e230cc56b443fa37a0be 100644
> --- a/include/uapi/linux/media/amlogic/c3-isp-config.h
> +++ b/include/uapi/linux/media/amlogic/c3-isp-config.h
> @@ -186,7 +186,7 @@ enum c3_isp_params_block_type {
>  #define C3_ISP_PARAMS_BLOCK_FL_ENABLE	V4L2_ISP_PARAMS_FL_BLOCK_ENABLE
>  
>  /**
> - * struct c3_isp_params_block_header - C3 ISP parameter block header
> + * c3_isp_params_block_header - C3 ISP parameter block header
>   *
>   * This structure represents the common part of all the ISP configuration
>   * blocks and is identical to :c:type:`v4l2_isp_params_block_header`.
> 

Just merged this one at media-committers next. 

My plan is to send later during the merge window, after the first
PR I sent upstream gets merged.

Regards,
Mauro

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

* Re: [PATCH 2/3] media: iris: Document difference in size during allocation
  2025-12-03  8:55 ` [PATCH 2/3] media: iris: Document difference in size during allocation Ricardo Ribalda
@ 2025-12-03  9:16   ` Laurent Pinchart
  2025-12-03 13:17     ` Ricardo Ribalda
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Pinchart @ 2025-12-03  9:16 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Sakari Ailus,
	linux-media, linux-kernel, linux-arm-msm

On Wed, Dec 03, 2025 at 08:55:35AM +0000, Ricardo Ribalda wrote:
> As we get ready for kzalloc checking for invalid sizes, let's add
> documentation for the cases where the size is different but valid.
> 
> This patch fixes this cocci warning:
> ./platform/qcom/iris/iris_hfi_gen2_command.c:1215:9-25: WARNING: casting value returned by memory allocation function to (struct iris_inst *) is useless.
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> index f9129553209922fda548ca320494ae6ae797854c..ab91afd0597045bd876d0411b08b5a3421b12c70 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> @@ -1212,5 +1212,13 @@ void iris_hfi_gen2_command_ops_init(struct iris_core *core)
>  
>  struct iris_inst *iris_hfi_gen2_get_instance(void)
>  {
> -	return (struct iris_inst *)kzalloc(sizeof(struct iris_inst_hfi_gen2), GFP_KERNEL);
> +	struct iris_inst_hfi_gen2 *out;
> +
> +	/*
> +	 * The allocation is intentionally larger. The first member of
> +	 * struct iris_hfi_gen2 is struct iris_inst.
> +	 */
> +	out = kzalloc(sizeof(*out), GFP_KERNEL);
> +
> +	return (struct iris_inst *)out;

	return &out->inst;

would be more readable. You can then drop the comment.

>  }
> 

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 2/3] media: iris: Document difference in size during allocation
  2025-12-03  9:16   ` Laurent Pinchart
@ 2025-12-03 13:17     ` Ricardo Ribalda
  0 siblings, 0 replies; 9+ messages in thread
From: Ricardo Ribalda @ 2025-12-03 13:17 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Sakari Ailus,
	linux-media, linux-kernel, linux-arm-msm

Hi Laurent



On Wed, 3 Dec 2025 at 10:17, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> On Wed, Dec 03, 2025 at 08:55:35AM +0000, Ricardo Ribalda wrote:
> > As we get ready for kzalloc checking for invalid sizes, let's add
> > documentation for the cases where the size is different but valid.
> >
> > This patch fixes this cocci warning:
> > ./platform/qcom/iris/iris_hfi_gen2_command.c:1215:9-25: WARNING: casting value returned by memory allocation function to (struct iris_inst *) is useless.
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> >  drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> > index f9129553209922fda548ca320494ae6ae797854c..ab91afd0597045bd876d0411b08b5a3421b12c70 100644
> > --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> > +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> > @@ -1212,5 +1212,13 @@ void iris_hfi_gen2_command_ops_init(struct iris_core *core)
> >
> >  struct iris_inst *iris_hfi_gen2_get_instance(void)
> >  {
> > -     return (struct iris_inst *)kzalloc(sizeof(struct iris_inst_hfi_gen2), GFP_KERNEL);
> > +     struct iris_inst_hfi_gen2 *out;
> > +
> > +     /*
> > +      * The allocation is intentionally larger. The first member of
> > +      * struct iris_hfi_gen2 is struct iris_inst.
> > +      */
> > +     out = kzalloc(sizeof(*out), GFP_KERNEL);
> > +
> > +     return (struct iris_inst *)out;
>
>         return &out->inst;
>
> would be more readable. You can then drop the comment.

It looks better, and it is more robust. Thanks

I prefer to leave a small comment though:

+       struct iris_inst_hfi_gen2 *out;
+
+       /* The allocation is intentionally larger than struct iris_inst. */
+       out = kzalloc(sizeof(*out), GFP_KERNEL);
+
+       return &out->inst;


Regards

>
> >  }
> >
>
> --
> Regards,
>
> Laurent Pinchart



-- 
Ricardo Ribalda

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

* Re: [PATCH 3/3] media: iris: Fix fps calculation
  2025-12-03  8:55 ` [PATCH 3/3] media: iris: Fix fps calculation Ricardo Ribalda
@ 2025-12-06  4:06   ` Dmitry Baryshkov
  2025-12-10  7:23     ` Ricardo Ribalda
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-12-06  4:06 UTC (permalink / raw)
  To: Ricardo Ribalda
  Cc: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Sakari Ailus,
	linux-media, linux-kernel, linux-arm-msm

On Wed, Dec 03, 2025 at 08:55:36AM +0000, Ricardo Ribalda wrote:
> iris_venc_s_param() uses do_div to divide two 64 bits operators, this is
> wrong. Luckily for us, both of the operators fit in 32 bits, so we can use
> a normal division.
> 
> Now that we are at it, mark the fps smaller than 1 as invalid, the code
> does not seem to handle them properly.
> 
> The following cocci warning is fixed with this patch:
> ./platform/qcom/iris/iris_venc.c:378:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead
> 
> Fixes: 4ff586ff28e3 ("media: iris: Add support for G/S_PARM for encoder video device")
> Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/platform/qcom/iris/iris_venc.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/platform/qcom/iris/iris_venc.c
> index 5830eba93c68b27fa9db87bac63a691eaca338d2..730f2aa1a83b2f4f90227ab9a7e04aee7c2c3cfe 100644
> --- a/drivers/media/platform/qcom/iris/iris_venc.c
> +++ b/drivers/media/platform/qcom/iris/iris_venc.c
> @@ -408,11 +408,10 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm)
>  	us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC;
>  	do_div(us_per_frame, timeperframe->denominator);
>  
> -	if (!us_per_frame)
> +	if (!us_per_frame || us_per_frame > USEC_PER_SEC)
>  		return -EINVAL;
>  
> -	fps = (u64)USEC_PER_SEC;
> -	do_div(fps, us_per_frame);
> +	fps = USEC_PER_SEC / (u32)us_per_frame;

Can we replace this with:

fps = timeperframe->denominator / timeperframe->numerator ?

>  	if (fps > max_rate) {
>  		ret = -ENOMEM;
>  		goto reset_rate;
> 
> -- 
> 2.52.0.158.g65b55ccf14-goog
> 

-- 
With best wishes
Dmitry

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

* Re: [PATCH 3/3] media: iris: Fix fps calculation
  2025-12-06  4:06   ` Dmitry Baryshkov
@ 2025-12-10  7:23     ` Ricardo Ribalda
  0 siblings, 0 replies; 9+ messages in thread
From: Ricardo Ribalda @ 2025-12-10  7:23 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Keke Li, Jacopo Mondi, Daniel Scally, Hans Verkuil,
	Laurent Pinchart, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Mauro Carvalho Chehab, Sakari Ailus,
	linux-media, linux-kernel, linux-arm-msm

On Sat, 6 Dec 2025 at 13:06, Dmitry Baryshkov
<dmitry.baryshkov@oss.qualcomm.com> wrote:
>
> On Wed, Dec 03, 2025 at 08:55:36AM +0000, Ricardo Ribalda wrote:
> > iris_venc_s_param() uses do_div to divide two 64 bits operators, this is
> > wrong. Luckily for us, both of the operators fit in 32 bits, so we can use
> > a normal division.
> >
> > Now that we are at it, mark the fps smaller than 1 as invalid, the code
> > does not seem to handle them properly.
> >
> > The following cocci warning is fixed with this patch:
> > ./platform/qcom/iris/iris_venc.c:378:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead
> >
> > Fixes: 4ff586ff28e3 ("media: iris: Add support for G/S_PARM for encoder video device")
> > Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> >  drivers/media/platform/qcom/iris/iris_venc.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/platform/qcom/iris/iris_venc.c
> > index 5830eba93c68b27fa9db87bac63a691eaca338d2..730f2aa1a83b2f4f90227ab9a7e04aee7c2c3cfe 100644
> > --- a/drivers/media/platform/qcom/iris/iris_venc.c
> > +++ b/drivers/media/platform/qcom/iris/iris_venc.c
> > @@ -408,11 +408,10 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm)
> >       us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC;
> >       do_div(us_per_frame, timeperframe->denominator);
> >
> > -     if (!us_per_frame)
> > +     if (!us_per_frame || us_per_frame > USEC_PER_SEC)
> >               return -EINVAL;
> >
> > -     fps = (u64)USEC_PER_SEC;
> > -     do_div(fps, us_per_frame);
> > +     fps = USEC_PER_SEC / (u32)us_per_frame;
>
> Can we replace this with:
>
> fps = timeperframe->denominator / timeperframe->numerator ?

Yep, I believe you are correct

I will send a new version soon.

>
> >       if (fps > max_rate) {
> >               ret = -ENOMEM;
> >               goto reset_rate;
> >
> > --
> > 2.52.0.158.g65b55ccf14-goog
> >
>
> --
> With best wishes
> Dmitry



-- 
Ricardo Ribalda

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

end of thread, other threads:[~2025-12-10  7:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03  8:55 [PATCH 0/3] media: Fix CI warnings for 6.19 Ricardo Ribalda
2025-12-03  8:55 ` [PATCH 1/3] media: uapi: c3-isp: Fix documentation warning Ricardo Ribalda
2025-12-03  9:13   ` Mauro Carvalho Chehab
2025-12-03  8:55 ` [PATCH 2/3] media: iris: Document difference in size during allocation Ricardo Ribalda
2025-12-03  9:16   ` Laurent Pinchart
2025-12-03 13:17     ` Ricardo Ribalda
2025-12-03  8:55 ` [PATCH 3/3] media: iris: Fix fps calculation Ricardo Ribalda
2025-12-06  4:06   ` Dmitry Baryshkov
2025-12-10  7:23     ` Ricardo Ribalda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox