msm_fb: Avoid multiple disable calls for vsync interrupt

For LCDC and DSI Video mode panels, there seem to be multiple
disable calls for Vsync interrupt term. Change to avoid this
issue by proper synchronization of vsync term and DMA term.

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

Conflicts:
	drivers/video/msm/mdp_dma_dsi_video.c
	drivers/video/msm/mdp_dma_lcdc.c
msm_fb: Handle histogram IRQ cleanly during suspend/resume

Currently, if the histogram disable IOCTL comes after panel
is turned off, we early return the IOCTL causing the interrupt
to be left enabled. This causes IPC issues during suspend. Fix
this issue by properly enabling/disabling the histogram interrupt
during suspend/resume scenario.

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

Conflicts:
	drivers/video/msm/mdp_dma_lcdc.c
msm_fb: Release semaphore when display Unblank fails

When continuous splash is enabled, the display subsystem will be
turned on during first pan display after boot up. During this
process, we acquire a semaphore. Release the semaphore if display
init fails and the function has to return early.

CRs-fixed: 441973
Change-Id: I4c8ba0b5e7710a6f3d409be619d5014b3ee32e5b
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
video: msm: Do not use disable_irq in the spin_lock_irqsave context

Both mdp_isr() and mdp_histogram_disable() uses the same
spin lock mdp_spin_lock variable.  One core waits for disabling
mdp_isr after acquiring mdp_spin_lock and other core in mdp_isr()
waits for spin lock mdp_spin_lock and dead lock between two cores.

Change-Id: I73a10494ab78e92fc88a348aed4f526091b51f89
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
(cherry picked from commit 946ca6389b8f8c70b62a2f1ab4d81b475395f7d8)
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Clear previous histogram data on next startup

Clear the pointer to the userspace histogram struct when histogram is
started. Previously, when the histogram was stopped while a histogram read
was in progress, the pointer was not cleared, causing the next histogram
read to think that someone was already using the histogram.

CRs-Fixed: 361640
Change-Id: If09017149e98b35c49603372c554aa4c97f2de82
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 19e4b71f617e307cacf0be077e08bec5c37df290)
video: msm: Enable mdp clock for histogram and histLUT

Enable the mdp clock for histogram and histogram LUT to ensure that the
clock remains enabled when they are being accessed.

Change-Id: Ic744f2ee96b64442f23ba19aa1c38552c0dad83a
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit e782ceab26e38590cd49a9bb273da1dbf1984ccd)
msm: display: reset vsync state when display is turned on

In the case that vsync ctrl is unbalanced, vsync IRQ is cleared
in suspend,  vsync cannot be enabled after resume.
Clear the status when display is turned on

CRs-fixed: 449155
Change-Id: I5ecf23053b60d1fbd91f042758d67d39c83ab444
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
sync: Fix race condition between merge and signal

The copied sync_pt was activated immediately. If the sync_pt was
signaled before the entire merge was completed, the new fence's pt_list
could be iterated over while it is still in the process of being
created.

Moving the the sync_pt_activate call for all new sync_pts to after both
the sync_fence_copy_pts and the sync_fence_merge_pts calls ensure that
the pt_list is complete and immutable before it can be reached from the
timeline's active list.

Signed-off-by: Erik Gilling <konkers@android.com>
sync: don't log wait timeouts when timeout = 0

Change-Id: If7542002e10da886af7e7cbc06a0abf023c15893
Signed-off-by: Erik Gilling <konkers@android.com>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
sync: fix timeout = 0 wait behavior

Change-Id: I8b9254e92c26d9f44abbc0c77fb44624de947013
Signed-off-by: Jamie Gennis <jgennis@google.com>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
base: genlock: Add new functions to get the fd

Add new API to get the file descriptor reference to a lock suitable for
sharing with other processes.

Change-Id: I1b61f44b6d5745a628eb98dfdc876767c46552ea
Signed-off-by: Alex Wong <waiw@codeaurora.org>
msm: mdp: Fix reserved field usage

