net: wireless: bcmdhd: Avoid suspend on watchdog

Change-Id: Ic41a8f369a2ee8b2a0084e6a1cbf6b454ff53353
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
cpufreq: interactiver governor: Add a time view concept

CPUFreq governors are always a tradeoff between power vs performance.
For low power UCs we want to have a less reponsive cpufreq governor that
does not respond or react to each load pick.
However when scrolling on the screen or during webbrowsing we need a more
responsive governor that interact or esponse to each load variation.

To detect which kind of application we have, we'll rely on the history of
the load. if the the average over the load history is high that means we
need to be more responsive so we change the governor paramters in that
direction.
if the average over the load history is low thatmeans we are in low power
UCs so we change the governor parameter to be less responsive

Change-Id: Ifd55ac4cfbc1bd9eded4ae603b158054c6169e8c
Signed-off-by: Nicole Chalhoub <n-chalhoub@ti.com>
Signed-off-by: Taras Kondratiuk <taras@ti.com>
(cherry picked from commit c9d2e290d40f629306ba4cd020be1d71ed5e1d23)

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive governor: Fix not uniform buf filling & memory corruption

Each CPU has it's own load history buffer, but all they use shared
<history_load_index> variable, this lead to not uniform filling
of the cpu's circular buffers. Only about half of buffer is updated
during each buffer rewriting cycle that obligate governor to use
outdated data during freq tuning.

Moreover access to <history_load_index> variable is not atomic, that
create race conditions. Simultaneous increment could cause situation
where such check:

        if (++history_load_index == sampling_periods)
                history_load_index = 0;

not safe and buffer overflow will not be prevented. That will lead
to memory corruption.

To avoid such problems this patch move buffer-index variable to
<cpufreq_interactive_cpuinfo> structure, which is separate for each CPU.
Also, buffer overflow checking will be paranoidly changed.

Change-Id: I333a4462be17816372a7a57529811d87930058c0
Signed-off-by: Leonid Iziumtsev <x0153368@ti.com>
(cherry picked from commit befb3fe3e38d88bc1872d99748c246c26406315d)

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: take idle notifications only when active - https://github.com/android/kernel_common/commit/22a51ab6e21de740c1b555f9a03626d28aaebdf3

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: keep freezer happy when not current governor - https://github.com/android/kernel_common/commit/5ff8407798f1d8c44f3165bc535676a2a897666b

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: handle speed up and down in the realtime task - https://github.com/android/kernel_common/commit/f8aa05d96a0d18416d2627c493f7dc9bc5324901

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: remove input_boost handling - https://github.com/android/kernel_common/commit/4e27eb56e819745a1b184f278d7f3dd3887a456c

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: fix compiling errors from the latest commits

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: separate Interactive governor into two, one with static settings and another one with dynamic settings (it adjusts itself according to load). The new governor is called Dynamic Interactive.

Conflicts:
	drivers/cpufreq/Makefile
cpufreq: interactive: change frequency up/down kernel thread priority. Now it has more priority than any user thread which should boost interactivity.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: add input_boost_freq entry. This entry is the frequency which the CPU will be boosted when the screen is touched. It's user configurable from userspace and it needs to match the entries in the frequency table.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

Conflicts:
	drivers/cpufreq/cpufreq_interactive.c
cpufreq: interactive: run at fraction of hispeed_freq when load is low

When load is below go_hispeed_load, apply the percentage of CPU load to
a max frequency of hispeed_freq instead of the max speed.  This avoids
jumping too quickly to hispeed_freq when it is a relatively low
percentage of max speed.  This also allows go_hispeed_load to be set to
a high percentage relative to hispeed_freq (as a percentage of max speed,
again useful when hispeed_freq is a low fraction of max speed), to cap
larger loads at hispeed_freq.  For example, a load of 60% will typically
move to 60% of hispeed_freq, not 60% of max speed.  This causes the
governor to apply two different speed caps, depending on whether load is
below or above go_hispeed_load.

Also fix the type of hispeed_freq, which was u64, to match other
speed data types (and avoid overhead and allow division).

Change-Id: Ie2d0668be161c074aaad77db2037505431457b3a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: pin timers to associated CPU - original patch: https://github.com/android/kernel_common/commit/430d3d4539a0d441679ca32cc7c3876f97a07da6

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: use deferrable timer by default - original patch: https://github.com/android/kernel_common/commit/0697ab54cab34e099711ceb4b07b2dfc6b507f0d

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

Conflicts:
	drivers/cpufreq/cpufreq_interactive.c
cpufreq: interactive: kick timer on idle exit past expiry - original patch: https://github.com/android/kernel_common/commit/9b29a6d49becf8caf0550373d84a1068c716e891

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
net: wireless: bcmdhd: Fix WD wakelock behavior

Change-Id: I7ebae2be248cbb4bc98e2b448641f65b77a320f4
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

Conflicts:

	drivers/net/wireless/bcmdhd/dhd_linux.c
Enable Dynamic Interactive Governor
Undervolt usim and vaux3
Set initial Contrast to -10