msm: kgsl: Remove the 32MB padding when checking for OOM

Allow the memory to allocate up to freeram bytes of memory in any
given GPU allocation.  Previously we had enforced a 32MB buffer
zone to try to keep the system alive, but that has turned out be
too much leeway and graphics applications were dying too soon.

Change-Id: Ic0dedbadaf86e248b372b22cd3a41a5dabedb82e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
ASoC: msm/apq: Remove the dependency of AUX PCM TX to AUX PCM RX

AUX PCM interface is a bi-direction interface which RX and TX paths
share the clock and sync word. In current design, it is assumed
when TX path is activated, RX path was enabled beforehand. So the
AUX PCM clock and GPIO pin configuration is only tied to AUX PCM RX
path.  There is use case that only AUX PCM TX path is activated by
application so the AUX PCM clock and GPIOs are never configured
in this case which causes recording from AUX PCM TX failed to
capture any audio sample.

The solution is to update the clock and GPIO pin configuration to
both RX and TX path and then use an atomic reference counter to
prevent them configured twice.

CRs-Fixed: 397095
Change-Id: I23dd140c63f9a20a35811293097f54aa04790ada
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
(cherry picked from commit ae395b024194bf6ae633a67dd1c2a5b3c7f1e019)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
board: 8960-pmic: Swap mapping of camera snapshot and focus keys

Functionality is swapped on 8960 devices.

Change-Id: I2a458c40b60be583dee982bb12927a9b018fb94f
Signed-off-by: Amy Maloche <amaloche@codeaurora.org>
(cherry picked from commit ecc6aad2618ae4372903c0b7fb726183e6c7e26d)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm_fb: Make Vsync IOCTL during disable sequence as NO WAIT

Change to make the vsync IOCTL no wait during the disable sequence.
This is to increase the performance. Handle the synchronization of
vsync interrupt using state variables in drivers from now.

(cherry picked from commit 5e0fcdbf8b22bc9637413de9cd0592c159dd4e8f)

Change-Id: I2d861c4ffbea535802860c47e3e9d5a84c9d4956
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Jessica Gonzalez <jgaona@codeaurora.org>
msm_fb: Return pan_display call on Vsync interrupt

Till now, the pan_display call returns on DMA_P_DONE interrupt.
For command mode panels, the DMA transfer starts only after the
DMA engine receives a TE signal from the panel. Hence, return
pan_display ioctl on vsync interrupt to improve performance.
We still wait if the previous DMA transfer is not finished at
the beginning of next pan_display.

(cherry picked from commit 61832135cad75ef082a905fedb30d835c85611b5)

Change-Id: I2eb250c0ba87098424c03fb6ecfffcd1e62ec2c9
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Jessica Goznalez <jgaona@codeaurora.org>
msm_fb: display: Send vsync events using sysfs for MDP4 targets

Replace sending of vsync timestamp using uevents with sysfs entry
as uevent result in increase in power numbers due to broadcast in
nature. Also, for smart panel, wait4vsync is removed.

(cherry picked from commit ca47ab601b9d36b2a96685a6e93042318ebbba8b)

Change-Id: I96577a3408fa0e2e1b54cf97434ddcf75bee589c
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Jessica Gonzalez <jgaona@codeaurora.org>
msm_fb: display: Send vsync events using sysfs for MDP3 targets

Replace sending of vsync timestamp using uevents with sysfs entry
as uevent result in increase in power numbers due to broadcast in
nature.

(cherry picked from commit 4ae2fcc7a3e2f1e68efe57ea0a42e7a4b83e87da)

Change-Id: I89bebef35e04c1b5e1e5a56d26482c95f1928b68
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Jessica Gonzalez <jgaona@codeaurora.org>
rmnet_smux: fix flow control race condition

If multiple packets are written quickly and the high watermark is
exceeded, then the -EAGAIN return code is returned (A) and the code is
checked and the tx processing is throttled (B) until a low-watermark
notification is received (C).  If the packet queue is
drained and the low-watermark notification is delivered between steps
(A) and (B), then the order of events will be ACB and the tx queue will
be permanently stalled.

To fix this, a spinlock is held to ensure that the sequence is always
either ABC.

CRs-Fixed: 401544
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit cb24b09ebcf924b43e14cfbf78dcc29c98f3a79b)

