Skip to content

Commit

Permalink
drm/sun4i: rgb: Fix potential division by zero
Browse files Browse the repository at this point in the history
In the case where mode_valid callback of our RGB connector was called
before mode_set was being called, the range of dividers would not be set,
resulting in a division by zero later on in the clk_round_rate logic.

Set the range of dividers before calling clk_round_rate to fix this.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Tested-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180221125703.4595-2-maxime.ripard@bootlin.com
  • Loading branch information
Maxime Ripard committed Mar 6, 2018
1 parent e742a17 commit 5af894b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/sun4i/sun4i_rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ static int sun4i_rgb_mode_valid(struct drm_connector *connector,

DRM_DEBUG_DRIVER("Vertical parameters OK\n");

tcon->dclk_min_div = 6;
tcon->dclk_max_div = 127;
rounded_rate = clk_round_rate(tcon->dclk, rate);
if (rounded_rate < rate)
return MODE_CLOCK_LOW;
Expand Down

0 comments on commit 5af894b

Please sign in to comment.