msm:vidc: Amend error checks on ION API failures

This change will validate the ION API failures
to fix target freeze issues.

CRs-fixed: 412958
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit 31bb7dc8e3a4d01262727349b30bb3007fd474bd)

Conflicts:

	drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.c
	drivers/video/msm/vidc/common/vcd/vcd_sub.c

Change-Id: I6d0dc8afef6ba1513c2ea29753f7df6b1a3d70e9
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
diag: Fix various issues with IOCTLs

DIAG kernel driver interacts with user space processes using
IOCTLS. Some issues, such as potential integer over/underflow,
incorrect buffer copy etc were identified in these functions.
This change fixes them.

Fix for the following CVE-
CVE#1 CVE-2012-4220
CVE#2 CVE-2012-4221

CRs-Fixed: 385352, 385349
Change-Id: Ie37dbda0acdc63fb440bd81d7f57c146f314b91a
Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
msm_serial_hs_hwreg.h: Correcting the even parity and odd parity bits

Currently parity bits are defined to be used with UART_DM_MR2
register with PARITY_MODE Bit as below :
EVEN_PARTIY = 1 and ODD_PARITY = 2
With these values, UART functionality doesn't work after enabling parity.
Hence adding correct used PARITY_MODE bits value as
EVEN_PARITY = 2 and ODD_PARITY = 1
after confirming with UART hardware programming guide.

CRs-Fixed: 410377
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
(cherry picked from commit fd40e5f6313fbc74e8897927be1004faa5d9df08)

Change-Id: Ia7461d1983336b1d965498ede00001cc67c1d925
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: display: Buffer sync point support

Add MSMFB_BUFFER_SYNC ioctl for the communication of
the acquired and released fence fd between kernel and hwc.

Wait for acquired fence before pan display.
Signal the previous released fence after pan display

(cherry picked from commit fd384f86cd5214a9359c56dc93affe95f2d802a4)

Change-Id: I30a7b33f523acc6e42978c8cbd0fa526808a06ed
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: add sync point support in overlay commit

Wait for fence signaled before commit, signal previous
fence after commit done. Same as pan display

(cherry picked from commit e622fc13cb58becfc077a830421e471abcc08140)

Change-Id: Ic7f95de86c5776a17ab1e5b7457e2dfb1108b576
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: make pan display as a non-blocking call

Schedule a workqueue, do the current job in the workqueue handler.
Block the second entry if the first one has not finished

(cherry picked from commit c760154faefd4772824cc2b032f5375f4ff1b75e)

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

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: add display commit ioctl

Display commit ioctl will do what pan_display
can do, addtionally has customized setting, such
as non-blocking call.

(cherry picked from commit d88df9d27e44fc35d16c7a4ea92508db1df12d8f)

Change-Id: I17e781c96f93f3d937020392e3bb7f090283a0b2
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
	include/linux/msm_mdp.h
msm: rotator: sync point support

Wait for fence before do rotate
Put the fence and fd after fence is signaled

(cherry picked from commit 78c7b6971a12a541c7bd55cb4998bf1bf285609e)

Change-Id: Ia9092a9d19e5c8390a05cef7bdf908732bbbf8d6
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: fence fd releasing

Release the fence fd after the fence has been signaled.

(cherry picked from commit 67945f986c46d592e26faba303b8b694397432a4)

Change-Id: Idc79eda3cbb518938d83a6c86a9af96db7f4675e
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: buf sync enhancement

Support wait for fence when flag is set

(cherry picked from commit 0745ebc4d82b4676da9b5ab8490824f6f9faa31b)

Change-Id: I2096103149874b3c7db90c38df59a1c767146994
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: allow fb open even in suspend state

resume might be coming later, allow fb open sucessfully, only
panel driver needs be delayed

(cherry picked from commit 89380aac14332dd3ff39a3f0904bfed117458abc)

Change-Id: Id24112f5bba7ba6290113987ebcc8ba6e4256419
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: Do not create release fence in suspend

When in suspend state, display operation will be stopped,
fence will not be signaled

(cherry picked from commit effec4d54954e67c91ba50eb228ecf56025d78ab)

Change-Id: Icbdd30995fa6662f28b003880c79d384d6f3b482
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: panel recovering from suspend

In suspend state, fb_open cannot turn on panel, need save this info
for resume.
In suspend state, blank setting needs be cached to be used at resuming.

(cherry picked from commit 9f7c82eaed91b9950d5ff5b1bbc77c6221a98afb)

Change-Id: I222f706774d0eed61a1cba6e8154ffd2337c2563
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: fb: make the pan task interruptible

(cherry picked from commit f35e93e2bbd636b25888d4283b17791b6f98fa78)

Change-Id: Ica9fea1b3523ba7c3e4e335ef9b0a54fbf1c8136
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: add more checking to ensure display is idle

Before execute operation on display, make sure it is complete idle
Because non-blocking display update has been introduced, need make sure
display update has finished in all entrances except the ones for
initialization.

(cherry picked from commit 43d62bf4b61cbaf52677126a4899ff8b489cdd76)

Change-Id: I18bee54c950404bea7ab89c9575c888e4c015935
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: add mutex for display driver entries

In some cases, display driver is called by multiple threads, this
will cause re-entrance problem. For example, one thread is
calling display commit, the other turns off the display. In order
to serialize the operation, mutex is added to most APIs.
Only the ones for initialization won't be added.

(cherry picked from commit 12c51684416bf5cc14d645fb741eea8d3d6627fa)

Change-Id: I84359d2e89930b61f5a0641b5e3078f9846c60ab
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: sync point handling in blanking

Release all fences when go to blank

(cherry picked from commit 2575a4aa634aec1c198dd8bc851c5a002dff2278)

Change-Id: I9d6a1f4ccd97b188497866b7f27cd9d3f84c94fc
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb: display: Protecting error condition if pipe alloc fails

(cherry picked from commit 4904a6e1f0ec57c0f1e240afc00314154317bc9c)

Change-Id: I4c41184fbbe2d40bdd36d40dd21d9a98adb2a76a
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_writeback.c