Revert "mutex: back out architecture specific check for negative mutex count"

This reverts commit 224ea28eafee5a670b83cef17b23d21c83713f34.
Revert "mutex: Queue mutex spinners with MCS lock to reduce cacheline contention"

This reverts commit f7ea5f22b24c1010e8ff9c5e46863d3bef52fdec.
Revert "mutex: Make more scalable by doing less atomic operations"

This reverts commit 80e6d7f69f20e364beac698ea4f831df27050353.
freezer: shorten freezer sleep time using exponential backoff

Date	Wed, 1 May 2013 18:34:59 -0700

All tasks can easily be frozen in under 10 ms, switch to using
an initial 1 ms sleep followed by exponential backoff until
8 ms.  Also convert the printed time to ms instead of centiseconds.

Signed-off-by: Colin Cross <ccross@android.com>
modified for Mako hybrid from LKML

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
freezer: skip waking up tasks with PF_FREEZER_SKIP set

Date	Wed, 1 May 2013 18:35:00 -0700

Android goes through suspend/resume very often (every few seconds when
on a busy wifi network with the screen off), and a significant portion
of the energy used to go in and out of suspend is spent in the
freezer.  If a task has called freezer_do_not_count(), don't bother
waking it up.  If it happens to wake up later it will call
freezer_count() and immediately enter the refrigerator.

Combined with patches to convert freezable helpers to use
freezer_do_not_count() and convert common sites where idle userspace
tasks are blocked to use the freezable helpers, this reduces the
time and energy required to suspend and resume.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
freezer: add new freezable helpers using freezer_do_not_count()

Date	Wed, 1 May 2013 18:35:01 -0700

Freezing tasks will wake up almost every userspace task from
where it is blocking and force it to run until it hits a
call to try_to_sleep(), generally on the exit path from the syscall
it is blocking in.  On resume each task will run again, usually
restarting the syscall and running until it hits the same
blocking call as it was originally blocked in.

To allow tasks to avoid running on every suspend/resume cycle,
this patch adds additional freezable wrappers around blocking calls
that call freezer_do_not_count().  Combined with the previous patch,
these tasks will not run during suspend or resume unless they wake
up for another reason, in which case they will run until they hit
the try_to_freeze() in freezer_count(), and then continue processing
the wakeup after tasks are thawed.  This patch also converts the
existing wait_event_freezable* wrappers to use freezer_do_not_count().

Additional patches will convert the most common locations that
userspace blocks in to use freezable helpers.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
binder: use freezable blocking calls

Date	Wed, 1 May 2013 18:35:02 -0700

Avoid waking up every thread sleeping in a binder call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
epoll: use freezable blocking call

Date	Wed, 1 May 2013 18:35:03 -0700

Avoid waking up every thread sleeping in an epoll_wait call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
select: use freezable blocking call

Date	Wed, 1 May 2013 18:35:04 -0700

Avoid waking up every thread sleeping in a select call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
futex: use freezable blocking call

Date	Wed, 1 May 2013 18:35:05 -0700

Avoid waking up every thread sleeping in a futex_wait call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
nanosleep: use freezable blocking call

Date	Wed, 1 May 2013 18:35:06 -0700

Avoid waking up every thread sleeping in a nanosleep call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
sigtimedwait: use freezable blocking call

Date	Wed, 1 May 2013 18:35:07 -0700

Avoid waking up every thread sleeping in a sigtimedwait call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
af_unix: use freezable blocking calls in read

Date	Wed, 1 May 2013 18:35:08 -0700

Avoid waking up every thread sleeping in read call on an AF_UNIX
socket during suspend and resume by calling a freezable blocking
call.  Previous patches modified the freezer to avoid sending
wakeups to threads that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
[SQUASH] Add custom Mako Hotplug driver for onlining and offlining cores based on system load.

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

Conflicts:

	arch/arm/kernel/Makefile

Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: fix some bugs, increase load levels by 10% each, queue the works in a dedicated workqueue, reduce the number of divisions every work call, fix a possible memory leak.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: online cpu1 on screen on to remove the lag, also merge the cpu max freq cap from the video driver to this driver. A bunch of other small fixes as well.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: use alloc_workqueue instead of create_*_workqueue because the latter is deprecated. Also online all cores on screen on for 1 sampling_rate for smoother screen on transitions.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: export settings to userspace. Also increase threshold for onlining all four cores to reduce heat at bordeline usages.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: add some flags to the WQ.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: reformat most of the code to be accoring upstream Kernel pedantic conventions.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: change load thresholds.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: fix a bug that was not updating online_cpus accordingly that then uncovered another bugs which led me to add a simple 10 position array for averaging the last 10 loads of the previous 10 samples which allows the driver to stay on quad-core during periods of continous high load. Also removed the sec_threshold temp_diff check for medium load if there is only 1 cpu online thus increasing interactivity between menus and UI interactions. Then after that initial onlining if the load keeps being medium it takes not 2 seconds but 4 seconds interval between onlining the remaining cpus.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: sync the threshold with the driver.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: add hooks so that the driver and the sysfs are synchronized with the defaults if I decide to change them in the future.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: fix a bug where the counter could be 10 sometimes and when trying to write to history_load[10] it derped big time. Also add all the stats to the struct, its cleaner.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: change the load history mechanism a little but based on one TI patch for interactive called timer_view that makes use of this type of ringbuffers.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

cpufreq: interactive: add hooks in the Hotplug driver to scale interactive tunables based on system load.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

cpufreq: interactive: cleanup mess from last commit (it was a proof of concept). Add an intermediate scaling point if the load is just allowing single onlining cpu cores. Also ajust some of the values.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: if the user has lots of widgets in the lock screen and in the home screen the device will lag during unlock if its only single core, so revert partially the last patch.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: add level for early_suspend struct.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: some performance optimizations.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

mako_hotplug: well duh, with the msleep if a user locked&unlocked too fast it would be stuck with black screen until the msleep was finished.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>

cpufreq: interactive: boost cpufreq to 1GHz on input, instead of 702MHz.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Derek Cannata <thederekjay@gmail.com>
configs: Update mako_defconfig MAKO_HOTPLUG.

Signed-off-by: Derek Cannata <thederekjay@gmail.com>