msm: smd: Add SMSM state queue

To reduce the chance of missing SMSM state transitions,
push the SMSM state into a queue in the interrupt handler
and then pull the state for processing the in callback
workqueue.

Change-Id: Ib66bc15f7445369ea7ad2ca271a79ac10b8105a0
CRs-Fixed: 323725
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: smd: add separate return code if SMD port is closing

Add EAGAIN return code if SMD port has been allocated, but
is currently pending a remote close.  This allows the client
to differentiate between ENODEV (port doesn't exist)
and EAGAIN (port not ready to be opened).

(cherry picked from commit bb2b1faf7d0fd51457e6fc452eef6c52f2023c64)

Change-Id: I1b057c0e3cc36b87f2d724325304ec941fcdb536
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: smsm: Add SMSM notifier wakelock.

CRs-Fixed : 345581

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit ff461d9d828499fec86b269cc65a3cfed8c5aaac)

Change-Id: I24845f52271fa98c36ec026bbf182240e965270a
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: smsm: Add SMSM notifier wakelock

Add wakelock that is locked in the SMSM interrupt handler and unlocked
in the workqueue after notifications have been completed.

This prevents the sleep code from putting the system to sleep before the
SMSM notification workqueue gets scheduled.

Change-Id: I45c4bc210d638ebccfecef883bb62abfbf9f2a1b
CRs-Fixed: 345581
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
msm: smd: Remove duplicate variable definitions

Remove duplicate local variable definitions that cause
variable aliasing and could result in accessing a null
pointer when dealing with open-close-open race
condition.

Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 724f317cf6176d0a48a994d0f98a4fb73019e3ce)

Change-Id: Ia891810ab42aa214a12fc7be7a09ed34dfdef387
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: smd: Do not use wakelock for local DEM notifications

Notify local SMSM callback clients without using a wakelock since SMSM
signaling is used by power management during power-down/-up sequencing
on DEM-based targets.  Grabbing a wakelock in this case will abort
power-down sequencing.

(cherry picked from commit da31d046ba0c5d3d1f674e9d35a39e9d0e4ae4df)

Change-Id: I1f7e3a3ae049573baaf8866efd79ad324a248f61
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 2240228f3be50b8a0ebd60d5f36cf6314f156404)
(cherry picked from commit 32c89ee88b9e1f020ba075d3688afb4d99033799)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: smsm: Fix race condition in SMSM notification

The SMSM snapshot logic takes a snapshot of the current SMSM state,
places it into a FIFO, increments a wakelock count, and then signals a
worker to process the state changes.  The worker processes the state
changes and then decrements the wakelock count.

In the previous case, the code would do the following:

Interrupt handler:
 1) insert data into FIFO
 2) increment wakelock count

Worker:
 a) verifies >= 1 snapshots are in FIFO
 b) processes snapshot
 c) decrements wakelock reference count

If the interrupt handler is interrupted between steps 1 and 2, then the
function flow would be 1abc2.  In this case, step c would fail because
the wakelock count would be zero and the wakelock would remain at 1 and
locked even though the FIFO would be empty.  This results in the
wakelock not getting released.

To resolve this, the order of 2 (now 1') and 1 (now 2') was swapped
which always ensures 1' will always occur before abc which results in
the proper ordering 1'2'abc.

CRS-Fixed: 349099
Change-Id: I388b4c2f76838f59337e94f83b65fa06e81bb875
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 96b55f6ec25d5812a0492fc39b6b44a6141795d2)
(cherry picked from commit 8c17b69afa7f2b7eb10df635f984b15d08c71da5)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: smd: Fix race condition while processing SMSM callback

When SMSM interrupt is received, a snapshot of SMSM callback is stored
in a kfifo. The snapshot is stored as
	a) SMSM state of each subsystem
	b) Wakelock usage information.

Then a work item is scheduled in global workqueue to process the snapshot
and notify the smsm clients. The smsm snapshot is processed as
	1) Lock the snapshot
	2) Retrieve SMSM states from kfifo and process them
	3) Unlock the snapshot
	4) Retrieve Wakelock usage information from kfifo

When back-to-back smsm interrupts are received, multiple work items are
scheduled in multiple cores. The first work item performs steps 1, 2 &
3 and got pre-empted. In the meanwhile the second work item starts
with Wakelock usage information and reports wrong smsm state to the SMSM
clients.

