ASoC: wcd9xxx: Synchronize button press with notifiers

Button press handler and event notification handler needs
to be syncronized so that they do not interfere in the
excution leading to incorrect register writes or threshold
updates.

CRs-Fixed: 637805
Change-Id: I51ebf1d546aa59e219ce71517970b35730589b6c
Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Avoid enabling button polling from event notify handler

During insertion, it is possible that recording is already
enabled from handset which will switch to headset. During
POST_MICBIAS_2_ON event, though button polling is not actually
enabled, due to polling_active becomes true, the event
notification handler pauses and re-starts button polling.
This could lead to unknown state for button polling state
machine.

CRs-Fixed: 639116
Change-Id: Ie379e5ff58c2e99f8e21e534cbcdb914bc98b7ec
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
asoc: msm8974: Properly configure MBHC

 * Fix all the headset issues including:
   - Headsets detected as headphones
   - Headphones detects as headsets
   - Buttons not working properly on all headsets
   - False redetection when volume is at max

Change-Id: I270c6601e08cae0580794ca452ee2799d13c558b
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Trying stock mpdecision

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "sched: fix race between try_to_wake_up() and move_task()"

This reverts commit c418db8d575af29675f13aeec1630e90443b5d8b.

Change-Id: Ice3b1d449ae6174969076a8011be32c791fd2383
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
video: mdss: Revert recent changes

 * Some instability is introduced with this patchset. Revert for now
   while the issue is debugged.

Revert "msm: mdss: refactor MDSS idle power collapse logic"

This reverts commit a90a739b1eb5b9ef9075ba2ce7d978e1f0e52d3e.

Revert "msm: mdss: reset runtime status upon device resume"

This reverts commit 4c937e815f584ba0e0d58715b965d19ae4b3e2c7.

Revert "msm: mdss: support reduced dspp and WB interfaces"

This reverts commit 4f15ba557dcddd92f4ecfd422cd6f9b35b144fcf.

Revert "mdss: display: move mdss_mdp_irq_enable out of clk_lock scope"

This reverts commit 8034f4882388f95e519f1194cc63a13be9417af8.

Revert "msm: mdss: reset cont splash screen flag after notifying panel intf"

This reverts commit 502d833be18295e9aab918e941686fc140296906.

Change-Id: I358256feeffdde8b5dbd804bf79b1c83082a40d7
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
crypto: msm: add suspend/resume callback for qcedev driver

Make chanegs to add suspend/resume callback for qcedev driver, and
disable ce clocks when entering suspend and re-enable clocks in resume.

Change-Id: Ibeab1e7cb531af79ae973d7ff0d0ed2d776f6d6f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: William Clark <wclark@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
crypto: msm: Fix SHA-1/256 zero length input data issue

Crypto module generating wrong hash value for zero length input data
using SHA1 and SHA256 functions. This patch fixes the issue to generate
proper hash value.

Change-Id: I795969cf2d3e3887064d56e35cbb488937051ac8
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Do not return invalid power stats when the device is off

adreno_power_stats() was returning unitialized data when the device
state was not active. Leave early from the function if the device
is not active and return 0s instead.

Change-Id: Ic0dedbadf6201cadb4472327c4ce7f9d9d32b82d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mmc: core: Fix null pointer dereference due to race conditions

Fix race condition between mmcqd thread and the mmc_queue_suspend
updating a shared variable mq->flags, which can lead to potential
null pointer dereference as following-

