msm: thermal: Add support for emergency frequency mitigation

Add emergency frequency mitigation support to Kernel Thermal
Monitor. This feature enables KTM to mitigate the cpu's max
frequency when the temperature crosses the preset threshold.

CRs-Fixed: 538981
Change-Id: I756e82e577b19c18f32b3297aa97fa2942d8b77d
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
ARM: dts: msm: Enable emergency frequency mitigation for MSM8974

Specify the frequency mitigation threshold and the max frequency
to which KTM should mitigate the cpu. This mitigation is enabled
only for cpu 0, but can be extended to other cpu's by modifying
the cpu mask.

CRs-Fixed: 538981
Change-Id: I062d7a048961ffa77bfb52e19c78a9a31e9894e7
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
msm: thermal: Add IOCTL interface support to Kernel Thermal Monitor

Kernel Thermal Monitor exposes an IOCTL dev interface,
which can be used for user space cpu frequency
mitigation.

CRs-Fixed: 538981
Change-Id: Idb8b836970f7d5d029fea606aaa4f7958c982f68
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
msm: mdss: Use MDP_SOLID_FILL to enable color on pipe

To enable constant color on a pipe, set MDP_SOLID_FILL in pipe
flag. This will do a solid fill on the pipe with the color
specified in bg_color.

CRs-Fixed:592032
Change-Id: I3201e2fa657a6fc6d0e7f51f8585366afc3d29a3
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: vidc: Send ABORT in FLUSH command from the Client

When session error is sent to the client, client issues FLUSH
and release buffers commands. But as instance state is INVALID,
these commands are never sent to the firmware, instead FLUSH
DONE and Release buffer done are sent back to client even
though firmware might be working on these buffers which may
result into page faults.
This change fixes the issue by sending ABORT command to the
firmware at the time when driver receives FLUSH command. Then
firmware will release all buffers, clean up session and send
ABORT_DONE back to the driver.

CRs-fixed: 592920
Change-Id: Ie4c79a312d2336c68b858f5f5e2a85331cf55f7b
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
kernel: alarm: Do not call rtc_alarm_irq_enable in IRQ Disabled context

Currently shutdown hook of alarm driver is calling
the rtc_alarm_irq_enable API in interrupts disabled
context. So fix the alarm_shutdown function to call
in API rtc_alarm_irq_enable in interrupt enabled context.

CRs-Fixed: 591790
Change-Id: Iebd82482be1dc95c6c978b617e1c18eb36e1b6eb
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
ARM: dts: msm: increase mdp dma priority to 3

Increase mdp dma bus master priority to 3 from 2.

Change-Id: I194b4c8195cd176bb9b66ccf2c7e766ea9620dfb
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
USB: msm_otg: Fix race between PM resume and charger detection

When device is in system suspend and USB charger is disconnected,
then due to VBUS clear IRQ from PMIC, the device will be PM resumed.
Now shortly if PMIC driver detects valid VBUS it will handle VBUS
set condition,notifies to msm_otg and msm_otg will kick in charger
detection mechanism. During PM resume, in dmp_complete() it will
call a pm_runtime_put_sync(), which will immediately kick off the
PM runtime idle and suspend routines.
dpm_complete()
  ->device_complete()
    ->pm_runtime_put_sync()
      ->rpm_idle()
        ->rpm_suspend()

The PM resume also runs in a separate worker queue, so it is not
guaranteed that it will finish executing before we finish the charger
detection stage. During this case there is a race if dpm_complete()
returns before charger detection starts. Return of dmp_cpmplete()
before charger detection will make USB to enter LPM. As USB will be
in LPM now and if charger detection starts then it will lead to
unclocked access.

Fixing the issue by handling the pm usage count using the variable
pm_done in msm_otg. When USB charger is disconnected and msm_otg
processes the disconnect event it marks the pm_done to true. Later
when USB charger is connected , mark the pm_done to false in
msm_otg_runtime_resume(). If pm_done is true increment the pm counter
using pm_runtime_get_sync. This handles the race case when PM resume
thread returns before the charger detection starts.

