msm: lpass-8960: Avoid write to lpass wakeup register.

LPASS SSR driver has a write to lpass wakeup register as part of
lpass shutdown process. But wakeup register falls under secure
space which is not accessible by HLOS. To avoid this, the write
has been moved to NMI call now. Hence remove this write to lpass
wake register from ssr driver

CRs-Fixed: 340872
Change-Id: I30f2eae105eeea2ebb543eb57b508c30e4b4b3d0
Signed-off-by: Sriranjan Srikantam <cssrika@codeaurora.org>
(cherry picked from commit 51a43afaaa39543a02f8234e973b462276e64043)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
ASoC: wcd9310: Add plug detection through mechanical switch

Use mechanical switch on the phone jack to detect headset/headphone
insertion and removal.  Mechanical switch is beneficial to avoid fake
button press and high impedance microphone headset detection.

CRs-fixed: 341402
Change-Id: I9eab7285617b9116671e9facb39a878a8ddb464e
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
(cherry picked from commit d7cf2e931cea51c7ff0a40e6b930edf99b320d8e)
(cherry picked from commit 803e1dd6602e789eb1e0da240dc734160f330d39)

Conflicts:

	sound/soc/codecs/wcd9310.c
	sound/soc/msm/apq8064.c
	sound/soc/msm/msm8960.c
ASoC: msm8960: properly protect external mclk control function

Both audio path and MBHC accessory detection logic need master clock
enabled along with bandgap and clock block of CODEC. Clock control
is managed by the machine driver. Calls to clock control function from
audio and MBHC detection paths can be nested. As a result, reference
counter of master clock is incremen/decrement out of order and cause
master clock not enabled when audio path is enabled. Without master clock
CODEC will not consume data and this leads to SLIMBUS overflow error.

Change-Id: Ic29b9740a28256251a8fb2aaf773082562a8fe40
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
(cherry picked from commit 28f49c84acb4e691b630b26c37ab6d206109482f)
(cherry picked from commit 62bceb0052e50013ed6d2e580c125a89493b289a)
cpufreq: Separate speed target revalidate time and initial set time

Allow speed drop after min_sample_time elapses from last time
the current speed was last re-validated as appropriate for
current load / input boost.

Allow speed bump after min_sample_time (or above_hispeed_delay)
elapses from the time the current speed was originally set.

Change-Id: Ic25687a7a53d25e6544c30c47d7ab6f27a47bee8
Signed-off-by: Todd Poynor <toddpoynor@google.com>
power: bms: add desay calibration data

Add the calibration data and battery ID information for the
Desay 5200 mAh battery which is used in LiQUID platform
devices.

Change-Id: I19ff1251ee3e71fa71d4fa0c83143d4b7667a80c
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit c00baa96ddc6cf9b0f6dbd0adc490451229d40c6)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/bms-batterydata.c
	drivers/power/pm8921-bms.c
	include/linux/mfd/pm8xxx/pm8921-bms.h
Revert "power: bms: add desay calibration data"

This reverts commit c17ad1e703b9ca555ee582409b2788cbd46cdc5d.
pm8xxx-adc: fix missing interrupts

There exists situations when an adc conversion is requested very
early in the resume sequence. These requests fail to complete
because of missing interrupts and eventually cause lockups.

When an interrupt is enabled during system resume the kernel rejects
enabling these interrupts. This keeps the interrupt disabled and causes
missed interrupt. Get around this problem by not needing to enable the
interrupt. IOW, do not call disable_irq and enable_irq, only request
the irq which leaves it in enabled state.

There is a bug in the pmic where if an interrupt is masked/unmasked
it clears the pending status. This causes a nonwakeup interrupt to
be missed as it is unmasked while resuming. Mostly this is okay but
if a adc request is made early in the suspend, it causes it to miss
interrupts. Make the adc interrupt a wakeup interrupt.

