msm_serial_hs: Fix unbalanced spinlock and leak of irq

If clock vote fails on msm_hs_request_clock_on(), it should get a spin lock.
But it didn't before and it caused the unbalanced spinlock.

And if clock vote fails on probe(), it didn't free the wake_irq. So fix it
also.

Change-Id: I508eb09efe1f35b6955618ef41661bf61bc4d6cf
Signed-off-by: Devin Kim <dojip.kim@lge.com>
arm/dt: dory: Allow uart to request a bus arbitration on both active & sleep

The UART for BT might request a bus arbitration on sleep also. In the case,
it might cause  a sysnoc crash before. So allow uart to request a bus
arbitration on both active & sleep to avoid the crash.

Change-Id: I76082651faad3430e2c47ceb3804eb8aa7f5a1d0
Signed-off-by: Devin Kim <dojip.kim@lge.com>
ARM: dory: disable debug options

Kernel debugging config options have found to be the cause
of longer than desired suspend/resume times. By turning these
off, the round trip time goes from 340 to 240ms, which helps
reduce average current when the device goes in and out of
suspend.

Bug: 15910797
Change-Id: I325d00e8ba5573d29a8ee5017d3c7c0a04433f3d
Signed-off-by: Simon Wilson <simonwilson@google.com>
ARM: dory: re-enable CONFIG_SERIAL_MSM_HSL_CONSOLE

This is needed for serial console debugging.

Bug: 15910797
Change-Id: Ie14ed45b522307e044376095d3b10a30a244dac1
Signed-off-by: Simon Wilson <simonwilson@google.com>
ARM: lge: read the uart console status from cmdline

Bootloader gives kernel the uart console status via cmdline. Kernel
can use it to control the uart console

Change-Id: I85d455e4b0ebe420cc4381f09302fda235c18d3f
Signed-off-by: Devin Kim <dojip.kim@lge.com>
ARM: dory: Set the gpio configuration for uart console

Set the gpios for uart to the uart funtion only if the uart console is
enabled. Otherwise, set the gpios to pull-downed gpios.

Change-Id: I834b7592fec89ad73a04b105f02bd258a1b78dbb
Signed-off-by: Devin Kim <dojip.kim@lge.com>
iio: imu: inv_mpu6515: fix mutex issue on suspend abort

If the kernel suspend cycle makes it past the Invensense driver's
suspend routine, but the suspend cycle aborts before Invensense's
driver's suspend_noirq handler is called, the Invensense sensor
driver would be left in a state where it will ignore all sensor
interrupts until the next time the kernel successfully suspends.

Bug: 16356062
Change-Id: Ie911ca2710d7146e046eba82ef804ba46afeb4be
Signed-off-by: Nick Vaccaro <nvaccaro@google.com>
net/l2tp: don't fall back on UDP [get|set]sockopt

The l2tp [get|set]sockopt() code has fallen back to the UDP functions
for socket option levels != SOL_PPPOL2TP since day one, but that has
never actually worked, since the l2tp socket isn't an inet socket.

As David Miller points out:

  "If we wanted this to work, it'd have to look up the tunnel and then
   use tunnel->sk, but I wonder how useful that would be"

Since this can never have worked so nobody could possibly have depended
on that functionality, just remove the broken code and return -EINVAL.

Change-Id: Ia8299b0046a6997feac4f0e0c3e4daf65affd617
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: James Chapman <jchapman@katalix.com>
Acked-by: David Miller <davem@davemloft.net>
Cc: Phil Turnbull <phil.turnbull@oracle.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ARM: lge: Add earjack debugger

This controls the pins for the UART console. It will enable the uart console
only if earjack debugger is connected.

If you want to use the uart console regardless the earjack connection,
set 'always_enable' to 1 for this sysfs.

echo 1 > /sys/devices/earjack-debugger.69/always_enable

Change-Id: Ib1f0368b26992651046caffd1b14332d72851ddd
Signed-off-by: Devin Kim <dojip.kim@lge.com>
arm/dt: dory: Support earjack debugger