Change-Id: I9b5da2ad4ee6b59df574b75537e8e796c0226e84
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: camera: remove 512 bytes limitation from ctrlcmd payload.

This change removes the 512 bytes length limitation from the
payload data passed to the server thread, as part of the control
commands.

Change-Id: I871b6a6d467f86431bb5d701784231d7142d60d2
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
Signed-off-by: Sunid Wilson <sunidw@codeaurora.org>
msm: rpm_stats: Update the base address to read rpm stats

Update the base address of the rpm sleep stats to match the address
being used by sleep stats driver on RPM. This change is needed to
allow reading of sleep stats from RPM MSG RAM.
Decrease the size of the MSG RAM for rpm_stats to 256 bytes as it
doesn't take more than that.

CRs-Fixed: 398586
Change-Id: Ia78bf817d8278b72ee8a90cb5e0f755bec23bd3d
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
(cherry picked from commit 660b4e4874c0ab39aae829fc03563f3017d626e2)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm_fb: configure LM1 and LM2 CSC coefficients with RGB2YUV for WFD

1) Initialise the LM1 and LM2 coefficients with RGB2YUV as WFD expects
these coefficients to be programmed.
2) LM2 is available from MDP ver 4.3, fix conditions accordingly
CRs-Fixed: 399462
Change-Id: Ifad2be0fb5c3c96fa1515e114097a87d250fd62a
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
(cherry picked from commit f6044334ee63fe9553f5cce8aa65c172c88e1175)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
mfd: wcd9xxx: Add WCD9304 1.2 version codec chip entry

-Add chip byte information for WCD9304 1.2 version.
 This information is required for correct detection
 of the codec at the codec init.
-Fix code to exit codec init with error, if codec
 detection fails.

Change-Id: I6b5522f6fb4d7b18011da2bedd322c4a480a5175
Signed-off-by: Venkat Sudhir <vsudhir@codeaurora.org>
(cherry picked from commit 4414deb3da8fc6cb3aeb7e8ac48083a361efdaae)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
rmnet_smux: Fix duplicate packet send

If the high watermark is exceeded, then msm_smux_write() will return
-EAGAIN and then rmnet_xmit() will return NETDEV_TX_BUSY to have the
TCP/IP stack reschedule the packet.  In the case where the high
watermark is hit, but not exceeded, then the function improperly returns
NETDEV_TX_BUSY resulting in the packet being sent a second time.  Since
the packets are deleted in the write-done notification, the second
transmit will result in either an access-after-delete or a double-delete
crash.

Remove check for high-water mark hit in the transmit function since it
is handled by a high-watermark event from SMUX already.

CRs-Fixed: 403691
Change-Id: Iadf3ac249d3fb8ccb378fc243415acbbfc3a1ff1
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 196e240ae5d3b7bff69bf4a0012e20707dd685b9)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: rpm_resources: Prevent power collapse with pending RPM ack

When a device is waiting on a RPM interrupt prevent RPM assisted power
collapse. Otherwise, the device waiting on RPM completion doesn't get
the completion event until after waking from from idle power collapse.

CRs-fixed: 403816
Change-Id: I9d2c7e4c3a89b402f9064af1443697026639645e
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
(cherry picked from commit 3ca355ab57126718efb51e96e854773b2e939418)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: display: Add DSI clock control for MDP GDHS power collapse

Enable DSI clock and regulator before enabling/disabling power collapse
for MDP GDHS.

Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
(cherry picked from commit ad3200279e62eff01fd1bb9136cc9c0d11e10380)

Change-Id: Ie1cbac811f5a1fcae6ade42c8f27efbcbc471c68
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
u_data_hsuart: Fix high-watermark race condition

If multiple packets are written quickly and the high watermark is
exceeded, then the -EAGAIN return code is returned (A), the return code
is checked and the tx processing is throttled (B) until a low-watermark
notification is received (C).  If the packet queue is drained and the
low-watermark notification is delivered between steps (A) and (B), then
the order of events will be ACB and the tx queue will be permanently
stalled.

To fix this, a spinlock is held to ensure that the sequence is always
ABC.

CRs-Fixed: 404380
Change-Id: I639eda87e115f592a6465f624e611830e6173852
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit e92b15ff084f1aeb9dec2a722c68f3b05f65fffd)
Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
EHCI: HSIC: Increase IAA watchdog timeout to 100ms