The driver initializes its completion only at probe time. This may cause
incorrect end of conversions with out of sync (spurious) interrupts.
Update the code to init a completion just before issuing a conversion.

Another issue was observed where the interrupt's unmask_irq was delayed,
causing another cpu to initiate the next conversion as soon as complete was
called. This lead to a situation where the interrupt for the next request
was triggered and the unmask happened later. Call complete within a
workqueue which guarantees that unmask would have completed and
it is safe to start the next conversion.

CRs-Fixed: 350768
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit f5285a2ed7918b941ac260e078c64c534a1d0e8d)

Change-Id: I09398655caed85a8a1b3af1cd5128b8dd2470c8c
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
dm-crypt: fix possible mempool deadlock

This patch fixes a possible deadlock in mempool in dm-crypt.

Currently, dm-crypt reserves a mempool of MIN_BIO_PAGES reserved
pages. It allocates first MIN_BIO_PAGES with non-failing allocation
(the allocation cannot fail and waits until the mempool is refilled).
Further pages are allocated with different gfp flags that allow
failing.

Because allocations may be done in parallel, this code can deadlock.
Example:
There are two processes, each tries to allocate MIN_BIO_PAGES and
the processes run simultaneously.
It may end up in a situation where each process allocates
(MIN_BIO_PAGES / 2) pages. The mempool is exhausted. Each process
waits for more pages to be freed to the mempool, which never happens.

To avoid this deadlock scenario, this patch changes the code so that
only the first page is allocated with non-failing gfp mask. Allocation
of further pages may fail.

(cherry picked from commit 71b41c32bc4dc0be468435fc62e9285ee862e805)

Change-Id: I56b934a16f3056b494bdea732676debde47219c1
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
(cherry picked from commit dca62667dfdee13709698769bb5af4a58ce5fc83)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
dm-crypt: add missing error handling

There were cases where error code would be used only if we finish
processing the last sector. If there were other encryption operations
in flight, error would be ignored and bio would be returned with
success as if no error happened.

This bug is present in kcryptd_crypt_write_convert,
kcryptd_crypt_read_convert and kcryptd_async_done.

This patch fixes it, setting io->error to -EIO always when an
error happens.

(cherry picked from commit 8bfc015229efd9f2e2eb18f03176d1a9d058e3a4)

Change-Id: I384100803d46630343e4777f807e062cf686dfd7
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
(cherry picked from commit 7f7f17e8c5d0cd1aa7cc8f2b33e1d9afda1c9c45)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:

	drivers/md/dm-crypt.c
Revert "dm-crypt: add missing error handling"

This reverts commit 093f90f9555dbe494c9cb37062c58601ee60bc94.
dm-crypt: Rename pending

There are two structures that have "pending" field.
This patch renames it to "cc_pending" and "io_pending" to reduce confusion
and ease searching the code.

(cherry picked from commit 815bc97ac977a0cbccbd141f373a730374cd7882)

Change-Id: I831085b44d8910a14379e8140349bbd5747db4eb
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
(cherry picked from commit 6a82453e13fc7f65cd706649cf37e1cb06dd1874)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:

	drivers/md/dm-crypt.c
dm-crypt: move static cipher data out of per-cpu structure

Cipher information is static, so it does not have to be in a per-cpu
structure.

This is a preparation for further patches that remove per-cpu structure
altogether.

(cherry picked from commit fbd06f976a4f69bde837f7307c6ac62d0e8f8704)

Change-Id: Id717d197a894e5c05eb9d2b4c9f56982899ccdc2
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
(cherry picked from commit d3c9a8845f3086b9adf4579180654f5a1b147ddb)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:

	drivers/md/dm-crypt.c
dm-crypt: remove per-cpu structure

Remove per-cpu structure and make it per-convert_context instead.
This allows moving requests between different cpus.

CRs-Fixed: 339113

(cherry picked from commit 30c273a77c02ed9db52bd51027c812ebf513771e)

