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
(cherry picked from commit 19e4b71f617e307cacf0be077e08bec5c37df290)

Change-Id: If09017149e98b35c49603372c554aa4c97f2de82
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Check for multiple readers of histogram

Check to ensure that only one reader attempts to read one frame's worth of
data from a histogram block. Prevent the case where two readers attempt to
get data, but end up causing a loop where neither of them do.

CRs-Fixed: 361640
(cherry picked from commit 71cf95bf1100ab5de55bf3858d40996be7dc445e)

Change-Id: I48878d9fe02d96f306894ed9acc47bf41cd9984b
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Avoid waking readers on failed histogram copy

Avoid waking up the waiting histogram reader when the current histogram has
failed to copy. Additionally, clean up initialization of histogram
workqueue (was initialized twice).

CRs-Fixed: 361640
(cherry picked from commit 0dc81db9cf48d869987e8fa8ab8914fcec964bda)

Change-Id: I376c0193b8e34aba5b0aef54feb9504f450ffff4
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm_fb: Check for Histogram NULL while queuing work

Don't queue the work if the user hasn't requested for the
histogram data

CRs-Fixed: 365729
(cherry picked from commit ff42a9a426ab9a76d75a29464412807dd72ceb13)

Change-Id: I0b28097fa00f13a836c2ee9d35e8e4557f1c70f0
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
video: msm: Always queue histogram work

Always queue histogram read worker in order to gain concurrency protection
from the histogram management mutex (move previous checks/calls into worker
itself).

CRs-fixed: 363763
(cherry picked from commit c0d815c2a4118d1ba51e316c6cb59bee4d68eb9b)

Change-Id: If9e3c13b5e4005f81fd1b5d2664af206b1decf5b
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Resolve post processing memory leaks

Allocate memory for post processing only once. Free post processing memory
when MDP is removed.

CRs-fixed: 366325
(cherry picked from commit d60ac323a1e3e7086ef2d77c866d5ed482d2a4e9)

Change-Id: I244f4e10a6933e2acaf69a83d8b91ee5f6e27557
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Always queue histogram work & lock histogram calls

Always queue histogram read worker in order to gain concurrency protection
from the histogram management mutex (move previous checks/calls into worker
itself).

Lock the mdp_histogram_start and mdp_histogram_stop calls with the same
lock used currently by mdp_do_histogram to maintain that every do_histogram
called between a start and stop will be completed.

Add a timeout to do_histogram wait_for_completion so that it will unlock
and yield to other histogram calls if it waits for longer than 33 msec.

CRs-fixed: 363763
(cherry picked from commit 56a123baaab84af584fbbf5cbb29955ec5c92f39)

Change-Id: Icc503aed4e60dd01941682003ca3dbc844aed8d9
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm_fb: Handle multiple histogram reader errors during suspend/resume

If a histogram reader waits for completion in the do_histogram ioctl
and during this time the device is suspended, the complete for this
gets called from mdp_histogram_ctrl_all() in the panel_next_off()
sequence. This results in mgmt->hist not set to NULL. The subsequent
do_histogram ioctls after device resume fail due to multiple reader
failure condition since the histogram irq will be enabled now from
the same mdp_histogram_ctrl_all() during panel_next_on() sequence and
this by-passes mgmt->hist getting set to NULL that is present in
histogram_start() ioctl. Handle this scenario.

(cherry picked from commit a43f44b44ee221df11ad84b8536c1c8d5373cbaf)

Change-Id: Ib0485da24c0f09a3f26768b75231903c8a2e0033
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
video: msm: Fix corner cases of "read twice" error

Fix several cases where histogram's completion structure is completed
multiple times which causes the next histogram read to force the histogram
software state machine into believing that the histogram is always being
read by someone.

When the timeout in mdp_do_histogram times out and then soon after the work
that was being waited on completes, the next do_histogram call that is
processed will not wait (and thus will not have its hist field set to
NULL). This will cause all subsequent do_histograms to think that the
histogram is currently being read, and will cause the "read twice" message
to flood the kernel logs.

This error is fixed by always initializing the completion structure before
waiting for the histogram to complete. That way if the completion happens
after the timeout, instead of causing the error, the completion's internal
counter is reset to zero, which prevents the next histogram read from
completing without waiting.

(cherry picked from commit 3d297368b8199b07bda815915e94ecb5761561b0)

Change-Id: Ic1bc4b8688cd191d226de1df15d389de09996106
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm_fb: Increase display timeout to 2 seconds

One second time out for no frame update, as in current implementation,
does not allow CABL to reach minimum backlight level possible because
histograms dont get generated after one second. So increase time out
period to two seconds which seem to be sufficient for complete black to
complete white and vice versa transitions.

CRs-Fixed: 370804
(cherry picked from commit 1bb4edf9242b0397975636a4442318713a53b5e6)

Change-Id: I0712924d669abcb820654cd6ca5f7da37bed57e6
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm_fb: display: Add pre-multiplied alpha support for MDP4.

MDP4 blend logic differs from GPU blend implementation as MDP4
does not differentiate between pre-multiplied alpha layers and
non pre-multiplied alpha layers. Check layers for pre-multiplied
alpha and change blend logic accordingly.