Change-Id: I7c12a6ddacbe56c3180c86d9af26e8c38b5f33d7
Signed-off-by: Devin Kim <dojip.kim@lge.com>
staging: binder: add vm_fault handler

An issue was observed when a userspace task exits.
The page which hits error here is the zero page.
In binder mmap, the whole of vma is not mapped.
On a task crash, when debuggerd reads the binder regions,
the unmapped areas fall to do_anonymous_page in handle_pte_fault,
due to the absence of a vm_fault handler. This results in
zero page being mapped. Later in zap_pte_range, vm_normal_page
returns zero page in the case of VM_MIXEDMAP and it results in the
error.

BUG: Bad page map in process mediaserver  pte:9dff379f pmd:9bfbd831
page:c0ed8e60 count:1 mapcount:-1 mapping:  (null) index:0x0
page flags: 0x404(referenced|reserved)
addr:40c3f000 vm_flags:10220051 anon_vma:  (null) mapping:d9fe0764 index:fd
vma->vm_ops->fault:   (null)
vma->vm_file->f_op->mmap: binder_mmap+0x0/0x274
CPU: 0 PID: 1463 Comm: mediaserver Tainted: G        W    3.10.17+ #1
[<c001549c>] (unwind_backtrace+0x0/0x11c) from [<c001200c>] (show_stack+0x10/0x14)
[<c001200c>] (show_stack+0x10/0x14) from [<c0103d78>] (print_bad_pte+0x158/0x190)
[<c0103d78>] (print_bad_pte+0x158/0x190) from [<c01055f0>] (unmap_single_vma+0x2e4/0x598)
[<c01055f0>] (unmap_single_vma+0x2e4/0x598) from [<c010618c>] (unmap_vmas+0x34/0x50)
[<c010618c>] (unmap_vmas+0x34/0x50) from [<c010a9e4>] (exit_mmap+0xc8/0x1e8)
[<c010a9e4>] (exit_mmap+0xc8/0x1e8) from [<c00520f0>] (mmput+0x54/0xd0)
[<c00520f0>] (mmput+0x54/0xd0) from [<c005972c>] (do_exit+0x360/0x990)
[<c005972c>] (do_exit+0x360/0x990) from [<c0059ef0>] (do_group_exit+0x84/0xc0)
[<c0059ef0>] (do_group_exit+0x84/0xc0) from [<c0066de0>] (get_signal_to_deliver+0x4d4/0x548)
[<c0066de0>] (get_signal_to_deliver+0x4d4/0x548) from [<c0011500>] (do_signal+0xa8/0x3b8)

Add a vm_fault handler which returns VM_FAULT_SIGBUS, and prevents the
wrong fallback to do_anonymous_page.

CRs-Fixed: 673147
Change-Id: I43730a51b6c819538b46c5e4dc5c96c8a384098d
Signed-off-by: Vinayak Menon <vinayakm.list@gmail.com>
Patch-mainline: linux-arm-kernel @ 06/02/14, 18:17
Signed-off-by: Vignesh Radhakrishnan <vigneshr@codeaurora.org>
ARM: lge: Read the lge.earjack-debugger from cmdline

If the cmdline has 'lge.earjack-debugger=always', earjack-debugger is always
enabled as default. It would be helpul if you want to see the log during
bootup.

Change-Id: I0107d3a5c1a78d8fa2d74400386d705aeb9ce851
Signed-off-by: Devin Kim <dojip.kim@lge.com>
sched: Window-based load stat improvements

Some tasks can have a sporadic load pattern such that they can suddenly
start running for longer intervals of time after running for shorter
durations. To recognize such sharp increase in tasks' demands, max
between the average of 5 window load samples and the most recent sample
is chosen as the task demand.

Make the window size (sched_ravg_window) configurable at boot up
time. To prevent users from setting inappropriate values for window
size, min and max limits are defined. As 'ravg' struct tracks load for
both real-time and non real-time tasks it is moved out of sched_entity
struct.

