gpu: ion: Add support for securing indiviudal buffers

Newer protection APIs allow individual allocations to be secured
instead of the entire heap. Add APIs to support securing individual
Ion handles. These APIs include a flag option to support delaying
the unsecure until the buffer itself is actually freed.

Change-Id: I01e2bc921a342e4bb6191a642942264a9613d6f9
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ion: ion mini upgrade

Change-Id: I39a7743690cf5115f28495d1206746421073364c

Conflicts:
	include/linux/ion.h
gpu: ion: Change secure heap allocation restrictions

Currently, allocations for secure memory will fail if there
is any oustanding mapping present on a secure heap. This is
too restrictive for allowing protection of individual buffers
instead of the entire heap. The correct solution is to allow
secured allocations even if there are oustanding mappings on
the heap. The heap protect call should fail if there are
oustanding mappings. Any detection of oustanding mappings
when the heap is secured should be considered a bug.

Change-Id: I10668fdd961e02cbef8eba7bf85702ae7eabfe31
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
gpu: ion: Don't require buffers to be 1M aligned

When generating the scatter gather table, older secure
clients cannot support 1MB aligned allocations. Change
the code flow to only generate the sg_table with 1MB
chunks if the buffer is 1MB aligned. Checks are present
elsewhere which will prevent the buffer from being
secured if the allocation is not 1MB aligned.

Change-Id: Id2d1610ccbc90ca1c8427eeadbf1f702b808cd38
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ion: update API stubs

The stubs for some of the Ion functions have gotten stale since the
last Ion API change. Update these to avoid compile errors when Ion is
not included in the build.

Change-Id: Idfe475c0f1990e5a9b5919434a27ae9dd63ffcb4
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
gpu: ion: fix race condition in checking virtual address

Currently, on an Ion cache operation, there is a short period of time
between checking the validity of the virtual address range of the
operation and the actual cache operation. During this time another
thread could twiddle the vm areas, resulting in an invalid cache
operation. Fix this by holding mmap_sem of the active_mm of the
current thread across the address range check and the cache operation.

CRs-fixed: 418933
Change-Id: I859e2e3d888dea38a26d04958c1577522471a62c
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
gpu: ion: repurpose flags field for heap_mask and caching

In the latest Ion API, userspace clients specify the heap_mask for an
allocation in the `heap_mask' field of the ion_allocation_data
structure, and they specify caching in the `flags' field. Before, the
heap_mask was in the `flags' field and caching was specified with the
O_DSYNC file open flag.

We would like to support the new API without actually updating Ion. To
do this, | the heap_mask back into the flags field on an allocation
ioctl (since the internal kernel APIs still expect to see it
there). Also make sure that caching is taken from the buffer flags
field rather than the O_DSYNC file flag.

Change-Id: I872afb40d9bf7c49bb31f19c5e9726ac714ef850
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
msm: ion: Only return Ion flags in ion_handle_get_flags

Since the ion_buffer.flags field is shared between the actual Ion
flags as well as the Ion heap mask, make sure that we're only
returning flags. The heap_mask bits should be masked off.

Change-Id: Ibdaf0ea374b7b80a036bddd11d19c4bafa173ef6
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
display: removed the code exhausts file descriptor in mdp overlay and rotator.

Fix the problem crashed while playing video clips and VT camera test.
ion_share_dma_buf is called in pr_debug.
So, it is called depends on build option and makes crash problem.
msm: rotator: Add pseudo-planar 422 H1V2 dst format for MDP4

For interleaved 422 inputs, rotator outputs MDP_Y_CRCB_H1V2
format on 90 degree rotation. Add support as destination format
for MDP4.

CRs-Fixed: 371303
Change-Id: Ie0f98d40f58bf2cb9bc3298a94cae9c4e89b2f7a
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: rotator: clear rotator bus scale handler

rotator bus client will be not registered again without handler reset.

Change-Id: Id35c4e5ad481d0a4401bdb3ee4628ffa9a891467
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: rotator: Support Fast YUV for 8960, 8064 and 8x30 targets.

Add Fast YUV support in rotator for 8960, 8064 and 8x30 based
targets to improve performance for YUV 420P and 420PP inputs.

CRs-fixed: 415246
Change-Id: Ib4cbbd0fd45a82b8d409e7f52ae8bf8420b2c4eb
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm_fb: display: exit properly when rotator max session reached

When rotator session reach maximum, it should exit without calling
put_img since no get_img had been called.

CRs-fixed: 466462
Change-Id: I951570227ebd81da6dad19c1b897cde84f8d0451
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: rotator: sync point support

Add MSM_ROTATOR_IOCTL_BUFFER_SYNC ioctl interface.
Rotator will create a timeline for each session at START, wait for
input fence and create released fence in this ioctl call,
signal the timeline after rotation is done.

Change-Id: I3738f8287d804ccd94e0a16ac0afb8b41b299c75
Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:
	drivers/char/msm_rotator.c
	include/linux/msm_rotator.h
msm: display: plane alpha support

Clean up the blending rule to follow blend_op set from hwc.
Use modulate alpha for plane alpha when it is not 0xff.
Keep backward compatibility if blend_op is not set.

Change-Id: I02fd3c3c7b5ace2e6eec22b2db0284161404a0fc
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm_fb: Avoid memset of frame buffer during early suspend

At present, we have backlight disabled before frame buffer
early suspend and there is mechanism in place to enable backlight
only after first frame update after display resume. This makes sure
to avoid panel specific artifacts being visible. Hence,
remove memset of frame buffer during suspend. This change
reduces latencies during frame buffer's early suspend.

Change-Id: I4a4d1d28ba10912f24ba38861fdb7086b78192a4
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.c

Conflicts:
	drivers/video/msm/msm_fb.c
msm_fb: display: extend mdp debugfs with force blt enable

Enabling/disabling mixer0 or mixer1 blt mode is a critical way to
debug display issues, so add debugfs interfaces to force blt mode
enabled/disabled with adb shell commands.

CRs-fixed: 390953
Change-Id: I96a568f22398867571a796a863c098f749f5618b
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c
msm: display: Allow MDP clocks to use Max clock.

Allowing the MDP clock to use its Max clock in order to avoid the blt
mode switch issues for both MDP mixers, as blt mode switch resulting
in HW hung

Signed-off-by: Nagamalleswararao Ganji <nganji@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c

Change-Id: I697445c38df92b57aad54e991e006948c3254f48
msm: mdp: Fix clocks

The max supported clock was wrong

Conflicts:
	drivers/video/msm/mdp.c

Change-Id: I12b9889b3c4273a2dd1edd748f5a78e4a1da9db1
msm: display: Add userspace LUT tuning

Tables and most code taken from the mako's kcal_ctrl interface

Change-Id: Id736e60f2411f268105b21ce1941865ec61f7258