Change-Id: Icbd465144e17b51710901b1cca88577e7bcfc9c7
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
(cherry picked from commit b463d1e1f24833d3b667f2f36f86e43adbaae88c)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: camera: Fix msm_camera_i2c_poll function call

Change-Id: Ie99e61811332054b2b7e4b0f3a05a932e988729c
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
CRs-Fixed: 348564
(cherry picked from commit e14cb2fd294c6dc2a3a825255bfafe2ce4fe4386)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
usb: otg: Add support for power supply API for USB charging

With this commit, USB Driver will start using Power Supply
API rather than calling direct pmxxx driver API for USB charging.
This will allow hiding specific charger model (such as
external LTC4088 charger used for MDM9x15) from USB driver.

In case the power supply API is not support, fallback to legacy
API which uses pm8921 driver.

Change-Id: Ic0f302e3aa8aa60f6483a0fdeec9389a0ded1fac
Signed-off-by: Amit Blay <ablay@codeaurora.org>
(cherry picked from commit 0f7edf7796c170f8dc4d87e71dcd77c24c93c39a)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
USB: OTG: remove pm8921_set_usb_power_supply_type

This custom notifier is no longer required to determine
wether a wall charger is connected to the PM8921 charger
or not.

The pm8921-charger driver determines AC charging solely
dependent upon maximum input current from the charging
device.

CRs-Fixed: 339841
Change-Id: I564fa01c61286d013be6b263d038e87568a297f2
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
(cherry picked from commit 34b874562012c3453da20059094992140ca1ea61)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:

	drivers/usb/otg/msm_otg.c
msm: rmnet_bam: Handle Network TX Queue Race Condition

The netif TX queue is started and stopped based upon the watermark state
maintained by BAM DMUX.  The queue is checked after TX-enqueue
operations to disable the queue if the high watermark is hit and after
TX-dequeue operations to enable the queue if the low watermark is hit.

Without locking, this opens a race condition where the TX-dequeue check
and the call to stop the queue can happen after the write-done
completion has occurred which would restart the queue.  This results in
the queue being stopped indefinitely which results in a permanent data
stall.

(cherry picked from commit ed3ca0ab07bf58816be2e24e9710511ee0c63c78)

Change-Id: Ib2780ba372c935852a347b77888568a2a3070d86
CRs-Fixed: 347174
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit ee21be22a59b5bb782a1cce170233e74ff86bd46)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: Resolve conflicts in state changes

Only check requested state once, and fully transition to that
specific state.  This will resolve any conflicts arising from
changes to the requested_state as the state transition occurs.

Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
(cherry picked from commit e4a7c1a365ea32aebfe3995e13fc63ca8c2916c5)

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

Change-Id: I6940a054bd4f1e9e3d9e078f0fe57a2afd071102
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm_fb: hdmi: Disable 1.1_FEATURE

Some displays support Enhanced Link Verfications(1.1_FEATURE)
which makes HDMI Tx to verify Pj on every 16th frame. Three
consecutive Pj mismatch will result in HDCP authentication
failure. If 1.1_FEATURE is supported(this can be detected by
reading BCAPS), it needs to be enabled by writing into AInfo
of display. Default is disbaled.
This change sets HDMI Tx core to disable 1.1_FEATURE by
default so that we don't see Pj mismatch error unless the
feature is enabled.

CRs-fixed: 348752
Change-Id: I996f60b852a7e867e8e13e700beecbac8190a59e
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
(cherry picked from commit 97e2fcf862d913feff157f536ee14cfc5f3197f7)
(cherry picked from commit 88cb4da47697fe407b013554678ec68d7c8ab93c)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
video: msm: wfd: Reduce first frame latency in CFR mode

When we get the first frame, push it immediately to the encoder rather
than waiting for the timer to expire.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit 47ef81ffe4ffd35db48a0a8795697a910378664a)

Change-Id: If7f85e747646a5022b416d1189d5d55d16b19343
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit bf844198db86317b2e73c98dab5b2f85f08f7555)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>