So schedule the work items in a single thread workqueue and interchange
steps 3 & 4 while processing the SMSM snapshot.

CRs-Fixed: 353552
Change-Id: Ic08e242653cc8d1648ad7a70bf7c5f6b7c089c4e
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit 3249a223df201088289d113b80c70b9d23dea847)
(cherry picked from commit 492417630c5e4e42c09b7fe36c53dc9882a4ce4b)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: idle_stats: Detect serialized use cases.

Check for 80% CPU busy within the GPU idle time, to improve performance
of serialized use cases.

CRs-fixed: 334781
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
(cherry picked from commit 61c7719e7993a8bfa58e83294d0f6e23b7d413a1)

Change-Id: Ic1221adc2ad900f4e2520eec29fe9b69ff797c59
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: idle_stats: Reset all idle stats events

Reset all the idle stats events once the information is communicated
to userspace. If this is not done, userspace keeps receiving stale
busy timer expiry events.

CRs-fixed: 334781
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
(cherry picked from commit 586c84fa558e7820cd9283aafbced13798f664f2)

Change-Id: Ia4cd09a5419625ffb9d9716b722739b50b8cc2c5
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: clock-8x60: Add IOMMU clock aliases for the video driver

The video driver needs control of some IOMMU clocks for secure video
playback. Add the necessary aliases to the clk_lookup table.

(cherry picked from commit 966922b3dc1649163c699e9b10da236341420aaf)

Change-Id: Ibdaf3d1f05aa0dd3e1feb0a5f2a07892b0eba586
Signed-off-by: Riaz Ur Rahaman <riazr@codeaurora.org>
msm: dsps: Revise handling of PPSS_PAUSE register.

Only modify the PPSS_PAUSE register if the apps processor controls
the DSPS power state. The Linux kernel shouldn't modify the register
if the DSPS is in control of its own power state.

Also move the definition of the PPSS_PAUSE_REG address to the devices
file, since it may be different on different platforms.

CRs-Fixed: 370236
Signed-off-by: Karthik Karuppasamy <kkaruppa@codeaurora.org>
(cherry picked from commit 9dac549aa64d2d86a156a075de1656cfd38fc60a)

Conflicts:

	arch/arm/mach-msm/devices-msm8x60.c
	arch/arm/mach-msm/include/mach/msm_dsps.h
	arch/arm/mach-msm/msm_dsps.c

Change-Id: I6141df35639d77103d94c13e437161b0afe573d6
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
(cherry picked from commit 74b4dae2862acadad22d91b530dbf3dce12dbebf)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: subsystem_restart: Explicitly log the restart level.

To allow one to determine what the restart level
was at the time of the invocation of a restart
sequence, explicitly log the level in the kernel
log.

While we're here, mention the name of the subsystem
that has crashed before panic'ing.

Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
shooteru:defconfig: enable sw_sync
framebuffer: add a pollable sysfs entry for display status

Wakeup the userspace poll on change of display status. The
userspace then may take action to change the
power/performance characteristics of the device.

Change-Id: I9bd11f3d895d3d83230104f5d8dcd1deeaa754cd
Signed-off-by: Amar Singhal <asinghal@codeaurora.org>
ASoc: msm: Add support for multiple inputs to kcontrol

Adds the macro SOC_SINGLE_MULTI_EXT which allows the user
to pass the number of integer inputs accepted by the control.

Change-Id: I75009672568d1e0979ecd577031e72bd87f310d2
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
ASoC: core: Fix the suspend/resume failure

The suspend/resume schedule work fails because of the
uninsantiated sound card. The fix is to skip the
schedule work for the uninsantiated sound card.

CRs-fixed: 339411
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
(cherry picked from commit 5ab054fb0655bb0ab6820a18e931fabf69053ea9)

Change-Id: Icf303ffef9d7019c936510dc676ba83eeec84f1c
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
mmc: msm_sdcc: Power down slots after reboot

Some reboot methods (eg. adb reboot) may not power
down SDCC slots. This can result in cards being
in unexpected states after reboot. Explicitly reset
slot voltage regulator on reboot.

CRs-Fixed: 341840
Change-Id: I8cdb52bc58e34900378af468794760653f3babad
Signed-off-by: Oluwafemi Adeyemi <aadeyemi@codeaurora.org>