@@ -28,6 +28,8 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
2828 if (df -> suspended )
2929 dev_err (dev , "%s while suspended ??\n" , __func__ );
3030
31+ dev_dbg (dev , "suggest: %lu\n" , * freq );
32+
3133 unsigned long curr_freq = get_freq (gpu );
3234 if (* freq == curr_freq )
3335 return 0 ;
@@ -86,7 +88,7 @@ static int msm_devfreq_get_dev_status(struct device *dev,
8688 status -> total_time = ktime_us_delta (time , df -> time );
8789 df -> time = time ;
8890
89- if (df -> suspended ) {
91+ if (( df -> suspended ) || ( status -> total_time == 0 ) ) {
9092 mutex_unlock (& df -> lock );
9193 status -> busy_time = 0 ;
9294 return 0 ;
@@ -96,21 +98,34 @@ static int msm_devfreq_get_dev_status(struct device *dev,
9698 busy_time = busy_cycles - df -> busy_cycles ;
9799 df -> busy_cycles = busy_cycles ;
98100
99- mutex_unlock (& df -> lock );
100101
101102 busy_time *= USEC_PER_SEC ;
102103 busy_time = div64_ul (busy_time , sample_rate );
103104 if (WARN_ON (busy_time > ~0LU ))
104105 busy_time = ~0LU ;
105106
106- status -> busy_time = busy_time ;
107+ /*
108+ running avg:
109+ a=((a*2) + (p+c))/4; p=c; a
110+ load per mille:
111+ */
112+ unsigned long load = busy_time * 1000 / status -> total_time ;
113+ df -> load_avg = ((df -> load_avg * 2 ) + (df -> load + load )) / 4 ;
114+ df -> load = load ;
115+
116+ status -> busy_time = df -> load_avg ;
117+ status -> total_time = 1000 ;
118+
119+ mutex_unlock (& df -> lock );
120+
121+ // status->busy_time = busy_time;
107122
108123 dev_dbg (& gpu -> pdev -> dev ,
109- "busy %lu / total %lu = %lu | freq %lu MHz bscy : %llu | srate: %lu\n" ,
124+ "busy %lu / total %lu = %lu | freq %lu MHz load : %lu | srate: %lu\n" ,
110125 status -> busy_time , status -> total_time ,
111- status -> busy_time / ( status -> total_time / 100 ) ,
126+ status -> busy_time * 100 / status -> total_time ,
112127 status -> current_frequency / 1000 / 1000 ,
113- busy_cycles ,
128+ load ,
114129 sample_rate );
115130
116131
@@ -153,8 +168,8 @@ void msm_devfreq_init(struct msm_gpu *gpu)
153168 * where due to stalling waiting for vblank we could get stuck
154169 * at (for ex) 30fps at 50% utilization.
155170 */
156- priv -> gpu_devfreq_config .upthreshold = 50 ;
157- priv -> gpu_devfreq_config .downdifferential = 10 ;
171+ priv -> gpu_devfreq_config .upthreshold = 80 ;
172+ priv -> gpu_devfreq_config .downdifferential = 20 ;
158173
159174 mutex_init (& df -> lock );
160175
@@ -225,10 +240,10 @@ void msm_devfreq_suspend(struct msm_gpu *gpu)
225240 if (!has_devfreq (gpu ))
226241 return ;
227242
243+ devfreq_suspend_device (df -> devfreq );
244+
228245 mutex_lock (& df -> lock );
229246 df -> suspended = true;
230247 mutex_unlock (& df -> lock );
231-
232- devfreq_suspend_device (df -> devfreq );
233248}
234249
0 commit comments