ashmem: Fix ashmem_shrink deadlock.

Don't acquire ashmem_mutex in ashmem_shrink if we've somehow recursed into the
shrinker code from within ashmem. Just bail out, avoiding a deadlock. This is
fine, as ashmem cache pruning is advisory anyhow.

Signed-off-by: Robert Love <rlove@google.com>
sync: don't block the flusher thread waiting on IO

When sync does it's WB_SYNC_ALL writeback, it issues data Io and
then immediately waits for IO completion. This is done in the
context of the flusher thread, and hence completely ties up the
flusher thread for the backing device until all the dirty inodes
have been synced. On filesystems that are dirtying inodes constantly
and quickly, this means the flusher thread can be tied up for
minutes per sync call and hence badly affect system level write IO
performance as the page cache cannot be cleaned quickly.

We already have a wait loop for IO completion for sync(2), so cut
this out of the flusher thread and delegate it to wait_sb_inodes().
Hence we can do rapid IO submission, and then wait for it all to
complete.

Effect of sync on fsmark before the patch:

FSUse%        Count         Size    Files/sec     App Overhead
.....
     0       640000         4096      35154.6          1026984
     0       720000         4096      36740.3          1023844
     0       800000         4096      36184.6           916599
     0       880000         4096       1282.7          1054367
     0       960000         4096       3951.3           918773
     0      1040000         4096      40646.2           996448
     0      1120000         4096      43610.1           895647
     0      1200000         4096      40333.1           921048

And a single sync pass took:

  real    0m52.407s
  user    0m0.000s
  sys     0m0.090s

After the patch, there is no impact on fsmark results, and each
individual sync(2) operation run concurrently with the same fsmark
workload takes roughly 7s:

  real    0m6.930s
  user    0m0.000s
  sys     0m0.039s

IOWs, sync is 7-8x faster on a busy filesystem and does not have an
adverse impact on ongoing async data write operations.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mako: touch: Simple method of boosting cpu frequency on touch

mako: touch: Do not boost touch while suspended

cpufreq: ondemand: add input_boost interface

Currently Ondemand governor handles any input event
like touch by scaling the CPU frequency to maximum
available on the target.

This change adds a new sysfs interface "input_boost"
whereby the CPU will scale to this frequency on input events.
The value of this sysfs is user defined so input events
can now be handled by scaling the CPU to lower frequencies
than target max.

Change-Id: I5428fd8797c9984b17a66b01a44557f2160e8b68
Signed-off-by: Dilip Gudlur <dgudlur@codeaurora.org>

Conflicts:
	drivers/cpufreq/cpufreq_ondemand.c

intellidemand: touchboost
acpu/regulator: lower min possible uv
cfg80211: Fix memory leak

When a driver requests a specific regulatory domain after cfg80211 already
has one, a struct ieee80211_regdomain is leaked.

Change-Id: Id28fc9861b9c911a97bd242439eabca097d76258
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Git-commit: b7566fc363e23f0efd3fa1e1460f9421cdc0d77e
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[mattw@codeaurora.org: trivially backport to the msm-3.4 kernel]
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
video: msm_fb: reduce logging level.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
kernel:sched: LOAD_FREQ (4*HZ+61) avoids loadavg Moire

LOAD_FREQ is (5*HZ+1) to avoid high load average when idle:
http://kerneltrap.org/mailarchive/linux-kernel/2007/10/3/328568

I suggest (4*HZ+61) for a better distribution.

With some seconds based load (like SSL heartbeats)
and LOAD_FREQ at (5*HZ+1) I see Moire patterns like inverse sawtooth,
since 2 or 3 probes hit the jobs (load increases quickly),
followed by several probes missing it.

