Re: [PATCH] drm/sun4i: hdmi: Fix u64 div on 32bit arch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Maxime,

Thanks for your patch!

On Mon, Mar 4, 2024 at 10:12 AM Maxime Ripard <mripard@xxxxxxxxxx> wrote:
> Commit 358e76fd613a ("drm/sun4i: hdmi: Consolidate atomic_check and
> mode_valid") changed the clock rate from an unsigned long to an unsigned
> long long resulting in a a 64-bit division that might not be supported
> on all platforms.

Why was this changed to unsigned long long?
Can a valid pixel clock really not fit in 32-bit?

> The resulted in compilation being broken at least for m68k, xtensa and
> some arm configurations, at least.
>
> Fixes: 358e76fd613a ("drm/sun4i: hdmi: Consolidate atomic_check and mode_valid")
> Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Reported-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
> Closes: https://lore.kernel.org/r/CA+G9fYvG9KE15PGNoLu+SBVyShe+u5HBLQ81+kK9Zop6u=ywmw@xxxxxxxxxxxxxx/
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202403011839.KLiXh4wC-lkp@xxxxxxxxx/
> Signed-off-by: Maxime Ripard <mripard@xxxxxxxxxx>

> --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
> @@ -163,11 +163,11 @@ static enum drm_mode_status
>  sun4i_hdmi_connector_clock_valid(const struct drm_connector *connector,
>                                  const struct drm_display_mode *mode,
>                                  unsigned long long clock)
>  {
>         const struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
> -       unsigned long diff = clock / 200; /* +-0.5% allowed by HDMI spec */
> +       unsigned long diff = div_u64(clock, 200); /* +-0.5% allowed by HDMI spec */

I'd rather see clock changed back to unsigned long.

>         long rounded_rate;
>
>         if (mode->flags & DRM_MODE_FLAG_DBLCLK)
>                 return MODE_BAD;
>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux