mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Shreeya Patel <shreeya.patel@collabora.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Dingxian Wen <shawn.wen@rock-chips.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-media@vger.kernel.org, kernel@collabora.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: platform: synopsys: use div_u64() for 64-bit division
Date: Fri, 7 Mar 2025 13:31:13 +0300	[thread overview]
Message-ID: <8c685f16-8f49-42ab-ab1b-0fa0804d65f0@collabora.com> (raw)
In-Reply-To: <20250307102405.56313-1-arnd@kernel.org>

On 3/7/25 13:23, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> One open-coded division causes a link failure on 32-bit architectures:
> 
> ld.lld-21: error: undefined symbol: __aeabi_uldivmod
>>>> referenced by snps_hdmirx.c
>>>>               drivers/media/platform/synopsys/hdmirx/snps_hdmirx.o:(hdmirx_query_dv_timings) in archive vmlinux.a
> 
> Another one uses do_div() with a temporary variable.
> 
> Change both to use div_u64() to avoid the link failure and improve
> readability.
> 
> Fixes: 7b59b132ad43 ("media: platform: synopsys: Add support for HDMI input driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> index 4ffc86ad6c35..438536d88c7f 100644
> --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> @@ -296,7 +296,7 @@ static void hdmirx_get_timings(struct snps_hdmirx_dev *hdmirx_dev,
>  	hfp = htotal - hact - hs - hbp;
>  	vfp = vtotal - vact - vs - vbp;
>  
> -	fps = (bt->pixelclock + (htotal * vtotal) / 2) / (htotal * vtotal);
> +	fps = div_u64(bt->pixelclock + (htotal * vtotal) / 2, htotal * vtotal);
>  	bt->width = hact;
>  	bt->height = vact;
>  	bt->hfrontporch = hfp;
> @@ -396,7 +396,7 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev,
>  	u32 val, tmdsqpclk_freq, pix_clk;
>  	unsigned int num_retries = 0;
>  	u32 field_type, deframer_st;
> -	u64 tmp_data, tmds_clk;
> +	u64 tmds_clk;
>  	bool is_dvi_mode;
>  	int ret;
>  
> @@ -418,9 +418,7 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev,
>  
>  	tmdsqpclk_freq = hdmirx_readl(hdmirx_dev, CMU_TMDSQPCLK_FREQ);
>  	tmds_clk = tmdsqpclk_freq * 4 * 1000;
> -	tmp_data = tmds_clk * 24;
> -	do_div(tmp_data, hdmirx_dev->color_depth);
> -	pix_clk = tmp_data;
> +	pix_clk = div_u64(tmds_clk * 24, hdmirx_dev->color_depth);
>  	bt->pixelclock = pix_clk;
>  
>  	if (hdmirx_dev->pix_fmt == HDMIRX_YUV420)

Hi, thanks for the fix! Hans already merged a similar patch [1].

[1]
https://patchwork.linuxtv.org/project/linux-media/patch/20250306-synopsys-hdmirx-fix-64-div-v1-1-dd5ff38bba5e@kernel.org/

-- 
Best regards,
Dmitry

      reply	other threads:[~2025-03-07 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 10:23 Arnd Bergmann
2025-03-07 10:31 ` Dmitry Osipenko [this message]

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=8c685f16-8f49-42ab-ab1b-0fa0804d65f0@collabora.com \
    --to=dmitry.osipenko@collabora.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=shawn.wen@rock-chips.com \
    --cc=shreeya.patel@collabora.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®