A 4.61 sec interval gives optimal distribution over when within a
second a probe is taken, as .61 is close to golden ratio phi 1.618...
(test in http://ripke.com/goldenratio.c).

12*4.61 = 55.32 secs is still close to a minute,
and 13*4.61=59.93 is even closer than the current 12*5.01=60.12
(with exponents EXP_x adjusted to a ratio of 13 instead of 12).
Disable modules by default
Modules config
block: row: add magic values.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
drivers: input: 2w: add options for enable/disable 2w with power button

/sys/module/input_core/parameters/pwrkey_suspend
pwrkey_suspend = Y or N
if yes when screen goes off without touch anything 2w is enabled
otherwise if you use power button is disabled.
You can save your battery with this option on.

Conflicts:
	drivers/input/touchscreen/lge_touch_core.c
	include/linux/input/pmic8xxx-pwrkey.h
drivers: input: 2w: Improve Power Key Suspend
arch/arm/Makefile: Enable pipe compiling

-pipe

Use pipes rather than temporary files for communication between the various stages of
compilation. This fails to work on some systems where the assembler is unable to read
from a pipe; but the GNU assembler has no trouble.
mach-msm/cpufreq: set safe frequencies from config

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/cpufreq.c
Default Intelli-demand config
msm_thermal: by showp1984 squashed

msm8960_tsens: enable all thermal devices

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	drivers/thermal/msm8960_tsens.c

thermal: update upstream msm_thermal with 3-phase control

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	drivers/thermal/msm_thermal.c

thermal: add sensor id to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

thermal: check every 150ms

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

thermal: fix previous lazyness

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Revert "thermal: add sensor id to sysfs"

This reverts commit 32941c2ab7c0ffd6f61f1fc2aa9171fcefc9c290.

This was meant for multi sensor control, which will be implemented later.

msm_thermal: export if we are currently throttled

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_thermal: fix spacing throughout the whole file

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_thermal: add stats for throttling

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

thermal: Fix critical enable/disable bug from STOCK source
This fixes a critical bug which only allowed to disable the thermal guard
but not to re-enable it again. Once disabled the thermal guard would stay
off until rebooted. This allows to re-enable it again. (sysfs)

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_thermal: enable msm_thermal

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Fix  __cpuinit
cpuinit: get rid of __cpuinit [1/2]
cpuinit: get rid of __cpuinit [2/2]
mach-msm: Add msm_mpdecision squashed by showp1984

Signed-off-by: showp1984 <showp1984@gmail.com>

Conflicts:

	arch/arm/mach-msm/Kconfig

Conflicts:
	arch/arm/mach-msm/Makefile

mach-msm: Add msm_mpdecision

This currently only does the following thing:
Screen on -> CPU1 online
Screen off -> CPU1 offline

More to come.

Signed-off-by: showp1984 <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/msm_mpdecision.c

Conflicts:
	arch/arm/mach-msm/msm_mpdecision.c

mach-msm: mpdecision: small cleanup

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: add load based decision making

This now works like the mpdecision binary from QCOM.
CPU hotplugging/unplugging based on system load.

A sysfs interface will be built in with a later commit.

Signed-off-by: showp1984 <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/msm_rq_stats.c

mach-msm: mpdecision: restructure locks, add delay

The new delay allows the CPU to come up before any other action is taken.
This prevents fast plugging and also ensures the CPU hotplug process
is really done, before trying to unplug it again (or plug it).

The new locks are more efficient, and only used if necessary.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: pause if CPU is unplugged outside of mpdecision

This fixes cpu wars if something else tries to control the cpus.
default delay: 10000ms

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: change early_suspend_level to blank_screen

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: don't start immediately

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: show cpumask after up/down

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: always set the suspend var

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: remove up/down delay, our default delay is large enough

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: add email to (c)

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: fix foreign hotplug/unplug detection

Signed-off-by: showp1984 <showp1984@gmail.com>

Conflicts:

	arch/arm/mach-msm/msm_mpdecision.c

mach-msm: mpdecision: show how long the cpu was online

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: rename msm_mpdec_suspend to msm_mpdec_cpudata

Since this is being used for more than suspend stuff the old name
just isn't accurate anymore.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: add sysfs interface

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: remove debug output

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: increase startdelay for sense

Surprise! Sense needs a lot longer to boot up than aosp...

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: adjust thresholds for sense

Sense is just too hungry...

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: fix foreign cpu control detection

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: allow mpdecision to be disabled (sysfs)

This allows disabling/enabling of mpdecision over sysfs.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: increase start delay for Sense

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: increase up threshold for Sense

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: sysfs: check if cpu is offline before hotplugging it

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: don't turn off cpu1 if freq > idle

This fixes cpu1 being turned off though it is still working
with a high frequency. The idle_freq can be modified through sysfs.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: fixup: move idle block to mpdecision()

This belongs in mp_decision() because this influences the decision
mpdecision is about to make.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: don't turn on cpu1 if cpu0 freq is below idle_freq
If the clock of cpu0 is below the set idle_freq don't enable cpu1 and
disregard the runqueue value.

Signed-off-by: showp1984 <showp1984@gmail.com>

msm_mpdecision: fix check for khz/mhz value (idle_freq sysfs)

Signed-off-by: showp1984 <showp1984@gmail.com>

msm_mpdecision: add debug output

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make mpdecision() core independent

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make msm_mpdec_work_thread() core independent

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix get_slowest_cpu()

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make debug output more compact & informative

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: decrease startup delay

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: decrease decision delay

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: update core data on first call

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: don't let msm_mpdec_work_thread() run if we are still booting

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make earlysuspend/lateresume core independent

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: update header to include full feature list

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: export the new, larger nwns/twts arrays to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix disabling mpdecision over sysfs for multicore

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: remove useless locking

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: use own workqueues

This will alter mpdecision to alloc it's own wq rather than using
the predefined queue which is a shared resource.

The WQ is not bound to the issuer CPU (=high-priority), has a
rescue worker task and is freezable.
Also destroy the workqueue on exit, and rename msm_mpdec to
msm_mpdec_init.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: cancel/resume main work thread on ES/LR

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: use unique lock names

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add max/min cpu limits to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: use CONFIG_NR_CPUS for max_cpu sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: decrease delay between checks to 70ms

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add get_rate()

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix merge errors

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: various fixes and tweaks

- fix get_slowest_cpu_rate(): don't cut off rate to int
- fix get_slowest_cpu_rate(): don't use values from an offline cpu
- fix get_slowest_cpu(): don't return cpu0.
- tweak hotplug thresholds

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: disable debug

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: when returning from sleep, start immediately

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: we can't turn off cpu0

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: turn on cpu1 early

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: on resume pull up cpu1

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: tweak hotplug values

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdecision: don't use sleep, cancel/resume wq instead

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdecision: checking every 100ms is enough

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdecision: update copyright

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Revert "mpdecision: don't use sleep, cancel/resume wq instead"

This reverts commit 4b6f8555481d2c5049eb7cb496283749ed7cd7ca.

msm_mpdecision: add stats & expose to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix sleep, don't use pause

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix spacing across the whole file
In the past year this evolved to a battlefield of tabs, spaces and different sizes of them. Fix that.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: stats: if cpu is online, add current ontime to stats

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add input event boost [read more]

This adds an input event boost to mpdecision.
It will basically boost the min freq of all cpus to predefined values if an
input event is detected.
Devices that qualify as boosters must fullfill one of these conditions:
- contain touch in their name
- contain keyboard in their name
This also boosts cpus independently from each other. Meaning:
If a cpu is hotplugged after the boost of another cpu was initiated the next
boost pulse will boost that cpu too.

Sysfs interface underway.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add sysfs interface for input event boost

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: input event boost: fix not resetting boost if cpu was unplugged before

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: tune hotplug values

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost: detect changed min frequency and update accordingly

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost: don't schedule more check than needed

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: increasing the check delay to 130ms
This change brings us down from 10 to 8 checks each second. The input boost reacts without
delay which is why we don't need to check for hotplugs so often anymore.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: change frequencies for input boost
This should provide us with a more battery friendly setup in light
usage situations while it still provides the obvious advantages
the input boost gives us (faster reaction).

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: min_cpus & max_cpus should on/offline affected cpus

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: several changes [read more]
reworked cpu_up/down handling which removed redundant code
reworked max/min_cpus settings
reworked suspend/resume handling to obide by these new changes
also reworked locking for per cpu settings

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix changing boost freq sets min = boost freq

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost: if we are not boosted, revib_wq does not need to run at all

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add fb callback, keep earlysuspend

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

thermal/mpdec: export throttle indicator and don't input boost if we are throttled

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	drivers/thermal/bricked_thermal.c

msm_mpdecision: switch to lcd callback and improve sus/res code

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: remove per_cpu suspend value
This is unneccessary and produces overhead when checking/setting over loops

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: offload definitions to header

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/msm_mpdecision.c

thermal: when we restore the original limits use the norm_min freq from mpdecision inputboost

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix definitions for earlysuspend/lcd callback switch

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix whitespaces throughout the file to comply with linux coding styles

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/msm_mpdecision.h

msm_mpdecision: early continue get_slowest_cpu() and _rate() to save some cycles

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: move startdelay to init to save cycles on each work call

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: also verify that boost frequencies are > minfreq

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix boost_time not respecting sysfs changes
This fixes issue #17

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add missing #ifdefs around thermal related code
This fixes issue #19 (compilation without thermal)

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add input boost triggers
This fixes issue #27 - No boost event triggered
&
issue #28 - Power button should trigger boost_freq

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: set idle_freq arch specific
This fixes issue #31 - idle frequency needs changing when switching archs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix early_suspend compilation

This was not changed because we do not compile with early suspend
and hence didn't encounter any errors. Fix it.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add locking to early_suspend related code, even if we do not use it

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: opt out early if we are thermal throttled

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost freqs are arch dependent too

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>
MP Decision config