diff --git a/drivers/gpu/msm/adreno_a6xx_rpmh.c b/drivers/gpu/msm/adreno_a6xx_rpmh.c index 0594304d64ee..c7a4b3297e45 100644 --- a/drivers/gpu/msm/adreno_a6xx_rpmh.c +++ b/drivers/gpu/msm/adreno_a6xx_rpmh.c @@ -120,6 +120,7 @@ static void tcs_cmd_data(struct bcm *bcms, int count, u32 ab, u32 ib, u32 *data) { int i; + u64 total_width; for (i = 0; i < count; i++) { bool valid = true; @@ -145,8 +146,11 @@ static void tcs_cmd_data(struct bcm *bcms, int count, u32 ab, u32 ib, /* Multiple the bandwidth by the width of the connection */ avg = ((u64) ab) * bcms[i].width; + total_width = bcms[i].buswidth * bcms[i].channels; + /* And then divide by the total width across channels */ - do_div(avg, bcms[i].buswidth * bcms[i].channels); + if (total_width) + do_div(avg, (u32) total_width); peak = ((u64) ib) * bcms[i].width; do_div(peak, bcms[i].buswidth); diff --git a/drivers/gpu/msm/governor_gpubw_mon.c b/drivers/gpu/msm/governor_gpubw_mon.c index fabcd56b3776..af437abf107e 100644 --- a/drivers/gpu/msm/governor_gpubw_mon.c +++ b/drivers/gpu/msm/governor_gpubw_mon.c @@ -101,7 +101,7 @@ static int devfreq_gpubw_get_target(struct devfreq *df, int act_level; int norm_max_cycles; int norm_cycles; - int wait_active_percent; + int wait_active_percent = 0; int gpu_percent; /* * Normalized AB should at max usage be the gpu_bimc frequency in MHz. @@ -132,8 +132,9 @@ static int devfreq_gpubw_get_target(struct devfreq *df, (unsigned int) priv->bus.total_time; norm_cycles = (unsigned int)(priv->bus.ram_time + priv->bus.ram_wait) / (unsigned int) priv->bus.total_time; - wait_active_percent = (100 * (unsigned int)priv->bus.ram_wait) / - (unsigned int) priv->bus.ram_time; + if (priv->bus.ram_time) + wait_active_percent = (100 * (unsigned int)priv->bus.ram_wait) / + (unsigned int) priv->bus.ram_time; gpu_percent = (100 * (unsigned int)priv->bus.gpu_time) / (unsigned int) priv->bus.total_time;