drm/etnaviv: slow down FE idle polling
[linux-2.6-microblaze.git] / drivers / gpu / drm / etnaviv / etnaviv_gpu.c
index de8c989..63b929b 100644 (file)
@@ -493,6 +493,14 @@ static void etnaviv_gpu_update_clock(struct etnaviv_gpu *gpu)
                clock |= VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(fscale);
                etnaviv_gpu_load_clock(gpu, clock);
        }
+
+       /*
+        * Choose number of wait cycles to target a ~30us (1/32768) max latency
+        * until new work is picked up by the FE when it polls in the idle loop.
+        * If the GPU base frequency is unknown use 200 wait cycles.
+        */
+       gpu->fe_waitcycles = clamp(gpu->base_rate_core >> (15 - gpu->freq_scale),
+                                  200UL, 0xffffUL);
 }
 
 static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)