CRs-Fixed: 599143
Change-Id: I6de19fe850e24efa03ea71c7d14e388c15cf2f97
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
input: misc: enable mma8x5x interrupt mode

Allow mma8x5x accelerometer work on interrupt mode and issue
interrupt to wake up application processor when data is ready.

Change-Id: Iadecfa9aeaa8e225098d049659802dcd7f976f48
Signed-off-by: Bingzhe Cai <bingzhec@codeaurora.org>
msm: msm_fb: remove mmio access through mmap

Disable access to mm io and add
appropriate range checks to ensure valid accesses
through framebuffer mmap. This prevents illegal
access into memory.

CRs-Fixed: 474706
Change-Id: If25166f2732433ef967e99c716440030b567aae9
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
ARM: dts: msm: Disable Venus GDSC collapse for 8974v2.2 and 8974Pro

The sudden current draw occurring when restoring Venus from GDSC
collapse may cause general instability on some platforms. Disable
this feature by default.

CRs-Fixed: 597489
Change-Id: I4e62b913d0206063547ad59ccd8029aa1c5aee16
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
ASoC: dapm: Fix race condition in dapm

Dirty widget list can be accessed by multiple
paths in dapm framework. Dirty list is protected by
dapm mutex. Since stream_event function accesses the dirty list,
it should acquire dapm mutex instead of codec mutex.

CRs-fixed: 593141, 596103
Change-Id: I9f41bf436b41ba9b4fa3bb447035fd1fe262e76b
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Revert "msm: wfd: Restart hrtimer after forwarding it"

This reverts commit Ia8e82a6ad327acddc135835268a755e3646d2ee8.
Calling hrtimer_forward_now() outside of the hrtimer callback context
and not restarting it seems to be a misuse of the hrt APIs.

Change-Id: Idd3f967d8037435ec43bbd843ce122d989aa838a
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
msm: camera: Add retry mechanism to detect camera sensor

When device power up, probe happens where camera sensors
connected in each slot are detected by reading its chip id. Add
retry mechanism to try 3 times to read chip id for detecting
camera sensors.

CRs-Fixed: 586066

Change-Id: I6c61f6b60a6daeb6177a112015c2371ab0691208
Signed-off-by: Abhishek Pant <apant@codeaurora.org>
msm: mdss: Add SMP parameters into hw capabilites

To handle use cases better, expose smp_mb_cnt and
smp_mb_per_pipe to userspace as part of hardware capability.
Pipes availablity for a use case can be computed taking these
values, based on which, composition decisions can be made.

CRs-Fixed: 592505
Change-Id: Ia7cc4db153cdb164a29ae2369d3e991b95aaba65
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: mdss: Reserve single SMP block for writeback mixer pipes

Writeback does not have stringent requirement for latency
buffers. So, SMP blocks reservation for the pipes attached
to writeback block can be restricted to single SMP block for
each plane. This makes more SMP block available for other
clients.

CRs-Fixed: 592505
Change-Id: I3d788bcf7fcbc5667b4a3a0c52256f55cc0aa1e7
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: mdss: Reset pipe's mfd parameter during pipe free

There is a corner case with dma pipe. If its set call
fails as line mode (for mdp) and is configured
subsequently as block mode (for rotation), mfd parameter
of the dma pipe structure does not get reset during set
failure cleanup. This causes unnecessary force dma
cleanup call in rotatorp lay which gets hang and
results in rotator fence timeout.

CRs-Fixed: 592505
Change-Id: Ia090e9eebf43ab6e28a2746f8fe57e2c3da34e59
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
Merge "Merge "ASoc: msm: qdsp6v2: Fix for NULL check""
Merge "input: misc: enable mma8x5x interrupt mode"
Merge "Merge "Merge "ASoc: msm: qdsp6v2: Fix for NULL check"""