drm/vc4: Correct DSI divider calculations
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Fri, 18 Jun 2021 20:52:28 +0000 (21:52 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Tue, 14 Sep 2021 12:04:20 +0000 (13:04 +0100)
The divider calculations tried to find the divider
just faster than the clock requested. However if
it required a divider of 7 then the for loop
aborted without handling the "error" case, and could
end up with a clock lower than requested.

Correct the loop so that we always have a clock greater
than requested.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_dsi.c

index 82b82ba..1c6939c 100644 (file)
@@ -850,11 +850,9 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder,
        /* Find what divider gets us a faster clock than the requested
         * pixel clock.
         */
-       for (divider = 1; divider < 8; divider++) {
-               if (parent_rate / divider < pll_clock) {
-                       divider--;
+       for (divider = 1; divider < 7; divider++) {
+               if (parent_rate / (divider + 1) < pll_clock)
                        break;
-               }
        }
 
        /* Now that we've picked a PLL divider, calculate back to its