dri-devel Archive mirror
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: Xinliang Liu <xinliang.liu@linaro.org>,
	Tian Tao <tiantao6@hisilicon.com>,
	Xinwei Kong <kong.kongxinwei@hisilicon.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Yongqin Liu <yongqin.liu@linaro.org>,
	John Stultz <jstultz@google.com>
Subject: [PATCH 09/21] drm/hisilicon/kirin: Fix 64bit divisions
Date: Mon,  8 Apr 2024 20:04:14 +0300	[thread overview]
Message-ID: <20240408170426.9285-10-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20240408170426.9285-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Use the appropriate 64bit division helpers to make the code
build on 32bit architectures.

Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Yongqin Liu <yongqin.liu@linaro.org>
Cc: John Stultz <jstultz@google.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
index 566de4658719..a39cc549c20b 100644
--- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
+++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
@@ -157,8 +157,8 @@ static u32 dsi_calc_phy_rate(u32 req_kHz, struct mipi_phy_params *phy)
 			q_pll = 0x10 >> (7 - phy->hstx_ckg_sel);
 
 		temp = f_kHz * (u64)q_pll * (u64)ref_clk_ps;
-		m_n_int = temp / (u64)1000000000;
-		m_n = (temp % (u64)1000000000) / (u64)100000000;
+		m_n_int = div64_u64_rem(temp, 1000000000, &temp);
+		m_n = div_u64(temp, 100000000);
 
 		if (m_n_int % 2 == 0) {
 			if (m_n * 6 >= 50) {
@@ -229,9 +229,8 @@ static u32 dsi_calc_phy_rate(u32 req_kHz, struct mipi_phy_params *phy)
 			phy->pll_fbd_div5f = 1;
 		}
 
-		f_kHz = (u64)1000000000 * (u64)m_pll /
-			((u64)ref_clk_ps * (u64)n_pll * (u64)q_pll);
-
+		f_kHz = div64_u64((u64)1000000000 * (u64)m_pll,
+				  (u64)ref_clk_ps * (u64)n_pll * (u64)q_pll);
 		if (f_kHz >= req_kHz)
 			break;
 
@@ -490,7 +489,7 @@ static void dsi_set_mode_timing(void __iomem *base,
 	hsa_time = (hsw * lane_byte_clk_kHz) / pixel_clk_kHz;
 	hbp_time = (hbp * lane_byte_clk_kHz) / pixel_clk_kHz;
 	tmp = (u64)htot * (u64)lane_byte_clk_kHz;
-	hline_time = DIV_ROUND_UP(tmp, pixel_clk_kHz);
+	hline_time = DIV_ROUND_UP_ULL(tmp, pixel_clk_kHz);
 
 	/* all specified in byte-lane clocks */
 	writel(hsa_time, base + VID_HSA_TIME);
-- 
2.43.2


  parent reply	other threads:[~2024-04-08 17:05 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 17:04 [PATCH 00/21] drm: Increase COMPILE_TEST=y coverage Ville Syrjala
2024-04-08 17:04 ` [PATCH 01/21] drm/armada: Fix printk arguments Ville Syrjala
2024-04-08 17:04 ` [PATCH 02/21] drm/armada: Fix armada_debugfs_crtc_reg_write() return type Ville Syrjala
2024-04-08 17:04 ` [PATCH 03/21] drm/armada: Allow build with COMPILE_TEST=y Ville Syrjala
2024-04-08 17:04 ` [PATCH 04/21] drm/imx/dcss: Fix 64bit divisions Ville Syrjala
2024-04-08 17:04 ` [PATCH 05/21] drm/imx/dcss: Allow build with COMPILE_TEST=y Ville Syrjala
2024-04-08 17:04 ` [PATCH 06/21] drm/sti: Include linux/io.h for devm_ioremap() Ville Syrjala
2024-05-27 15:28   ` Alain Volmat
2024-04-08 17:04 ` [PATCH 07/21] drm/sti: Allow build with COMPILE_TEST=y Ville Syrjala
2024-05-27 15:29   ` Alain Volmat
2024-05-28 19:45     ` Ville Syrjälä
2024-04-08 17:04 ` [PATCH 08/21] drm/hisilicon/kirin: Include linux/io.h for readl()/writel() Ville Syrjala
2024-04-08 17:08   ` John Stultz
2024-04-08 17:04 ` Ville Syrjala [this message]
2024-04-08 17:09   ` [PATCH 09/21] drm/hisilicon/kirin: Fix 64bit divisions John Stultz
2024-04-08 17:04 ` [PATCH 10/21] drm/hisilicon/kirin: Fix MASK(32) on 32bit architectures Ville Syrjala
2024-04-08 17:09   ` John Stultz
2024-04-08 17:04 ` [PATCH 11/21] drm/hisilicon/kirin: Allow build with COMPILE_TEST=y Ville Syrjala
2024-04-08 17:11   ` John Stultz
2024-04-08 17:04 ` [PATCH 12/21] drm/tilcdc: Allow build without __iowmb() Ville Syrjala
2024-04-10  9:06   ` Tomi Valkeinen
2024-04-10 15:25     ` Ville Syrjälä
2024-04-10 15:47       ` Tomi Valkeinen
2024-04-10 17:04       ` Ville Syrjälä
2024-04-10 17:12         ` Tomi Valkeinen
2024-04-11 13:40       ` jyri.sarha
2024-04-08 17:04 ` [PATCH 13/21] drm/tilcdc: Allow build with COMPILE_TEST=y Ville Syrjala
2024-04-10  9:06   ` Tomi Valkeinen
2024-04-08 17:04 ` [PATCH 14/21] drm/omap: Open code phys_to_page() Ville Syrjala
2024-04-10  9:14   ` Tomi Valkeinen
2024-04-08 17:04 ` [PATCH 15/21] drm/omap: Allow build with COMPILE_TEST=y Ville Syrjala
2024-04-08 17:12   ` Ville Syrjälä
2024-04-10  9:15   ` Tomi Valkeinen
2024-04-08 17:04 ` [PATCH 16/21] drm/atmel-hlcdc: " Ville Syrjala
2024-04-09 16:55   ` Sam Ravnborg
2024-04-08 17:04 ` [PATCH 17/21] drm/fsl-dcu: " Ville Syrjala
2024-04-08 17:04 ` [PATCH 18/21] drm/mediatek: " Ville Syrjala
2024-04-08 17:04 ` [PATCH 19/21] drm/meson: " Ville Syrjala
2024-04-08 17:23   ` Martin Blumenstingl
2024-04-08 17:04 ` [PATCH 20/21] drm/rcar-du: " Ville Syrjala
2024-04-09  7:26   ` Geert Uytterhoeven
2024-04-10 22:36   ` Laurent Pinchart
2024-04-08 17:04 ` [PATCH 21/21] drm/stm: " Ville Syrjala
2024-04-10 12:15   ` Raphael Gallais-Pou
2024-04-10  6:07 ` [PATCH 12/21] drm/tilcdc: Allow build without __iowmb() sarha
2024-04-10  6:07 ` [PATCH 13/21] drm/tilcdc: Allow build with COMPILE_TEST=y sarha
2024-05-08 19:40 ` [PATCH 00/21] drm: Increase COMPILE_TEST=y coverage Ville Syrjälä

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=20240408170426.9285-10-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jstultz@google.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tiantao6@hisilicon.com \
    --cc=xinliang.liu@linaro.org \
    --cc=yongqin.liu@linaro.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).