Unable to handle kernel NULL pointer dereference at
virtual address 00000020
pgd = c0004000
[00000020] *pgd=00000000
mmcqd/0:  186] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
CPU: 0    Tainted: G        W     (3.4.0-1251694-eng #1)
PC is at mmc_blk_err_check+0x20c/0x3b8
LR is at mmc_start_req+0x198/0x718

cpu0		|	cpu1
x |= 1		|	x |= 2

final value of x can be x = 1 or x = 2

Change-Id: Ie0fff6d6dba5aebb3584cba9fb98de24515c4cd8
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
net: Zeroing the structure ethtool_wolinfo in ethtool_get_wol()

memset() the structure ethtool_wolinfo that has padded bytes
but the padded bytes have not been zeroed out.

Change-Id: If3fd2d872a1b1ab9521d937b86a29fc468a8bbfe
Signed-off-by: Avijit Kanti Das <avijitnsec@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
n_tty: Fix n_tty_write crash when echoing in raw mode

The tty atomic_write_lock does not provide an exclusion guarantee for
the tty driver if the termios settings are LECHO & !OPOST. And since
it is unexpected and not allowed to call TTY buffer helpers like
tty_insert_flip_string concurrently, this may lead to crashes when
concurrect writers call pty_write. In that case the following two
writers:
* the ECHOing from a workqueue and
* pty_write from the process
race and can overflow the corresponding TTY buffer like follows.

If we look into tty_insert_flip_string_fixed_flag, there is:
  int space = __tty_buffer_request_room(port, goal, flags);
  struct tty_buffer *tb = port->buf.tail;
  ...
  memcpy(char_buf_ptr(tb, tb->used), chars, space);
  ...
  tb->used += space;

so the race of the two can result in something like this:
          A                             B
   __tty_buffer_request_room
                                  __tty_buffer_request_room
   memcpy(buf(tb->used), ...)
   tb->used += space;
                                 memcpy(buf(tb->used), ...) ->BOOM

B's memcpy is past the tty_buffer due to the previous A's tb->used
increment.

Since the N_TTY line discipline input processing can output
concurrently with a tty write, obtain the N_TTY ldisc output_lock to
serialize echo output with normal tty writes. This ensures the tty
buffer helper tty_insert_flip_string is not called concurrently and
everything is fine.

Note that this is nicely reproducible by an ordinary user using
forkpty and some setup around that (raw termios + ECHO). And it is
present in kernels at least after commit
d945cb9cce20ac7143c2de8d88b187f62db99bdc (pty: Rework the pty layer to
use the normal buffering logic) in 2.6.31-rc3.

js: add more info to the commit log
js: switch to bool
js: lock unconditionally
js: lock only the tty->ops->write call

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I9e235db6ec2bb950f26bd8a23f6145dab5dc0a15
Git-commit: 4291086b1f081b869c6d79e5b7441633dc3ace00
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Avijit Kanti Das <avijitnsec@codeaurora.org>
[rsiddoji@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Ravi Kumar S <rsiddoji@codeaurora.org>

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm_bam_rmnet: Fix potential memory corruption

Usage of legacy string manipulation function sprintf could lead to
memory corruption as the number of bytes to be written to the
destination is not bounded. Replace sprintf with snprintf where the
number of bytes to be written is explicitly specified.

CRs-fixed: 672202
Change-Id: Iab7516ad0e2540eb619fe96e26a3516c7adf86cc
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: qdspv2: Fix junk characters in session name

Initialize MVM session name array to zero to avoid junk
characters at the end.

Change-Id: I441e5dbeb4052c937bb99f9c4c96a91c410db553
CRs-fixed: 702741
Signed-off-by: Karthik Reddy Katta <a_katta@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: qdsp6v2: Add a new waitqueue state for mem map/unmap

All of the commands being sent to the DSP are using cmd_state flag
which can be overwritten when several commands are sent at the same
time. This results in Memory map command timing out. The change will
separate the memory flag from flags for other commands so that they
do not overwrite each other.

Change-Id: If42ff7c34180eb0004c97ffc0eb656f0c30be0d8
CRs-fixed: 673781
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
arm/dt: Set capless mode for MICBIAS2

 * Improves impedance detection accuracy.

Change-Id: Icbefdd80cb00518a350f19203fb4cf1378604b8f
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "input: touch: synaptics: Reset the device when blanking display"

This reverts commit e1786f2ab98c5d1062b33959ebd9523609c9468f.

Change-Id: Ic2db4b74cc10cf32f320388401aa2dcb40b14824
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
arm/dt: Don't mess with vdd during idle screen PC

 * This is causing problems with our touchscreen. Don't
   mess with this regulator as it can cause mass chaos
   due to desync between panel and TS.

Change-Id: Ibfdc6455bf1ae003811bf60d01fcc1a6639559d2
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "arm/dt: Set capless mode for MICBIAS2"

This reverts commit 89acc87ffad89733ea0701fa019ab7f35517ab46.

Change-Id: I19e9aeb9b0dafbc63730825919f83cf3910e9bfc
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "Trying stock mpdecision"

This reverts commit 4da2927e55c7830bc3dbb7a10a79e49120f89589.