video: tegra: dc: fix bandwidth calc for 4K
Jong Kim [Tue, 20 May 2014 00:37:46 +0000 (17:37 -0700)]
Fix 32bit arithmatic overflow in bandwidth calculation by
switching division and multiplying.

bug 1499542

Change-Id: Ia37ce2f0a6c4e0f08398f2eaa3be557461fdfbb7
Signed-off-by: Jong Kim <jongk@nvidia.com>
Reviewed-on: http://git-master/r/411746
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Winnie Hsu <whsu@nvidia.com>

drivers/video/tegra/dc/bandwidth.c

index b98ced8..4555845 100644 (file)
@@ -617,12 +617,12 @@ static unsigned long tegra_dc_calc_win_bandwidth(struct tegra_dc *dc,
         * is of the luma plane's size only. */
        bpp = tegra_dc_is_yuv_planar(w->fmt) ?
                2 * tegra_dc_fmt_bpp(w->fmt) : tegra_dc_fmt_bpp(w->fmt);
-       ret = dc->mode.pclk / 1000UL * bpp / 8 *
+       ret = dc->mode.pclk / 1000UL * bpp / 8
 #if defined(CONFIG_ARCH_TEGRA_2x_SOC) || defined(CONFIG_ARCH_TEGRA_3x_SOC)
-               (win_use_v_filter(dc, w) ? 2 : 1) *
+               * (win_use_v_filter(dc, w) ? 2 : 1)
 #endif
-               in_w / w->out_w * (WIN_IS_TILED(w) ?
-               tiled_windows_bw_multiplier : 1);
+               / w->out_w * in_w
+               / (WIN_IS_TILED(w) ?  tiled_windows_bw_multiplier : 1);
 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
        /*
         * Assuming 60% efficiency: i.e. if we calculate we need 70MBps, we