Fast Sleep, wake lock timer change. (wistilt2)
ashmem: fix deadlock when system is low on memory(DjNoXD)
Increase readahead to some more reasonable values (franciscofranco)
VM twreaks
USB: f_mass_storage: Disable write cache support
ashmem: Fix flush routine of ashmem

The ashmem flush function ashmem_flush_cache_range was calling
dmac_clean_range and dmac_flush_range with a user virtual address
which is not allowed. Instead of calling dmac_clean_range or
dmac_flush_range use flush_cache_user_range which can be called
with a user vitual address.

Change-Id: I5dd137fb248b45ef2c7ea5f7bdb4b540b8310af9
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
sched: Do not block when waiting to free old root domain

Instead of calling synchronize_sched(), directly invoke
call_rcu_sched() which will not block the cpu hotplug
operation but will call free_rootdomain when the rcu
process is complete. This is safe because the root
domains are allocated dynamically so any new readers
will have pointers to the new data and the new data
does not overwrite the old data.

This is a partial backport from 3.0.0 kernel.
I did not backport the dynamic allocation of the sched
domain and sched group data structures.  This would
require inclusion of 10 other patches and would not be
stable.

dce840a08702bd13a9a186e07e63d1ef82256b5e
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date:   Thu Apr 7 14:09:50 2011 +0200

    sched: Dynamically allocate sched_domain/sched_group data-structures

    Instead of relying on static allocations for the sched_domain and
    sched_group trees, dynamically allocate and RCU free them.

    Allocating this dynamically also allows for some build_sched_groups()
    simplification since we can now (like with other simplifications) rely
    on the sched_domain tree instead of hard-coded knowledge.

    One tricky to note is that detach_destroy_domains() needs to hold
    rcu_read_lock() over the entire tear-down, per-cpu is not sufficient
    since that can lead to partial sched_group existance (could possibly
    be solved by doing the tear-down backwards but this is much more
    robust).

    A concequence of the above is that we can no longer print the
    sched_domain debug stuff from cpu_attach_domain() since that might now
    run with preemption disabled (due to classic RCU etc.) and
    sched_domain_debug() does some GFP_KERNEL allocations.

    Another thing to note is that we now fully rely on normal RCU and not
    RCU-sched, this is because with the new and exiting RCU flavours we
    grew over the years BH doesn't necessarily hold off RCU-sched grace
    periods (-rt is known to break this). This would in fact already cause
    us grief since we do sched_domain/sched_group iterations from softirq
    context.

    This patch is somewhat larger than I would like it to be, but I didn't
    find any means of shrinking/splitting this.

    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Nick Piggin <npiggin@kernel.dk>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Link: http://lkml.kernel.org/r/20110407122942.245307941@chello.nl
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

Signed-off-by: Maya Spivak <mspivak@codeaurora.org>
(cherry picked from commit 09d39b8ade298ffed33597926a1b30f4609400a6)

Change-Id: I7305af949900919f06cf3444daf1183370aa07b7
Signed-off-by: Swetha Basineni <sbasin@codeaurora.org>
partition_sched_domains: Do not destroy old sched domain on cpu_up

This is safe on a cpu_up only. Although a reader may still have
access to the old scheduling domain data, the data indicates that
the new CPU is not up, and therefore the only limitation is the
new CPU will not be schedulable by that reader until that reader
receives the new data.

Signed-off-by: Maya Spivak <mspivak@codeaurora.org>
(cherry picked from commit f963077fba323bd06814639a691bd905006bb541)

Change-Id: I15b3e0fd8c182e14db1c14f2a45b467f24d41cc5
Signed-off-by: Swetha Basineni <sbasin@codeaurora.org>
power: fix lcd resume taking long time with an ongoing file copy

This fixes the issue where LCD takes a long time to come back up
since the execution of backlight on and late_resume works by the
suspend worker thread is delayed due to one (or more) of the
sys_sync calls in early_suspend and suspend paths taking a long
time (sometimes 15sec or more) for the below reported scenario(s):

Scenario 1 (copy with usb connected):
1. plug usb
2. adb shell
3. busybox cp /sdcard/file1 /sdcard/file2 (copy >= 100MB file1
   in sdcard/emmc to file2 in sdcard/emmc)
4. press end key to suspend
5. press end key again and it takes a long time for LCD to come
   back up

Scenario 2 (background copy):
1. plug usb
2. adb shell
3. busybox cp /sdcard/file1 /sdcard/file2 & (copy >= 100MB file1
   in sdcard/emmc to file2 in sdcard/emmc)
4. disconnect usb
5. press end key to suspend
6. press end key again and it takes a long time for LCD to come
   back up

A more common form of Scenario 2 is for the user to just use the
copy function on the UI to copy large file(s).

We address this by moving sys_sync calls to a separate workqueue
and having a timeout polling based mechanism to bail out of suspend
in case of user invoking a wakeup event (like end key press) while
we are waiting for the sys_sync completion at the synchronization
point in suspend worker thread context.

CRs-Fixed: 283994
(cherry picked from commit 28244e07afcb5dc3bc6803432c4210745452b292)

