static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu)
{
- u64 busy_cycles;
- unsigned long busy_time;
+ u64 busy_cycles, busy_time;
busy_cycles = gpu_read64(gpu, REG_A5XX_RBBM_PERFCTR_RBBM_0_LO,
REG_A5XX_RBBM_PERFCTR_RBBM_0_HI);
- busy_time = (busy_cycles - gpu->devfreq.busy_cycles) /
- (clk_get_rate(gpu->core_clk) / 1000000);
+ busy_time = (busy_cycles - gpu->devfreq.busy_cycles);
+ do_div(busy_time, (clk_get_rate(gpu->core_clk) / 1000000));
gpu->devfreq.busy_cycles = busy_cycles;
- return busy_time;
+ if (WARN_ON(busy_time > ~0LU))
+ return ~0LU;
+
+ return (unsigned long)busy_time;
}
static const struct adreno_gpu_funcs funcs = {