In order to prevent changing function signatures for move_tasks() and
move_one_task() per-cpu variables are defined to track the total load
moved. In case multiple tasks are selected to migrate in one load
balance operation, loads > 100 could be sent through migration notifiers.
Prevent this scenario by setting mnd.load to 100 in such cases.

Define wrapper functions to compute cpu demands for tasks and to change
rq->cumulative_runnable_avg.

Change-Id: I9abfbf3b5fe23ae615a6acd3db9580cfdeb515b4
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
sched: window-stats: Fix overflow bug

Multiplication over-flow possibility exists in update_task_ravg() when
updating task's window_start. That would lead to incorrect accounting
of task load. Fix the issue by using 64-bit arithmetic.

CRs-Fixed: 665706
Change-Id: I92651c41efa6121bb8fe102e495ae956127b237a
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
sched_clock: Avoid corrupting hrtimer tree during suspend

During suspend we call sched_clock_poll() to update the epoch and
accumulated time and reprogram the sched_clock_timer to fire
before the next wrap-around time. Unfortunately,
sched_clock_poll() doesn't restart the timer, instead it relies
on the hrtimer layer to do that and during suspend we aren't
calling that function from the hrtimer layer. Instead, we're
reprogramming the expires time while the hrtimer is enqueued,
which can cause the hrtimer tree to be corrupted. Furthermore, we
restart the timer during suspend but we update the epoch during
resume which seems counter-intuitive.

Let's fix this by saving the accumulated state and canceling the
timer during suspend. On resume we can update the epoch and
restart the timer similar to what we would do if we were starting
the clock for the first time.

Change-Id: Iee2a1cca42e5b681347ea0607e9af420a63892d7
CRs-Fixed: 696826
Fixes: a08ca5d1089d "sched_clock: Use an hrtimer instead of timer"
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: mdss: Fix typo of 'qcom,mdss-dsi-low-fps-mode-off-command-state'

Change-Id: I259d547cc3fbcad42f759fa12fbdc280c294c5ef
Signed-off-by: Devin Kim <dojip.kim@lge.com>
touch: synaptics: change default palm key to KEY_SLEEP

Change-Id: Iee93b8cdf2e1e4379f317a17b96c1e4587af702e
Signed-off-by: Simon Wilson <simonwilson@google.com>
arm/dt: dory: change palm key to KEY_SLEEP

Change-Id: I6ad8d793c50525fe0967c6a0e0e78aff73fd8374
Signed-off-by: Simon Wilson <simonwilson@google.com>
net: ipv6: ping: Use socket mark in routing lookup

Change-Id: I5a61e0f9f22f193c51b1aafd270fb0642a2e0fab
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net: ipv6: autoconf routes into per-device tables

Currently, IPv6 router discovery always puts routes into
RT6_TABLE_MAIN. This causes problems for connection managers
that want to support multiple simultaneous network connections
and want control over which one is used by default (e.g., wifi
and wired).

To work around this connection managers typically take the routes
they prefer and copy them to static routes with low metrics in
the main table. This puts the burden on the connection manager
to watch netlink to see if the routes have changed, delete the
routes when their lifetime expires, etc.

Instead, this patch adds a per-interface sysctl to have the
kernel put autoconf routes into different tables. This allows
each interface to have its own autoconf table, and choosing the
default interface (or using different interfaces at the same
time for different types of traffic) can be done using
appropriate ip rules.

The sysctl behaves as follows:

- = 0: default. Put routes into RT6_TABLE_MAIN as before.
- > 0: manual. Put routes into the specified table.
- < 0: automatic. Add the absolute value of the sysctl to the
       device's ifindex, and use that table.

The automatic mode is most useful in conjunction with
net.ipv6.conf.default.accept_ra_rt_table. A connection manager
or distribution could set it to, say, -100 on boot, and
thereafter just use IP rules.

Change-Id: I82d16e3737d9cdfa6489e649e247894d0d60cbb1
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>

Conflicts:
	include/uapi/linux/ipv6.h