drm/i915/dp: fix integer overflow in 128b/132b data rate calculation
authorJani Nikula <jani.nikula@intel.com>
Tue, 26 Oct 2021 09:34:07 +0000 (12:34 +0300)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 27 Oct 2021 10:10:11 +0000 (06:10 -0400)
The intermediate value 1000000 * 10 * 9671 overflows 32 bits, so force
promotion to a bigger type.

From the logs:

[drm:intel_dp_compute_config [i915]] DP link rate required 3657063 available -580783288

v2: Use mul_u32_u32() (Ville)

Fixes: 48efd014f0ea ("drm/i915/dp: add max data rate calculation for UHBR rates")
Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211026093407.11381-1-jani.nikula@intel.com
(cherry picked from commit bf0d608b55d9b7f426031dfd9f08d9df36c94728)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/i915/display/intel_dp.c

index 0ddc24a..2a3521c 100644 (file)
@@ -287,7 +287,7 @@ intel_dp_max_data_rate(int max_link_rate, int max_lanes)
                 */
                int max_link_rate_kbps = max_link_rate * 10;
 
-               max_link_rate_kbps = DIV_ROUND_CLOSEST_ULL(max_link_rate_kbps * 9671, 10000);
+               max_link_rate_kbps = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(max_link_rate_kbps, 9671), 10000);
                max_link_rate = max_link_rate_kbps / 8;
        }