@@ -367,7 +367,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
367
367
* If the sum of the intercepts metric for all of the idle states
368
368
* shallower than the current candidate one (idx) is greater than the
369
369
* sum of the intercepts and hits metrics for the candidate state and
370
- * all of the deeper states a shallower idle state is likely to be a
370
+ * all of the deeper states, a shallower idle state is likely to be a
371
371
* better choice.
372
372
*/
373
373
prev_intercept_idx = idx ;
@@ -396,30 +396,36 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
396
396
* first enabled state that is deep enough.
397
397
*/
398
398
if (teo_state_ok (i , drv ) &&
399
- !dev -> states_usage [i ].disable )
399
+ !dev -> states_usage [i ].disable ) {
400
400
idx = i ;
401
- else
402
- idx = first_suitable_idx ;
403
-
401
+ break ;
402
+ }
403
+ idx = first_suitable_idx ;
404
404
break ;
405
405
}
406
406
407
407
if (dev -> states_usage [i ].disable )
408
408
continue ;
409
409
410
- if (! teo_state_ok (i , drv )) {
410
+ if (teo_state_ok (i , drv )) {
411
411
/*
412
- * The current state is too shallow, but if an
413
- * alternative candidate state has been found,
414
- * it may still turn out to be a better choice.
412
+ * The current state is deep enough, but still
413
+ * there may be a better one.
415
414
*/
416
- if (first_suitable_idx != idx )
417
- continue ;
418
-
419
- break ;
415
+ first_suitable_idx = i ;
416
+ continue ;
420
417
}
421
418
422
- first_suitable_idx = i ;
419
+ /*
420
+ * The current state is too shallow, so if no suitable
421
+ * states other than the initial candidate have been
422
+ * found, give up (the remaining states to check are
423
+ * shallower still), but otherwise the first suitable
424
+ * state other than the initial candidate may turn out
425
+ * to be preferable.
426
+ */
427
+ if (first_suitable_idx == idx )
428
+ break ;
423
429
}
424
430
}
425
431
if (!idx && prev_intercept_idx ) {
0 commit comments