msm_fb: display: add wait after overlay kickoff

MDP writeback overlay kick off needs to be a blocking call to avoid
WFD tearing issues.

Change-Id: I03ce16b1e11c458bc8602880f22f1aed536a2e5a
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
(cherry picked from commit 7c31ee7933fff437acfaa69cf443c81638a495de)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
vidc: Handle EOS with Codec config buffer.

Change will handle codec config buffer with EOS.
Video driver will make sure that the codec config buffer with
EOS will be requeued in case of reconfig and non-reconfig paths.

CRs-fixed: 399347
Change-Id: I94ed460b04b76663895c6690c2f866590ac51c7d
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
(cherry picked from commit 43b203869814fe5f0ddcb265a8f859aebdaa652f)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
vidc: 1080p: IDR picture type support for H264 format

Read IDR picture type from 1080p core register set
and propagate it to user space using IDR frame type
enumeration in api header file. The IDR frame type
info is used in SYNCFRAME logic for H264 format in
userspace.

Change-Id: Ic677eb4d28469f6712832b7e09050467420eb70b
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm:vidc: add support for pause in eos state

This commit will add support for pause command in
eos state along with run state of the video driver.

(cherry picked from commit da817ebe8a4dea682b2cc9beaa582e0f0f0f0112)

Change-Id: Ia75c7ee43fb13cab5898ded69459469ddec4be54
CRs-fixed: 387562
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm: vidc: suppress non-fatal error messages.

These messages are non-fatal and appear frequently
during video session. Hence suppressing them.

CRs-fixed: 389408
Signed-off-by: Arun Menon <menon@codeaurora.org>
(cherry picked from commit 24631e349a3f306cc3b06fb411d5fb1f7ac8f0ae)

Conflicts:

	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.c
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c

Change-Id: Ifb874912ac79c863ed8fc531272d3822d8aebebe
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
vidc: 1080p: Reset meta data offset to zero

For multi-resolution clips, the meta data offset used while
doing cache clean of meta data buffer is from the previous
resolution & resulting in kernel panic. Resetting the offset
to zero during meta data buffer initialization for new
resolution fixes the issue.

CRs-fixed: 386245
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit 16145bcbd6af8db0eebc0eedec1f01ee1b0b3635)

Change-Id: I0f241ce99df62f02c2440fe3700a70d6c13b1537
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: vidc: Reset data corrupt flag for non-H264 decoder

Core does not set display correctness flag on decoder
output buffers for non H264 video codec. With this change,
we reset the data corrupt flag for non-H264 codec.

CRs-Fixed: 397599
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit fde67e239d8ac3a1e983b7d82d0c37af47464138)

Change-Id: I961413acda5b772879de6bc26d0d6d4d60eafcd5
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
ARM: smp: Fix cpu_up() racing with sys_reboot

Nothing stops a process from hotplugging in a CPU concurrently
with a sys_reboot() call. In such a situation we could have
ipi_cpu_stop() mark a cpu as 'offline' and _cpu_up() ignore the
fact that the CPU is not really offline and call the
CPU_UP_PREPARE notifier. When this happens stop_machine code will
complain that the cpu thread already exists and BUG_ON().

CPU0                      CPU1

sys_reboot()
 kernel_restart()
  machine_restart()
   machine_shutdown()
    smp_send_stop()
    ...                   ipi_cpu_stop()
                           set_cpu_online(1, false)
                            local_irq_disable()
                             while(1)
    <PREEMPT>
cpu_up()
 _cpu_up()
   if (!cpu_online(1))
    __cpu_notify(CPU_UP_PREPARE...)

cpu_stop_cpu_callback()
  BUG_ON(stopper->thread)

This is easily reproducible by hotplugging in and out in a tight
loop while also rebooting.

Since the CPU is not really offline and hasn't gone through the
proper steps to be marked as such, let's mark the CPU as inactive.
This is just as easily testable as online and avoids any possibility
of _cpu_up() trying to bring the CPU back online when it never was
offline to begin with.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 4a734179d918a4ee42c5fd6d54220eb6dd671ff0)

Change-Id: I03d8ed8226a9a9aab29499afcf052e0434fa2fe0
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
ARM: Fix deadlock scenario with smp_send_stop()

