drm/sun4i: hdmi: Fix sun4i_tmds_determine_rate
PATCH 1/1 drm/sun4i: hdmi: Fix sun4i_tmds_determine_rate
There are several issues in sun4i_tmds_determine_rate:
- doesn't check if the best match was already set before comparing it with the enumerated parameters which could result in integer divide by zero
- doesn't consider rate halving when determining closest match if it can't match the requested rate exactly
- sets best_div to i which corresponds to rate halving when it should be set to j which corresponds to the divider
Fix these issues.
--- drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +6 -3
@@ -102,10 +102,13 @@ static int sun4i_tmds_determine_rate(struct clk_hw *hw, goto out; } -if (abs (rate - rounded / i) < -abs (rate - best_parent / best_div)) { +if (!best_parent || +abs (rate - rounded / i / j) < +abs (rate - best_parent / best_half / + best_div)) { best_parent = rounded; - best_div = i; + best_half = i; + best_div = j; } } }
Signature · 1 line
2.15.0
Hi,
Quoted 9 lines · Jonathan Liu
There are several issues in
sun4i_tmds_determine_rate:
- doesn't check if the best match was already set before comparing it with the enumerated parameters which could result in integer divide by zero
- doesn't consider rate halving when determining closest match if it can't match the requested rate exactly
- setsbest_divto i which corresponds to rate halving when it should be set to j which corresponds to the divider
Quoted 4 lines
Fix these issues.
Fixes 9c5681011a0c ("drm/sun4i: Add HDMI support")Signed-off-by Jonathan Liu <[email protected]>
Please make separate patches for each of these issues, if possible detailing how do you reproduce them.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20171221/555a6fd4/attachment.sig>