power: Ignore interaction boost sequence in a short period

 * When slowly, but continuously scrolling, a sequence of zero duration
   boosts are fired by the framework. They quickly fill up the internal
   limitation of MPCTL, as a result all incoming boosts get ignored.
 * Fixing the following logspam:
    ANDR-PERF-MPCTL: Active req limit reached, No optimizations performed
 * This restores cm-14.1 behavior.

Change-Id: I977e844935539a4598a749c77f4c0934ca93a2b7
diff --git a/power-660.c b/power-660.c
index 9ab8b62..895b1ff 100644
--- a/power-660.c
+++ b/power-660.c
@@ -251,8 +251,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8084.c b/power-8084.c
index c9d7d13..251318f 100644
--- a/power-8084.c
+++ b/power-8084.c
@@ -275,8 +275,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8226.c b/power-8226.c
index 99a2e91..c254f8f 100644
--- a/power-8226.c
+++ b/power-8226.c
@@ -218,8 +218,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-845.c b/power-845.c
index e2b6892..3a95c79 100644
--- a/power-845.c
+++ b/power-845.c
@@ -208,8 +208,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8610.c b/power-8610.c
index f5f28ff..764b6af 100644
--- a/power-8610.c
+++ b/power-8610.c
@@ -214,8 +214,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8916.c b/power-8916.c
index 08340ba..c126874 100644
--- a/power-8916.c
+++ b/power-8916.c
@@ -190,8 +190,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8937.c b/power-8937.c
index 3509665..b28e2c7 100644
--- a/power-8937.c
+++ b/power-8937.c
@@ -266,8 +266,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8953.c b/power-8953.c
index 7862ee0..8a127ec 100644
--- a/power-8953.c
+++ b/power-8953.c
@@ -263,8 +263,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8974.c b/power-8974.c
index 6269438..5d16ecf 100644
--- a/power-8974.c
+++ b/power-8974.c
@@ -281,8 +281,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8992.c b/power-8992.c
index 049dcf3..69f1c47 100644
--- a/power-8992.c
+++ b/power-8992.c
@@ -265,8 +265,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8994.c b/power-8994.c
index 22f747d..5272454 100644
--- a/power-8994.c
+++ b/power-8994.c
@@ -273,8 +273,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8996.c b/power-8996.c
index 411f7c1..6829644 100644
--- a/power-8996.c
+++ b/power-8996.c
@@ -316,8 +316,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;
diff --git a/power-8998.c b/power-8998.c
index 0fd6aae..aeec6c6 100644
--- a/power-8998.c
+++ b/power-8998.c
@@ -282,8 +282,10 @@
     clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
 
     elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
-    // don't hint if previous hint's duration covers this hint's duration
-    if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
+    // don't hint if it's been less than 250ms since last boost
+    // also detect if we're doing anything resembling a fling
+    // support additional boosting in case of flings
+    if (elapsed_time < 250000 && duration <= 750) {
         return;
     }
     s_previous_boost_timespec = cur_boost_timespec;