An earlier commit(ec5b2f)increased the number of reserved fields
in the kernel standard fb.h header changing the struct size.
This caused issues with userland applications using the corresponding
bionic header. This patch revert the earlier increas in size
and makes corresponding adjustments to the reserved field usage.
A follow up patch will remove usage of reserved fields entirely.

Change-Id: Ibc2c00de71e5a6d2563a8a8a3e0916d15faef32b
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Signed-off-by: Arun Kumar K.R <akumarkr@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.c
	drivers/video/msm/tvout_msm.c
msm: display: sync point clean up

Remove unused fence input in mdp_display_commit
structure
Use different timeline name for different fb

Change-Id: I4edd335b36dce057ff3e54302af6088a9cc470ec
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm: display: increase fence timeout

Increase timeout value to 900ms to allow
gfx engine to render longer.
When sync_fence_wait fails, need not put fence as
it will be handled outside the loop.

Change-Id: Id4caff55c9f99c48e5f87a85d30fe4c8c0cd65e7
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm_fb: Update MDP fence wait behaviour

The current fence wait times out too early in cases where the GPU
is under a heavy workload. Change this behaviour to warn and wait
for a longer time for GPU to complete it's work.

Change-Id: I8b20c22733a77c1aaea4a1fd1e4daaa14b5ec2fd
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm_fb: display: fix fence fd list be put twice

msm_fb_wait_for_fence() will put fence fd list if sync_fence_wait()
failed. After that same fd list wil be put one more time. This
cause a fd put twice and cause system crash at the time fd
was closed.

Change-Id: If6a358e051c98841e34c23d81098243003ef0836
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
ashmem: avoid deadlock between read and mmap calls

Avoid holding ashmem_mutex across code that can page fault.  Page faults
grab the mmap_sem for the process, which are also held by mmap calls
prior to calling ashmem_mmap, which locks ashmem_mutex.  The reversed
order of locking between the two can deadlock.

The calls that can page fault are read() and the ASHMEM_SET_NAME and
ASHMEM_GET_NAME ioctls.  Move the code that accesses userspace pages
outside the ashmem_mutex.

Bug: 9261835
Change-Id: If1322e981d29c889a56cdc9dfcbc6df2729a45e9
Signed-off-by: Todd Poynor <toddpoynor@google.com>
kgsl: update kgsl to 3.14

commit 27d2fbc0d7aed511d777545b2918e75436f945a7
Author: Jeff Boody <jboody@codeaurora.org>
Date:   Fri Mar 29 13:23:31 2013 -0600

    msm: kgsl: fix paren placement leading to fence timeout

    The incorrect paren placement can lead to a fence timeout
    because the last_timestamp is always written. As a result
    the last_timestamp could be corrupted by writing an old
    value leading to a future timestamp_cmp indicating that a
    signaled sync pt was unsignaled.

    Change-Id: I4650a467bfdd98a905f86fbec7d833596c67ba19
    Signed-off-by: Jeff Boody <jboody@codeaurora.org>

Change-Id: I2f3dada8c910b0e6bbfc09a025003aa788c6454f

Conflicts:
	drivers/gpu/msm/adreno_a2xx.c
	drivers/gpu/msm/adreno_ringbuffer.c
gpu: ion: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I4f999e301d147ec3242a33ee75b10b6501d42a70
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

Conflicts:
	drivers/gpu/ion/msm/msm_ion.c
gpu: ion: move msm-specific ioctls to custom_ioctl

    To avoid collisions with future ioctls that may be added to ion,
    msm-specific ioctls should use the `custom_ioctl' interface provided
    by struct ion_device, as originally intended.

    Change-Id: I68d32b81c7691fd3f54f38acfdc17fee2573bc44
    Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

Change-Id: I54264f5fd8ec030e855efb66179d2234870e5e6a

Conflicts:
	drivers/gpu/ion/ion.c