gpu: ion: Fix fragmentation message log condition

If an ion allocation fails because of memory fragmentation a debug
message should be printed. However, the logic that decides whether
the debug message should be printed or not is incorrect causing
the debug message to not be printed when it should.

CRs-fixed: 359593
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 099501a01beda17a8b5be3ebc13d51791d96a269)

Change-Id: Ic91b9e97852b37461f4df503b2940714a344bdc2
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
gpu: ion: Leave fmem in c-state until unsecured

When the last buffer is freed from a heap that uses fmem we call
into fmem to transition the memory from c-state to t-state. However,
if the heap has been secured for content protection transitioning
the memory from c-state to t-state could cause undefined behavior
in fmem.

Add checks to ensure that a secured heap will not transition to
t-state until heap is unsecured.

CRs-fixed: 359593
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 20f3b6d7591986db8ff46a7f7e333b3c30db04e8)

Change-Id: I0d58b82bb119f4d621a3ddf1891dc477322ad532
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: kgsl: Store process mem entries in a rbtree

The list of memory objects attached to a process gets searched quite
a lot during normal operation of the driver.  For processes with a
lot of memory allocations, the linear search through the list is O(N)
and uses a lot more CPU during critical loops than it should. Change
the mem entry list to a rbtree for faster search speeds.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl.c
(cherry picked from commit c9559e461e3df1b828218421430a38c9d7a38ca4)

Change-Id: I844f7907823e2e53d8b588dc186defd7b2194694
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: rework ib checking

Separate ib parse checking from cffdump as it is useful
in other situations. This is controlled by a new debugfs
file, ib_check. All ib checking is off (0) by default,
because parsing and mem_entry lookup can have a performance
impact on some benchmarks. Level 1 checking verifies the
IB1's. Level 2 checking also verifies the IB2.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno.h
	drivers/gpu/msm/adreno_pm4types.h
	drivers/gpu/msm/adreno_ringbuffer.c
(cherry-picked from commit d0ab6adeeae7dd039069fd93e6649777aff23668)

Change-Id: Iea0b282d6b532016a358934c1323b8a8e415d3df
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: Use kzalloc to allocate scatterlists of 1 page or less

The majority of the scatterlist allocations used in KGSL are under 1
page (1 page of struct scatterlist is approximately 1024 entries
equalling 4MB of allocated buffer).  In these cases using vmalloc
for the sglist is undesirable and slow.  Add functions to check the
size of the allocation and favor kzalloc for 1 page allocations and
vmalloc for larger lists.

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

Change-Id: Ib520a5c19f5b8e12698a368456f1753a31c927e1
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: fix 2d IB processing

The 2d hardware handles ringbuffer and IB commands as
a series of gotos. At the end of each IB, there must
be a goto command back to the ringbuffer, which must
be "monkey patched" into the IB by the driver.
Fix this code to use a proper kernel mapping.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>

(cherry-picked from commit d27b09f388bab25f7e15ed9c5ca5eb1203c85492)

Change-Id: Ie41b50f2bd33d3e854e179ad4ada075422bfa77f
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm_fb: Make buffers aligned to 4K page boundary

This change makes the frame buffers aligned to the page
boundary. Improves GPU performance since accessing the
frame buffer from page boundary is faster.

Change-Id: I17879437dd7cbb9a1758d82321c6e68dbd88b9e0
CRs-Fixed: 325134
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm_fb: Clean up of frame buffer 4KB alignment changes

Remove redundant code from the 4 KB alignment patch
and reduce the overhead of calculation of the hole
size by using bitwise operators in its calculation.

Change-Id: I1706484249bf8e01b250e91fa87e00f6021d9a72
CRs-fixed: 325134
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: display: Call footswitch control from overlay dtv on/off

Instead of dtv on and off, call footswitch control during
overlay dtv timing generator on and off calls

Change-Id: I186955d9c6b07608e77b599c23d9a6593faba6e3
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
msm: display: Add proper flags for secure/non-secure writeback buffers

For MDP writeback buffer allocations, use appropriate heap id flags
for secure and non-secure sessions

Change-Id: I619d0a00325c4ee7f2d86b276c89473f75118ff5
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay.c
msm_fb: display: Enable timing generator during first update

During first display update through pan_display or overlay_play,
enable the timing generator for pull modes like LCDC, DSI Video
and DTV interfaces

Change-Id: I69ba1361586f0b461dcc50a7c6b96fa26347152c
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_overlay_lcdc.c