In order to remove queue heads(QH) from Asynchronous Schedule Interrupt
on Async Advance(IAA) bit is used in USBCMD as doorbell by ehci driver
to handshake with host controller. When the host controller has evicted
all appropriate cached schedule states, then the host controller will
assert an interrupt which indicates ehci driver that it is safe to
modify a removed queue head from the asynchronous list.

EHCI driver walks through the asynchronous schedule list to search for
the QH(say QH1) which needs to be unlinked from HW. It removes QH1 from
the list, sets ehci->reclaim points to QH1 and starts iaa watchdog timer
after setting IAAD bit in USBCMD register. Before getting IAAD interrupt
for QH1, rest of other interface drives can also issue unlinking of their
QHs which get added to the list of QHs to be removed and pointed by
ehci->reclaim. It is possible that IAAD interrupt gets delayed for more
than current watchdog timeout value. This causes watchdog handler to
finish the unlinking process of QH1 with ehci lock held. Unlinking process
ends by setting QH1's next pointer to NULL, ehci->reclaim pointing to next
QH to be unlinked(say QH2) and calling qh_completions() to retire all the
transfer descriptor associated with QH1. qh_completions() releases
ehci->lock in ehci_urb_done(). There is a possibility of controller
asserting IAAD interrupt during this time on other core. After ehci lock
is released, ehci irq handler gets a chance to acquire ehci lock and
execute which results in premature unlinking of QH2, since ehci->reclaim
now points to QH2. QH2 is not yet removed from the asynchronous list and
ehci driver has not initiated IAAD handshake for QH2. Similarly unlinking
ends for QH2 by setting QH2's next qh pointer to NULL, since QH2 is not yet
removed from asynchronous list, this breaks the list. Due to this racing
between IAAD interrupt and watchdog timer interrupt ehci driver loses
track of which IAAD interrupt triggered for which QH. This results in NULL
pointer dereference while searching for subsequent QHs to be unlinked, in
already broken asynchronous list. Hence increase the IAA watchdog timeout
value from 10ms to a higher value of 100ms. Higher timeout value avoids
the race between IAAD interrupt and IAA watchdog handler and allows IAAD
interrupt to finish the unlinking of QH. Watchdog handler is still be
used to take care of scenarios when controller does not generate IAAD
interrupt for some reason (which is rare, but possible).

(cherry picked from commit 8a657de16d301e1bfab7ba69349446720d4a70e3)

Change-Id: Ie8d87bccf12cab2eaaabb12a9d6439a6b87f9342
CRs-Fixed: 396250
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
msm: mdm: Add shutdown ioctl and send poweroff request to the mdm

When the whole phone is being powered off, a poweroff request needs
to be sent to the external modem so that it can shutdown gracefully.
This request needs to be triggered from userspace before kernel drivers
start unloading so that other drivers needed to send the request are
still available. The shutdown ioctl is provided for this purpose.
The request is sent over system monitor.

Since the mdm driver is common to platforms that support sysmon as
well as those that don't, a platform specific flag named send_shdn
is added for runtime detection.

(cherry picked from commit bf3e4b526c55ea765a92f54cf91540330d0b75ae)

Change-Id: I356200b6e407b3fbe7a9db20675cdd2fbcf1bd78
Crs-Fixed: 401598
Signed-off-by: Joel King <joelking@codeaurora.org>
msm: sysmon: Introduce sysmon_send_shutdown() for subsystem shutdown

The sysmon_send_shutdown() API sends a shutdown request to a subsystem
and reads the response. The response is expected to be simply an
acknowledgment that the subsystem has received the request.

(cherry picked from commit 069dcbcc0730ce9918c98f7b5536e58f33b9ccb3)

Change-Id: I126d6e0746ed0393792eda8157f5031feb37f6a9
Signed-off-by: Joel King <joelking@codeaurora.org>
mmc: msm_sdcc: fix the sdcc version check

MCI_VERSION register has the couple of fields like "major"
and "step". Driver should be checking these fields individually
but at one place we are checking the complete value of MCI_VERSION
register where we should have just checked the "step" field of it.
This change fix it by checking just "step" field instead of entire
MCI_VERSION register value.

(cherry picked from commit 034a94a2fc227e88fd00a43ed910a9a7d24b3037)

Change-Id: Ida992cce7aba72cba083bdd2a53db57431ee2ad6
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>