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 363763
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
(cherry picked from commit ff42a9a426ab9a76d75a29464412807dd72ceb13)

Change-Id: If5e6a5ad525e895ff7c2f27666cc7a445c485cb4
Signed-off-by: Srivalli Oguri <oguri@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
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit c0d815c2a4118d1ba51e316c6cb59bee4d68eb9b)

Change-Id: I8970021ff300c08131bdc1fbf3efdc74623bdb90
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp.c
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
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 56a123baaab84af584fbbf5cbb29955ec5c92f39)

Change-Id: I803b6457523d1af13cc83e459a8b0fe2829badf8
Signed-off-by: Srivalli Oguri <oguri@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.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
(cherry picked from commit a43f44b44ee221df11ad84b8536c1c8d5373cbaf)

Change-Id: If0a45a8215a969bf6f137e19f2536d6d4abce156
Signed-off-by: Srivalli Oguri <oguri@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.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 3d297368b8199b07bda815915e94ecb5761561b0)

Change-Id: Ibb47ceae75fdd7347b1c3474cb16a394eff40446
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp.c
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>
gpu: ion: Check return code of msm_allocate_iova_address

In the IOMMU heap, the return value of msm_allocate_iova_address
needs to be checked instead of the value of the iova address.
Check the return value instead.

Change-Id: I4554515d17c926a7dd738824aff21eb65d2ba56a
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

Conflicts:

	drivers/gpu/ion/ion_iommu_heap.c
msm: Make iommu domains platform devices

Information about the layout of iommu domains is a device
specific option. Convert the iommu domain information
into a platform driver with a corresponding platform device.
This allows different devices to have different layouts as
needed.

Change-Id: I6bf4162476143daabe16a2f5de3b655ae4377902
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/board-8064.c
	arch/arm/mach-msm/board-8960.c
	arch/arm/mach-msm/devices-8064.c
	arch/arm/mach-msm/devices-8930.c
	arch/arm/mach-msm/devices-8960.c
	arch/arm/mach-msm/devices.h