msm_fb: Turn clock on during overlay commit for MDDI

MDP clock is controlled by framework. There is a
possibility that MDP clock gets turned off while
frame update is still happening. In this case update
thread may get stuck at wait4vsync/wait4dmap since there
is no MDP clcok to trigger vsync/DMAP interrupt. This
patch enables MDP clock at pipe commit if it is already
turned off so that frame update can be completed.

Change-Id: Ic46ff0f205763288522a80b183abb6af1ce55ecf
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
Merge "msm_fb: Turn clock on during overlay commit for MDDI"
msm: kgsl: Fix guilty context logic for GPU hangs

Always mark GPU contexts that have cause a GPU hang as guilty.
If the GPU context recovered successfully, still mark it as guilty.
This will inform applications that something might have
gone wrong and to take actions to ensure everything is correct.

Also, swap out any active context following a hang.  This will
ensure that any new submissions will force the context to be restored
before it is used.

(cherry picked from commit 8179f5a1bfb73626047fa472b115e77381d3900e)

Change-Id: If15e10744e54f17b6f035a51e2d9dae6f37b708b
CRs-fixed: 427603
CRs-fixed: 405434
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Ensure context pointer exists before dereferencing

When trying to add commands to the ringbuffer command stream, ensure
that the context point is not NULL before dereferencing it.

(cherry picked from commit 4e8b4023c86b2b26c38053f9710c9d76c42d59a2)

Change-Id: Ie7e97df786606110805b2a8f9676e7095e5c658a
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Add GFP_NORETRY to the page_alloc flags and handle errors

The most important thing for the memory allocator is to not crash
or otherwise behave badly during low memory situations. Adding
GFP_NORETRY keeps the OOM killer from being invoked making the 32MB
padding on the allocation redundant.  Remove the padding, add the flags
and go down the proper error path when alloc_pages() fails.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 97c74d6577d59122915a56c9eca4c5936de5f642)

Conflicts:

	drivers/gpu/msm/kgsl_sharedmem.c

Change-Id: I5b305910a2d1ac21f10335f4cf9b088ea7c1480e
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Merge "msm: kgsl: Fix guilty context logic for GPU hangs"
Merge "msm: kgsl: Ensure context pointer exists before dereferencing"
Merge "msm: kgsl: Add GFP_NORETRY to the page_alloc flags and handle errors"
msm:vidc: Amend error checks on ION API failures

This change will validate the ION API failures
to fix target freeze issues.

CRs-fixed: 412958
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit 31bb7dc8e3a4d01262727349b30bb3007fd474bd)

Conflicts:

	drivers/video/msm/vidc/common/vcd/vcd_sub.c

Change-Id: I0c0a7cefa46751308a1ee1f7f6897c9a540e1144
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Merge "msm:vidc: Amend error checks on ION API failures"
msm: kgsl: Add minimum amount of wait in adreno_waittimestamp

Add minimum amount of wait period in adreno_waittimestamp
to avoid instances of malformed wait period (such as msecs=0)
arguments from userspace and in turn avoid false hang detections.

(cherry picked from commit 5e57bd33becce86c8779771df7a584b3798168c2)

Change-Id: I694257630cb0b08454cf98b075fd6d11488c4a24
CRs-fixed: 437738
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Merge "msm: kgsl: Add minimum amount of wait in adreno_waittimestamp"
msm: pm2: Use different API to get the next timer expiration

Use different API to get the next timer expiration. Replace
the existing API "tick_nohz_get_sleep_length" with
"msm_timer_enter_idle". Sometimes existing APIs giving less
timer expiration than what is required when the system decide
to enter into PC. This time is not sufficient for the system
to enter and coming out of the PC.

Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
(cherry picked from commit 8dc6ff4d47fceff2b11ab1de7336b659ee10cb19)

Change-Id: Iae2ede92e06f8a16c8f43558d2766b746c6d453a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: pm2: Update SPC LPM stats correctly

Currently StandalonePC stats are updating incorrectly even
for successful cases. After debug found that compiler has
optimized some of the instructions where the return value
from "msm_pm_power_collapse_standalone()" being compared
incorrectly and always log the stats as failed even for
success cases. Change the "exit_stat" variable to "volatile"
to avoid any optimization.

CRs-Fixed: 433578
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
(cherry picked from commit f59048d29fd75a30cac8c294e068178d9d489af3)

Change-Id: If1f9313f7968e93f5dcd9fb33426496f5091d14a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Merge "msm: pm2: Use different API to get the next timer expiration"
Merge "msm: pm2: Update SPC LPM stats correctly"
USB: OTG: Vote against APP's idle PC in USB Host Mode

In USB Host mode, When the target is going to APP's
idle PC and coming out with any peripheral device
connected, target is crashing. Fix this issue by
not allowing Idle PC in USB Host Mode.

(cherry picked from commit 9d672c8f341fc2bbee2c6ee0108d7d8eedbe999f)

Change-Id: I7f5fb2fe9d2f545bc383daf0c0ab3d322650e9a5
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Merge "USB: OTG: Vote against APP's idle PC in USB Host Mode"
Revert "msm: kgsl: Update pagetable on context destruction for A20x"

This reverts commit f0d1c9b79e05972816b92bd43b29e98f764826ea.

Reverting this change since it corrupts Bin Base Offset between
two draws of a Binning pass, resulting in GPU hang.

(cherry picked from commit 3ec5d2db139d0941ec8360f6cc399223b18469e5)

Change-Id: Ie1853075533e15e6c8020a00e57b1695df81c9ba
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
Merge "Revert "msm: kgsl: Update pagetable on context destruction for A20x""