msm: smd_pkt: Handle wakelocks appropriately to optimize power usage

If the user-space application performs a poll() operation before a
read() operation, then release the wakelock in the read operation.
This is under the assumption that user-space application can grab a
wakelock between poll() and read() operations. If the user-space
application does not perform poll() operation at all before read()
operation, then allow the wakelock to timeout and release itself.

CRs-Fixed: 337654
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit 048ef381aca6b150953a4e6d9b196778589f8e71)

Change-Id: I3cb6e1b06dbb08522dd66dcd8f5cfe4069fefdb1
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>

msm: smd_pkt: Add packet arrival wakelock

While handling the incoming packets from remote subsystems, delay the
system suspension by holding a wakelock with a timeout value of 2 seconds.
This will allow the user-space clients to process the incoming packets
before the system goes to suspend.

(cherry picked from commit c3c5cd93233bccaff0d0230932a5e387ce8dcd4a)

Change-Id: I488f795b76c8aad546a9b14b004d6a59be63b01c
CRs-Fixed: 335782
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
Revert "shooteru: Import sweep2wake"

This reverts commit 84598ad6cde6d1ff17de003921a51bdb5fff0f5a.
Patch: Linux Kernel to 3.0.100
msm_autosmp: remove msm dependencies and rename as autosmp
generalize as autosmp for other architectures
Import Sweep2wake from coolexe's kernel
shooteru: update config
shooteru: Make tun module built-in
Revert "drivers: net: wireless: bcmdhd: Update to aosp-common-3.0"

This reverts commit 245004a3b1bc8229959030a638fa4c024fb65df3.
touchscreen: atmel: AOSP multitouch fix

SENSE doesn't need this patch

credit: agrabren
touchscreen: reduce log spam of atmel driver
and a small touch up
Sweep2Wake: Redefine some functions
Sweep2wake: Disable some debug messages
Patch: Linux Kernel to 3.0.101 (end of life)

:((
msm: rpm: Replace mutex_lock_interruptible with mutex_lock

mutex_lock_interruptible() bails on signal pending. Instead use the
mutex_lock() variant and let the caller handle the pending signal
condition.

Change-Id: Ib06953731a7e4eb367358148bde202dfbdf556df
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
(cherry picked from commit 4f3b37232a708d6e8cf2f082f95d83f49d3a730c)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>
PM / Sleep: Do not check wakeup too often in try_to_freeze_tasks()

Use the observation that it is more efficient to check the wakeup
variable once before the loop reporting tasks that were not
frozen in try_to_freeze_tasks() than to do that in every step of that
loop.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Conflicts:

	kernel/power/process.c

Change-Id: I0bd9e71b638e565773f4861899ca175f82f2a4cc
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>
lib: genalloc: Change chunk allocation to vmalloc

Change the chunk allocation from kmalloc to vmalloc for
allocations greater than a page. This allows large
chunks to be allocated from physically non-contiguous
memory and increases the chance of the allocation
succeeding.

(cherry picked from commit 0614b96dc8e4c8a0dd0db41aec5a79daa3bdf091)

Conflicts:

	lib/genalloc.c

(cherry picked from commit 64cf7183f37df623bec8f46348b11c5781d3b0cc)

Change-Id: Ied97c888b967c4433519cb47e972f7a0f2281d71
CRs-fixed: 387655
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>
fs: fat: rate limit the kernel messages

If FAT formatted SD card gets removed without unmounting,
FAT file system may throw many kernel error messages which
could too much traffic for console driver and can sometimes
even cause the system to trigger watchdog timeout.

This patch converts the printk to printk_ratelimited to rate
limit the error messages from FAT fs.

CRs-fixed: 368446
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit a872b71069d717ced1a2de642afa0693d1bb9448)

Change-Id: I3ace0ffc5a0119641dff8084adccf7ed780c7900
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>
ASoC: core: avoid scheduling delay work

ASoC framework prevents undesirable audio artifact
due to quick shutdown and startup of CODEC Rx path by
schedule delayed work. When timer expires, delayed work
callback function calls DAPM to tear down CODEC Rx path
This mechanism is undesirable when user-space application
manages shutdown of CODEC Rx path in similar fashion.
It causes false turning off of active CODEC path when
there is use case requiring co-processor manages audio use
cases while host processor goes to suspend mode. Change
power down time to 0 instead of 5 second by default.

CRs-fixed: 351956
Signed-off-by: Patrick Lai <plai@codeaurora.org>
(cherry picked from commit 95c1e67867befcbd81c7d507f31f478f7a795377)

Change-Id: I75f4a019a381dffc93807c50108dcfecb7aad50e
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>
msm: pil: Synchronize request_firmware() with suspend

Calling request_firmware() during suspend/resume operations is
buggy and error prone. Therefore a check exists in
request_firmware() to see if a suspend/resume operation is in
progress. In testing we've seen that a wakeup interrupt can come
in during suspend and trigger subsystem restart to call
pil_force_boot() before userspace has fully thawed. Since this is
not allowed the request_firmware() call from pil_force_boot()
fails with -EBUSY and the processor is never rebooted.

Register for PM notifiers to avoid calling request_firmware()
when suspend/resume is in progress. Within the notifier
synchronize any request firmware calls with suspend using a
rwsem. In the case where pil is called before suspend, the
suspend notifier should block on the down_write() during
PM_SUSPEND_PREPARE. When suspend is initiated before pil any pil
operations should block on the down_read() until suspend
finishes. Doing this should fix races between suspend/resume and
request_firmware() within PIL.

Change-Id: Id12d128a3729680b36845de7228bf3919c32a672
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>
arm: Allow saving of stacktraces from other processes

Currently, a process is only able to save its own stacktrace
due to concerns about other processes going away while the
saving is occuring. Realistaically though, hititng this
case is very unlikely and the debugging benefit outweighs
the risk. Enable saving of other stacktraces for access
through systems such as procfs.

Change-Id: I584388f6edb48431bfec8d11d217f0fdc116f73e
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Darescu Ionut <johnny@esi.ro>