CRs-Fixed: 355755
CRs-Fixed: 361729
Change-Id: Id8253d3888f1ebbadba1b6bbd87e7d98bac22da7
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
(cherry picked from commit 3d36e64838fbd064ad4868e1a3770e27c183f83e)
(cherry picked from commit 5eff5c41312dc0ccda3c56865d4654546d7e37c5)
msm_fb: display: free iommu buffers for WFD

Iommu buffers from overlay destinated for WFD (mixer2) are
not freed after kickoff. This patch will free those iommu
buffers.

CRs-fixed: 394270
Change-Id: I6b58b5d1831e7c59c5107641b786730511803557
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit cbd2a940d95056c51f6cef0a1641a716c8ed292e)
(cherry picked from commit 5aff850872964d7bfbb7d31e10de4ee7a58b8d14)
msm_fb: display: free iommu buffers for WFD

Iommu buffers from overlay destinated for WFD (mixer2) are
not freed after kickoff. This patch will free those iommu
buffers.

CRs-fixed: 394270
Change-Id: I6b58b5d1831e7c59c5107641b786730511803557
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit cbd2a940d95056c51f6cef0a1641a716c8ed292e)
(cherry picked from commit 5aff850872964d7bfbb7d31e10de4ee7a58b8d14)
(cherry picked from commit 06987a15c6e2d0135f2294f91a2d0a9b2f35e4b1)
defconfig: wcnss: Enable wcnss pre-alloc memory

Enable support for pre-alloc memory for WLAN driver.

Change-Id: I5142492a57ca9be500293d0edd9cab336d8fca1c
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
(cherry picked from commit 274dc940a785d69ad8f5aec7ab6869d14788079e)
(cherry picked from commit 3bfe64e7a79a0ede8eee6a445dc6f7e4e18bbe9e)
wcnss: Pre-alloc memory for WLAN driver

WLAN driver will use this pre-allocated memory (when available) for
large memory allocations; this will prevent WLAN driver load
failures because of the un-availability of the large size slabs
during module load.

Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
(cherry picked from commit 24db5288a9f82ced747746a2064a60f368ea6646)

Conflicts:

	drivers/net/wireless/Kconfig
	drivers/net/wireless/wcnss/wcnss_wlan.c
	include/linux/wcnss_wlan.h

Change-Id: I79da592689014a16e25382176e5edf8ea4e91d6c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit 60b943e1d425e76d250cb07563021140a21b9d93)
msm_fb : Add option to enable/disable  mixer commit

Adds support to enable or disable mixer commit during pipe
staging operations. Depending on the current activity, this
selection can be made.

Change-Id: Ia2f5dbab58f73ef4de90abf7f278332d8d73df46
Signed-off-by: Pradeep Jilagam <pjilagam@codeaurora.org>
(cherry picked from commit f9bc16bf6dcb8beb7d5d6405ee5dc767e6decdff)
(cherry picked from commit dfca66d79de4a32af3ece205f97b9ba86d14eb28)
msm_fb: display: Fix blend configuration for MDP4.1

MDP4.1 blend operation registers are not double buffered and
take effect as soon as they are configured. Configuring these
registers at any place other than between dma and vsync produce
flickers as new blend values would get applied to previous
mixer configurations. Configure blend operation registers just
after dma is over, before vsync.

Change-Id: I377c11222f7a0cd77e98e90edec6e2e1dc0c17ca
Signed-off-by: Pradeep Jilagam <pjilagam@codeaurora.org>
(cherry picked from commit e79dde6faab507c51994a8588bebd03dfc5fb57a)
(cherry picked from commit 9bbc4ed761133435dd6897e099100517c6af773e)
msm_fb: display: Add pre-multiplied alpha support for MDP4.

MDP4 blend logic differs from GPU blend implementation as MDP4
does not differentiate between pre-multiplied alpha layers and
non pre-multiplied alpha layers. Check layers for pre-multiplied
alpha and change blend logic accordingly.

CRs-Fixed: 355755
CRs-Fixed: 361729
Change-Id: Id8253d3888f1ebbadba1b6bbd87e7d98bac22da7
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
(cherry picked from commit 3d36e64838fbd064ad4868e1a3770e27c183f83e)
(cherry picked from commit 5eff5c41312dc0ccda3c56865d4654546d7e37c5)
(cherry picked from commit 4b216f6d0b5a8e7eae45613706d799c7d464b778)
msm_fb: display: add blt condition check at video/lcdc off

Blt mode may be enabled during system suspend. Need to make
sure blt overlay done  before turn off video/lcdc timig generator.

Change-Id: Iad54ee544499213bb7c9cfe60d00919f819aacb1
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit 4b251d6f0067af78a0a424af5054747cc38a0904)
(cherry picked from commit 922724ddd13d286ceccc074fe1010c81924ccbe8)
(cherry picked from commit ef69dc4211eea1d26901d560f0cbed1128bd8ac9)
msm: kgsl: Do bounds checking on user supplied GPU addresses

Add bounds checking to kgsl_sharedmem_find_region to ensure that GPU
addresses supplied by the user via KGSL_IOCTL_SHAREMEM_FREE and
KGSL_IOCTL_CFF_SYNCMEM are within a valid range for the MMU scheme of
choice.

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

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

Conflicts:

	drivers/gpu/msm/kgsl_mmu.h

Change-Id: I043038d96a4f6f48e4f3391a9ebbccff1afce334
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>