If one process calls sys_reboot and that process then stops other
CPUs while those CPUs are within a spin_lock() region we can
potentially encounter a deadlock scenario like below.

CPU 0                   CPU 1
-----                   -----
                        spin_lock(my_lock)
smp_send_stop()
 send_IPI               handle_IPI()
                         disable_preemption/irqs
                          while(1);
 <PREEMPT>
spin_lock(my_lock) <--- Waits forever

We shouldn't attempt to run any other tasks after we send a stop
IPI to a CPU so disable preemption so that this task runs to
completion.

CRs-Fixed: 396169
Reported-by: Sundarajan Srinivasan <sundaraj@codeaurora.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
(cherry picked from commit 78e9b56740ad789351b6d15cd9a67fe03091a3a1)

Change-Id: I7f9809a36264959d77276ce081b91426cfd9fce8
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
vidc: fix wrong number of slices in slice delivery mode

The slices completed is not matching with the expected number
of slices in frame done. The fix is available in July firmware
release and this commit will have the corresponding video driver
changes.

CRs-fixed: 380629
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit 909aebf7bd4d89fb5acccd64b27349cf93a736e0)

Change-Id: I7bd0cc4a381039d892ce884189a2e76462f89a19
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm_fb: display: free base layer pipe at adb stop

Base layer pipe need to be freed at adb stop so that same
pipe can be allocated at adb start.

CRs-fixed: 390644
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit 7e73b56cb67779bc700938acbb226dd99d361882)

Change-Id: I6f1f752fd5f4870eadadb6ef151e9108b90e243b
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: kgsl: Improved bounds checking on user specified parameters

Verify that the user specified length for a PMEM region is smaller
than the size of the entire region as reported by the kernel APIs.

CRs-fixed: 380282
Change-Id: Ic0dedbad0127bdaed70eafc00238b44f982b093b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 58ad656d0fc1447314d2682f87799d1e568ed8c5)
msm: kgsl: Detect and avoid malformed ioctl codes

Because we were using _IO_NR, one could construct a malformed ioctl
code that would avoid allocating memory yet go to a function that
expected that memory. Still use _IO_NR to index the array of ioctls,
but check that the full values match before jumping to the helper
function.

CRs-fixed: 385592
Change-Id: Ic0dedbaded469035bd0a2bb0f20fecb2a3045ca5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 1e76f61bb001b93795a227f8f808104b6c10b048)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: smd: call smem_find() after releasing spinlocks

If a subsystem crashes with a remote spinlock locked, then the subsystem
restart code should release it before attempting to access SMEM.
Originally when this code was written, smem_find() did not lock a remote
spinlock in violation of the SMEM protocol.  Once smem_find() was
updated to lock the remote spinlock, this deadlock scnario was created.

Do not call smem_find() until the remote spinlocks have been released
for the failed subsystem.

CRs-Fixed: 397287
Change-Id: I41086c81df5943659465741601191be9d243ca2c
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 50ad86febb34255ed47b7dd9840aaa6f1b257b3c)
msm_fb: display: Update mdp clocks based on perf patch

MDP clock was not getting updated to the correct values
causing underrun issues.

Change-Id: I4902ede1a8dda7408384261ca352e1ca1057a69c
Crs-Fixed: 395054, 395166
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
(cherry picked from commit edd57ca52bd12fa42865557bc5cfcc70cbbb8e6f)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: kgsl: Add MEM_WRITE type for postmortem dump

Add missed memory type to make postmortem dump more readable

Change-Id: I51e90efa24e85250c35d01dc504bde20e86dfc03
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
sync: Add synchronization framework

not run through checkpatch yet.

Change-Id: I209f9db2824e0313f467f11ab09e5f54f0a4a6b5
Signed-off-by: Erik Gilling <konkers@android.com>
sync: add timestamps to sync_pts

Change-Id: I2ad855072b86873880769a09a3176e85aa1199d7
Signed-off-by: Erik Gilling <konkers@android.com>
sync: add debugfs support

Change-Id: I8a7ea63e454fbeee1ecf17e6c3caff7c43b24734
Signed-off-by: Erik Gilling <konkers@android.com>
sync: add ioctl to get fence data

Change-Id: I71410aef7e03a52562f7cb15b993ac8441b1fa12
Signed-off-by: Erik Gilling <konkers@android.com>