Revert "msm_fb: Fix the hang issues due to improper usage of vsync"

This reverts commit 3646c5c461e4429e0b87d0d38f4bb81b7930ce9f.
msm_fb: display: skip one vsync event after enabling mdp and vsync clk

Both mdp and mdp_vsync clks are disabled for command mode panel when
no new frames are being played. When they are re-enabled if new
requests come in, the first vsync event which is signaled by read
pointer interrupt arrives in a random time due to the sync between mdp
and panel, so skip it to maintain correct vsync timing.

Change-Id: I683b765e4a16d3d152b9270f5982234b94921f1e
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
(cherry picked from commit a4567ac320abe5d74b3c7decdbddba4bd8c57463)
msm: display: dsi command mode vsync time generation

In each vsync cycle there will be two vsync interrupts
generated, need ignore the wrong one to provide the correct vsync
timestamp.

CRs-fixed: 452269
Change-Id: Ic13eea77d15eb46f4879f818d346425c63efe41a
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm: mdp: Use a waitqueue for vsync notifications

Use a waitqueue instead of completions and make sure the vsync
show event always returns the timestamp except when it is
interrupted. This simplifies the vsync wait mechanism both here
and in userspace and avoids any unnecessary locking.

Change-Id: Ia3c2fce24e50d6b1e7fa1b36c668d5cc8678a1c6
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm_fb: display: wake up system before vsync for cmd panel

Add this feature for cmd mode panel. The feature is to avoid frame
drops due to power collapse and it is already present for other
display interfaces.

Change-Id: Ic68f41cd59931294b592577475ed7480459f2cf8
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdp: Wait unconditionally in internal vsync waits

Do not wait for timestamp to change for internal waits as the
waitqueue can be woken up from places where the vsync timestamp
doesn't change.

Change-Id: Ibd922d09975fad79065792f5da44816f3fea3044
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm_fb: display: add mdp master port1 bandwidth request

mdp bus traffic go through both mdp port0 and port1, but now mdp
bandwidth request is only for port0.

Change-Id: Ie902de6362cd9225abf6e9c42f260b5af7c3c6f8
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: display: get mdp bandwidth parameters from board file

Underrun issues can be solved by changing mdp bandwidth parameters:
max_bw, ab_factor and ib_factor. However these parameters are not
universally same for all targets, and one set of values that works for
one target could cause underruns or higher power on other
targets. This change is driver change which makes those parameters
target dependent.

CRs-Fixed: 464492
Change-Id: Ib23ebc431caabbe91c7ae3bd96bb38789d7ddc90
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: display: balance bus bandwidth on mdp axi port0 and port1

mdp read and write clients are connected on both mdp port0 and port1,
however, the bus bandwidth request is made on only port0. This change
divides mdp bw requests to port0 and port1 based on pipe connections
to mdp ports.
ab - no scaling factor - port0 and port1 split
ib - scaling factor - port 0 and port1 split

Change-Id: I9050d1178f634ca908675fa826d08bee09e2a2f3
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: display: add scaling factor for mdp ab

system profiling found that mdp downscaling needs larger bandwidth
that is related to mdp ab request, so adding scaling factor to mdp ab
calculation reduces the chance of underruns.

ab - scaling factors - port0 and port1 split
ib - 1.5 x ab - no split and same on both ports

Change-Id: I4fde87fce1cd292e317a8261e4700cf98662d09d
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: display: keep a minimum mdp ib bandwidth request

The calculated ab and ib bandwidth requests are very small which cause
underruns if mdp composites only very small layers. For these use
cases keeping a minimum ib request based on the baselayer size can
prevent underruns and no power impact is observed.

CRs-fixed: 472444
Change-Id: I08e77610aafdfa84c5c2a882a0c95a51950aa069
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: display: Add minimum src/dst image size validation for MDP

MDP4 has minimum size restriction for both source and destination
height and width. Add checks to validate source and destination
layer size.

CRs-fixed: 484728
Change-Id: I8cb8d4b969cd6ab2d8e99d7ed2ebb1a4adce1ef3
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: rotator: Wait for the pending commits in finish IOCTL

Due to asynchronuous rotator mechanism, sometimes the
MSM_ROTATOR_IOCTL_FINISH arrives before the previously queued
do_rotate work is completed. This causes fence to be signalled
before the buffer is used by rotator. In case of fast YUV 2 pass
scenario, this causes IOMMU page fault on 2 pass buffers, since
the buffer is unmapped when the rotator is still using it. Hence,
wait for the pending commit works to be finished before releasing
the fence and freeing the 2 pass buffers.

Change-Id: Iec9edd11406d102c7dd102c2ad7935184bbbba93
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm: display: provide mdp bandwidth parameters from board file

Underrun issues can be solved by changing mdp bandwidth parameters:
max_bw, ab_factor and ib_factor. However these parameters are not
universally same for all targets, and one set of values that works for
one target could cause underruns or higher power on other
targets. This is board side change.

CRs-Fixed: 464492
Change-Id: I2a8fbb9018011ddf42dfa50b371e450e38f4351a
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
video: msm: Add MDP bandwidth parameters for Celox/Quincy

Change-Id: I0b5afa247f394b2a34418f8cffbf965d74484909
video: msm: Cleanup and resync

Change-Id: Id47f64d918ab6fe2654783ce0dda569793fbfd9d
msm_fb: Set timeline threshold for command mode to 2

For command mode panel, timeline threshold is 1 and we return
commit ioctl on DMA_P interrupt. This causes fps to drop
since sometimes overlay is kickoff just after vsync interrupt
causing DMA_P wait time more than 1 vsync period. Hence, increase
timeline to 2 and return commit ioctl on vsync interrupt.

CRs-fixed: 457153
CRs-fixed: 452269
Change-Id: Ic7385631fdeb25f269306d284c94fdf43cade3d1
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: Fail fb2 open if called during suspend

At present, if msm_fb_open() for fb2 is called during suspend,
we increment the ref_count for fb2 and return success without
turning on the writeback pipeline. This causes the WFD client
think that fb2 is successfully opened whereas fb2_open should
not successful during suspend. Hence, return error if msm_fb_open()
is called for fb2 during suspend.

CRs-fixed: 475310
Change-Id: I73167a120a64ac18c5789ccc9cf7faad14b50b94
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: Fail fb2 open during suspend if ref_cnt is zero

Fail fb2 open during suspend if the ref_cnt for fb2 is zero
currently.

CRs-fixed: 475310
Change-Id: Ie5dd7c2dadecb489423cca1e2ff8276edc6314d7
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: display: command mode panel release fence

For command mode panel, release fence should be signaled after the buffer is
sent to the panel.  For performance consideration, allow one more commit to be
queued.  Keep the second kick off as short as enough.

Change-Id: I19af075ebf480d3e81b46b1cd2ef21a2893f143e
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>