sched/nohz: Correctly initialize 'next_balance' in 'nohz' idle balancer

The 'next_balance' field of 'nohz' idle balancer must be initialized
to jiffies. Since jiffies is initialized to negative 300 seconds the
'nohz' idle balancer does not run for the first 300s (5mins) after
bootup. If no new processes are spawed or no idle cycles happen, the
load on the cpus will remain unbalanced for that duration.

Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1DD7BFEDD3147247B1355BEFEFE4665237994F30EF@HQMAIL04.nvidia.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>

[xqi@codeaurora.org merge into different file location in 3.0]
Change-Id: I42c41210babb0881150d28d11c2d3fce24fe3a9f
Signed-off-by: Xin Qi <xqi@codeaurora.org>
sched/nohz: Fix logic in nohz_kick_needed

Update the logic so that as long as rq->nr_running is greater than 1,
nohz_kick will be needed, regardless of whether the current CPU has
successfully competed for the first or second cpu spot

Previous logic has the corner case that if current CPU has r_running more than
1, and two other CPUs alreay hold first and econd cpu spot, but they don't
meeting kicking criterial (first cpu has nr_running 1, and second cpu doesn't
have any load), then nohz_kick will not be set correctly.

Change-Id: I30790f22df0a2e90899daa44c67757284dcca25d
Signed-off-by: Xin Qi <xqi@codeaurora.org>
sched/nohz: Fix logic in run_rebalance_domains

If triggered by nohz_balancer_kick, idle_at_tick is not updated
accordingly.  Update myself at this moment right before it is used

Change-Id: I20dd4314159e70f955ffe482160c8867c65c261e
Signed-off-by: Xin Qi <xqi@codeaurora.org>
sched/nohz: Fix logic in trigger_load_balance

Whether we need to kick nohz doesn't depend on current rq->next_balance,
meaning it doesn't depend on the check of previous if condition.

Change-Id: I566011d6341fa7a9a700c834f77e129043eaba11
Signed-off-by: Xin Qi <xqi@codeaurora.org>
tick-sched: recalculate sleep length each time it is requested

Recalculating the sleep length each time its called allows us to account
for the fact that the amount of time we can sleep for might change after
tick_nohz_stop_sched_tick is called in idle. The prime example of this
is an idle notifier that cancels timers as we are entering idle.

Change-Id: I92871efc7befb3fee2a816da16145ba9da334a9e
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>

Conflicts:

	kernel/time/tick-sched.c
d2: Set as-instr to use printf intsead of echo

as-instr was hardcoded to use /bin/echo with the -e option.
Non-GNU systems like MacOSX would fail and cause compiler errors.

Since BSD echo does not have the -e option (escape backslashes)
prinf was used instead would should be more friendly cross-platform

Specifically with the new OSX toolchain it caused the following
error:
  Error: selected processor does not support ARM mode `smc #0'

This was caused by $(call as-instr,.arch_extension sec,+sec) failing
since it was using echo -e.

See: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

  "It is not possible to use echo portably across all POSIX systems
   unless both -n (as the first argument) and escape sequences are
   omitted.

  The printf utility can be used portably to emulate any of the
  traditional behaviors of the echo utility as follows (assuming
  that IFS has its standard value or is unset)

  New applications are encouraged to use printf instead of echo."

Change-Id: I558ec343e9bb8d449e1af710d329b4dc76743a05
cpufreq: Add a boostpulse interface to ondemand

For applications that require a one-shot increase in frequency,
the boostpulse interface would help to scale to max for the time
specified in boostime. This helps applications that currently
increases scaling_min_freq and resets later after a fixed duration.
Instead of changing scaling_min_freq applications can directly write
to boostpulse and governer resets during regular timer after the time
expires.

Change-Id: Ie5f490ff06b41364aa76dd468573433495da28a4
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
cpufreq: notify avg load for short sampling_rate

If the sampling rate is less than 50ms reporting
the actual load may lead to poor decision making
at user space. So, for sampling rates less than 50ms
report the average of load across two samples.

Change-Id: I0d1cf00801732bee8e4380158d7e892758226594
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>

Conflicts:

	drivers/cpufreq/cpufreq_ondemand.c
cpufreq: boost the sampling rate on touch event

For better Ux responsiveness ondemand sampling rate
needs to be 20ms. But, a 20ms sampling rate increases power
consumption. So, boost the sampling rate to 20ms on every
touch event for 2.5 ms and later reset to default rate.
Also, change sampling down factor proportional to the
sampling rate.

Change-Id: I111b1cf3b8ed133347149afc34d329d0384ecfcb
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>

Conflicts:

	drivers/cpufreq/cpufreq_ondemand.c
d2: add xz compression support

fix compile on d2 kernel and enable in defconfig

From: "Imre Kaloz" <kaloz@openwrt.org>
Subject: Wire up support for the XZ decompressor

Wire up support for the XZ decompressor

Signed-off-by: Imre Kaloz <kaloz@openwrt.org>

Change-Id: I86d7cfa26edc433291ba5e9372b20e65e95fc970
fix compiling on Mac with non-GZIP kernel compressions

  * Non-GZIP compressions do not include the size in the file. Makefile.lib
    uses the stat command to determine the size of the file and then append
    the file size to the end of the image.
  * On BSD systems like Mac, stat does not recognize -c "%s" instead it
    needs -f "%z". This resulted in a non-booting kernel since the appended
    file size was either corrupt or 0.
  * Run both forms of stat, using whichever does not error out.

Change-Id: I95fd913074db90bb2b4afd8a2667246bea4a62e3
cpufreq: ondemand: Fix the boostpulse interface

 * Boostpulse was not working because no default frequency was set.
 * We don't need an input handler to push the freq to max, userspace
   does a better job with the Power HAL.
 * Tweak boost time to 500ms

Change-Id: Ib377e22fb4fbe5f41e85ac16806fdad9537a3077

Conflicts:

	drivers/cpufreq/cpufreq_ondemand.c
	drivers/input/touchscreen/mms_ts_144.c