Change-Id: Iec35dd7bdd7cf89e3c2608422e26cadf19bc28f2
Signed-off-by: Sunil Joseph <sunilj@codeaurora.org>
Signed-off-by: Raj Kushwaha <rajk@codeaurora.org>
sched_fair: Remove cpu from nohz idle set if not active

Currently, when determining which cpu should do load balancing in nohz
mode, we still consider cpus that have been hotremoved. This is a
problem because, if we decide to try and move the load balancing to a
hotremoved cpu, we will spin and stop doing load balancing at all. This
will also make us cease doing any idle power collapse until the cpu has
been brought back online.

Fix this by removing a cpu from the nohz idle mask if we find that it
isn't active when we consider it for load balancing.

Change-Id: I93a86fdcab88964a452cb3f38e4815db13d0ee6c
CRs-Fixed: 290042
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
Signed-off-by: Raj Kushwaha <rajk@codeaurora.org>
power: fix suspend_sys_sync_wait()

Since the workqueue code deletes the work before executing it,
checking for no work item being currently queued to the workqueue
is not sufficient to guarantee that all the works have finished
execution.

Use a counter to guarantee that all the pending suspend_sys_sync()
works have finished execution before returning from
suspend_sys_sync_wait().

Change-Id: I2f1e0b622cc050aa287ee941c351d3ce3b47cfdf
CRs-Fixed: 293595
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
Signed-off-by: Raj Kushwaha <rajk@codeaurora.org>
mtd: msm_nand: Allow CPU to take ownership of oob buffer while page read

In msm_nand_read_oob() while checking for an erased page the
ownership of the oob buffer is with DMA and CPU might read
corrupt data to decide upon erased page. The exact contents will
be updated only after dma_unmap_page() is called. Fix this by giving
ownership to CPU before checking for erased page.

CRs-Fixed: 285705
Signed-off-by: Sujith Reddy Thumma <sthumma@codeaurora.org>
(cherry picked from commit 7316b6561180820ca2198d137bc92c3e09e71738)

Change-Id: I8f29f26d0886af12bf61213a3020936da7185845
Signed-off-by: Sunil Joseph <sunilj@codeaurora.org>
msm: dma: use __raw variants of readl/writel

Change-Id: I097d0d9707287ffc09e812487bc69554d5254b6c
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
msm: dma: vote for ebi1 clock

Previously if we entered power collapse while an ADM transfer was
occuring, the RPM could put EBI into self-refresh. ADM accesses to EBI
during this time would cause bus errors, which would make the transfer
fail. Vote for ebi1_clk during transfers so this doesn't happen.

CRs-Fixed: 288571
Change-Id: I673250c0a2f5cb25faec0141c5661ef609ae1610
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
msm: dma: Enable clock while initializing datamover

Previously we were not enabling the clock before we wrote to
configuration registers at boot time. This causes resets if the clock is
not turned on by default.

Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
(cherry picked from commit c5ec507a0dda16a9eb9897a620f529bfb9353d0e)

Change-Id: I5ce1fbaafb2644d5f602a336698411131086ce5d
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
Clean bma150 sensor init dmesg
Bluetooth: Fix NULL pointer dereference with hu->proto

Set the bit HCI_UART_PROTO_SET after successful completion of hci_
uart_set_proto. In case of incoming packet before HCIUARTSETPROTO
is completed, hci_uart_tty_receive returns after testing bit
HCI_UART_PROTO_SET avoiding NULL pointer dereference.

Change-Id: I43ab351a5ed46b96cabbab8a917a7585bf8db455
CRs-Fixed: 286489
Signed-off-by: Ankit Verma <ankitv@codeaurora.org>
bluetooth-power: Don't change state on error

bluetooth_toggle_radio() maintains the previous state of the
bluetooth power regardless of whether or not the power_control
callback returns an error. If an error occurs, this can lead to
incorrectly tracking the state of the device leading to
incorrectly calling regulators and xo voting functions.

This leads to crashes like:

[<c01849d8>] (__msm_xo_mode_vote+0x30/0x12c) from [<c0184c20>]
[<c0184c20>] (msm_xo_mode_vote+0x58/0xb8) from [<c0176f90>]
[<c0176f90>] (bluetooth_power+0x128/0x1ac) from [<c0548720>]
[<c0548720>] (bluetooth_toggle_radio+0x28/0x38) from [<c07072f4>]
[<c07072f4>] (rfkill_set_block+0x108/0x1cc) from [<c07078cc>]
[<c07078cc>] (rfkill_state_store+0x68/0x7c) from [<c03ff804>]
[<c03ff804>] (dev_attr_store+0x1c/0x20) from [<c027b3f0>]
[<c027b3f0>] (sysfs_write_file+0x108/0x13c) from [<c022986c>]
[<c022986c>] (vfs_write+0xac/0x154) from [<c02299c0>]
[<c02299c0>] (sys_write+0x3c/0x68) from [<c0101280>]

which can be fixed by checking the return code of power_control.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit efd62b7a91ca19d2acb78019dc3a7c378f06be30)

Change-Id: I83dc9cfd3f56ab1457694c72de0f5004ec8aaea8
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>