push zion kernel to u v1.0
Revert "msm: hotplug: Underp input checks"

This reverts commit 7f326941bbbd364b0da341ea480564ba3261a729.
msm: hotplug: Always honor the limits

* max_cpus_online and min_cpus_online must be honored before
  cpu_up_work and cpu_down_work respectively.
* Make boosting of CPUs second priority.
* When cpus_boosted is set to 1, do not perform any boost work
  as this value should always be greater than min_cpus_online
* Break out early when target is matched while switching CPUs
  online/offline.

Even after above strict checks, we get spikes in CPU1 with max_cpus_online=1.
This maybe due to CPU Boost driver which is already half broken with CAF updates.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Fix few regressions introduced in previous commit

Thanks @myfluxi for reviewing https://github.com/neobuddy89/hammerhead_kernel_caf/commit/3435c9fc98c71f287bb3256a53cb20921344521c

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Fix firing up all CPUs while resuming

Checks introduced in 3435c9fc98c71f287bb3256a53cb20921344521c  do not let us
fire up all cpus with online_cpu() function if max_cpus_online != 4.

Fix this by letting resume function to online all cpus independently.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Return early if already enabled

* In case user/script tries to send same value again to msm_enabled,
  return early.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Add preventive checks

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Fix derp

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Remove the redundant iowait check

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Rewrite suspend-resume

* Use power-suspend instead of LCD notifier, power-suspend being
  less aggressive comparatively.
* When suspended, flush workqueue and put all sibling cores to rest.
  (yin-yan is complete as resume fires up all cores for downlock
   duration.)
* This should help to save little more battery.
* Additionally, it will help to save power and generate less heat
  when min_cpus_online > 1.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Deallocate resources when disabled

* Based on @Dorimanx and @Alucard24 idea.
* Move resource allocation to new function msm_hotplug_start()
* Create resource deallocation counterpart msm_hotplug_stop()
* Reclaim memory when msm hotplug is disabled.
* Rectify store_history_size() to reschedule only when enabled.
* Rename suspend/resume helpers to match new start/stop helpers.
* Fire up all CPUs when msm_hotplug_start() is invoked.
  This should help for speedier boot process.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: fixed history_size modifications

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Initialize and terminate mutex properly

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Use only screen touch event for boost code

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Add suspend_defer_time

* After discussions with @franciscofranco, let's use more
  suspend/resume helper LCD notifier, since now we can
  control suspend delay.
* As name suggest, suspend takes are place after some
  delay when screen is turned off. Default - 10 seconds.
* If user resumes device before suspend_defer_time seconds,
  all cores go online as before but suspend work is
  canceled and rescheduling is not done.
* If screen is turned off and suspend_defer_time is exceeded,
  all sibling cores shut down as before. While resuming,
  all cores go online for downlock duration and hotplug
  resumes working.

* Restructure msm_hotplug_mutex and suspended variables.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Use only screen touch event for boost code

[neo: This got removed by mistake.]

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Use load dependent update rates

[neo: Small corrections]

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Add compatibility for other suspend structures

* Thanks to @Dorimanx and @Alucard24
* Some kernels like this one has both LCD Notifier and
  Power Suspend, so prefer LCD Notifier in such case.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Shrink ifdef usage

* There is no functional change in this commit.
* Add #ifdef wherever required for compilation.
* Shrink where it is already used.
* Reposition suspend_defer_time attribute.

https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/0610ec687e802bc1f2ca94acc6ff19565a202d41

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Add missing ifdef for mutex

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>