Skip to content

Commit

Permalink
drm/i915/dp: fix integer overflow in 128b/132b data rate calculation
Browse files Browse the repository at this point in the history
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: 48efd01 ("drm/i915/dp: add max data rate calculation for UHBR rates")
Cc: Manasi Navare <[email protected]>
Cc: Ville Syrjälä <[email protected]>
Reviewed-by: Ville Syrjälä <[email protected]>
Signed-off-by: Jani Nikula <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit bf0d608)
Signed-off-by: Rodrigo Vivi <[email protected]>
  • Loading branch information
jnikula authored and rodrigovivi committed Oct 27, 2021
1 parent 9ca8bb7 commit 02295cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 02295cf

Please sign in to comment.