Commit 3123698f authored by Chris Wilson's avatar Chris Wilson

drm/i915: Use mul_u32_u32() for 32b x 32b -> 64b result

As realised by commit 9e3d6223 ("math64, timers: Fix 32bit
mul_u64_u32_shr() and friends"), GCC does not always generate ideal code
for performing a 32b x 32b multiply returning a 64b result (i.e. where
we idiomatically use u64 result = (u64)x * (u32)x). This catches a
couple of instances in the display code using (u64)x * (u32)y.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20170913105154.2910-1-chris@chris-wilson.co.ukReviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent e60b36f7
...@@ -10224,7 +10224,7 @@ int intel_dotclock_calculate(int link_freq, ...@@ -10224,7 +10224,7 @@ int intel_dotclock_calculate(int link_freq,
if (!m_n->link_n) if (!m_n->link_n)
return 0; return 0;
return div_u64((u64)m_n->link_m * link_freq, m_n->link_n); return div_u64(mul_u32_u32(m_n->link_m, link_freq), m_n->link_n);
} }
static void ironlake_pch_clock_get(struct intel_crtc *crtc, static void ironlake_pch_clock_get(struct intel_crtc *crtc,
......
...@@ -1385,7 +1385,7 @@ intel_tv_get_modes(struct drm_connector *connector) ...@@ -1385,7 +1385,7 @@ intel_tv_get_modes(struct drm_connector *connector)
mode_ptr->vsync_end = mode_ptr->vsync_start + 1; mode_ptr->vsync_end = mode_ptr->vsync_start + 1;
mode_ptr->vtotal = vactive_s + 33; mode_ptr->vtotal = vactive_s + 33;
tmp = (u64) tv_mode->refresh * mode_ptr->vtotal; tmp = mul_u32_u32(tv_mode->refresh, mode_ptr->vtotal);
tmp *= mode_ptr->htotal; tmp *= mode_ptr->htotal;
tmp = div_u64(tmp, 1000000); tmp = div_u64(tmp, 1000000);
mode_ptr->clock = (int) tmp; mode_ptr->clock = (int) tmp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment