mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 03:45:24 -04:00
msm: kgsl: Fix UBSAN warnings
Fix possible division by zero error. Change-Id: I64eb6a5ee1247dafea6701b8244eefab1c40eea6 Signed-off-by: Jeyaprabu J <quic_jeyaprab@quicinc.com>
This commit is contained in:
parent
e97ce5ceb5
commit
726d78ef8a
2 changed files with 9 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue