Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Ricardo Ribalda <ribalda@chromium.org>,
	Martin Tuma <martin.tuma@digiteqautomotive.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hugues Fruchet <hugues.fruchet@foss.st.com>,
	Alain Volmat <alain.volmat@foss.st.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Sowjanya Komatineni <skomatineni@nvidia.com>,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Sergey Kozlov <serjk@netup.ru>, Abylay Ospan <aospan@netup.ru>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Dmitry Osipenko <digetx@gmail.com>,
	Benjamin Mugnier <benjamin.mugnier@foss.st.com>,
	Sylvain Petinot <sylvain.petinot@foss.st.com>,
	Stanimir Varbanov <stanimir.k.varbanov@gmail.com>,
	Vikash Garodia <quic_vgarodia@quicinc.com>,
	Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev,
	linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit
Date: Mon, 6 Jan 2025 13:21:50 +0100	[thread overview]
Message-ID: <f11653a7-bc49-48cd-9cdb-1659147453e4@xs4all.nl> (raw)
In-Reply-To: <20240429-fix-cocci-v3-23-3c4865f5a4b0@chromium.org>

On 29/04/2024 17:05, Ricardo Ribalda wrote:
> Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit
> number. Make that explicit.
> 
> Found by cocci:
> drivers/media/platform/qcom/venus/vdec.c:488:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
> 
> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/platform/qcom/venus/vdec.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
> index 29130a9441e7..2b2874aedb2d 100644
> --- a/drivers/media/platform/qcom/venus/vdec.c
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -464,7 +464,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>  	struct venus_inst *inst = to_inst(file);
>  	struct v4l2_captureparm *cap = &a->parm.capture;
>  	struct v4l2_fract *timeperframe = &cap->timeperframe;
> -	u64 us_per_frame, fps;
> +	u64 us_per_frame;
>  
>  	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
>  	    a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> @@ -484,10 +484,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>  	if (!us_per_frame)
>  		return -EINVAL;
>  
> -	fps = (u64)USEC_PER_SEC;
> -	do_div(fps, us_per_frame);
> -
> -	inst->fps = fps;
> +	inst->fps = USEC_PER_SEC / (u32)us_per_frame;

What happens if us_per_frame > USEC_PER_SEC? inst->fps is now 0, and I wonder what
issues that may cause.

I will drop this patch from the PR, as it is probably wise to return an error if
us_per_frame > USEC_PER_SEC.

The same issue is present with the venc patch (24/26), but that wasn't included in
the PR anyway.

Regards,

	Hans

>  	inst->timeperframe = *timeperframe;
>  
>  	return 0;
> 


  reply	other threads:[~2025-01-06 12:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 15:04 [PATCH v3 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 02/26] media: stb0899: Simplify check Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 03/26] media: uvcvideo: Refactor iterators Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 04/26] media: uvcvideo: Use max() macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 05/26] media: go7007: Use min and max macros Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 06/26] media: stm32-dcmipp: Remove redundant printk Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 07/26] media: staging: sun6i-isp: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 10/26] staging: media: tegra-video: Use swap macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 13/26] media: common: saa7146: Use min macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 14/26] media: dvb-frontends: drx39xyj: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 15/26] media: netup_unidvb: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 16/26] media: au0828: Use umin macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 17/26] media: flexcop-usb: Use min macro Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 18/26] media: gspca: cpia1: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 19/26] media: stk1160: " Ricardo Ribalda
2024-04-29 15:04 ` [PATCH v3 20/26] media: tegra-vde: Refactor timeout handling Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 21/26] media: i2c: st-mipid02: Use the correct div function Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 22/26] media: tc358746: Use the correct div_ function Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit Ricardo Ribalda
2025-01-06 12:21   ` Hans Verkuil [this message]
2024-04-29 15:05 ` [PATCH v3 24/26] media: venus: venc: " Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow Ricardo Ribalda
2024-04-29 15:05 ` [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit Ricardo Ribalda
2024-05-03 10:27   ` Mauro Carvalho Chehab
2024-05-03 11:55     ` Dan Carpenter
2024-05-03 11:56       ` Ricardo Ribalda
2024-05-03 14:08         ` Dragan Simic
2024-05-13 13:35           ` Ricardo Ribalda
2024-05-13 14:25             ` Michael Ira Krufky
2024-08-09  8:02               ` Ricardo Ribalda

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=f11653a7-bc49-48cd-9cdb-1659147453e4@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andersson@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=aospan@netup.ru \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=digetx@gmail.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=hugues.fruchet@foss.st.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=martin.tuma@digiteqautomotive.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=quic_vgarodia@quicinc.com \
    --cc=ribalda@chromium.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=samuel@sholland.org \
    --cc=serjk@netup.ru \
    --cc=skomatineni@nvidia.com \
    --cc=stanimir.k.varbanov@gmail.com \
    --cc=sylvain.petinot@foss.st.com \
    --cc=thierry.reding@gmail.com \
    --cc=wens@csie.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