msm: kgsl: Fix several possible problem spots in the dispatcher

Fix a few spots that the compiler warnings missed. Avoid
dereferencing a pointer that may have returned ERR_PTR() without
first checking to see that if it did return ERR_PTR() and correct
an egregious signed / unsigned mixup. Not sure why the compiler
didn't yell at me for that one.

Change-Id: Ic0dedbadf075b34e51a89ce625d2308c5171a58d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Restrict the maximum memory entries for bulk cache sync

Restrict the maximum number of memory entries that can be specified
to a single bulk cache sync call to PAGE_SIZE / sizeof(unsigned int)
so that the allocation can always fit within one page.

CRs-fixed: 578062
Change-Id: Ic0dedbad07e1986cd6ccc5b260ffef82b5adb6d3
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: show timestamp in sync dump

Improve the debug information printed for kgsl points and timelines.

kgsl_sync_pt_value_str:
  - show timestamp passed to kgsl_add_fence_event()
kgsl_sync_timeline_value_str:
  - show most recent timestamp passed to kgsl_sync_timeline_signal()
  - show last retired timestamp according to kgsl_sync_get_timestamp()

Change-Id: I93fe408b06de054b11e05784cd7175ed3fcb76ad
Git-commit: 595e213985f63d6aa484c966a4f4a710b31ca209
Git-repo: https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm.git
Signed-off-by: Fred Fettinger <fred.fettinger@motorola.com>
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: generate descriptive names for kgsl-timeline

Generate names for kgsl-timelines using the following format:
<device>-<thread name>(<tid>)-<proc name>(<pid>)-<context id>

This makes it possible to identify the context of a timeline in the
sync dump, which makes it much easier to identify which context has
a GPU timeout.

Change-Id: I0ce0614a53a93fd81094d92c9bef7053e6d416d2
Git-commit: e3348f389f715cb2143a708ec6796d3f65e03821
Git-repo: https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm.git
Signed-off-by: Fred Fettinger <fred.fettinger@motorola.com>
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: mdss: wait for ping pong during unblank kickoff

During panel unblank a kickoff is done to turn on the panel so that the
first update is not delayed. However since buffer sync and display
commit is not called on this, need to make sure that the update finishes
completely including the workqueue that signals the fences. Signaling
the sync fence can potentially cause timeline to be ahead and end up
signaling the acquire fences early leading to source tearing on command
mode panels.

Change-Id: I56edf8355e1c635c3da24f20405c3ae4fe31cf2e
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Fix race conditions during device shutdown

Wait for the display commit thread to exit and abort all
pending ioctls when releasing the framebuffer device. This is
necessary to address any potential race conditions between these
threads that operate on a common data structure.

Change-Id: I5ab32758c34d4e80c4e85f949ffa0054d3cb5340
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: stop display commit thread only if it is running

When the framebuffer device is shutdown, it is possible that
the display commit thread has already been stopped. In such
scenarios, ensure that we not attempt to stop the thread again
to avoid any potential crashes.

CRs-Fixed: 584499
Change-Id: If0026cdcc4367c149815933ffe4ed08056d54770
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: Fix NULL pointer dereference in mdss_mdp_display_wait4comp

Add sanity check for ctl to prevent NULL pointer dereference
leading to kernel panic.

CRs-Fixed: 578595
Change-Id: Iace727501856d9f93ba87eca92f9f000c32d2c8f
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: initialize pipe to NULL

Initialize the pipe pointer to NULL.
So that even if the selection of pipe from pipe-pool
fails, the function returns NULL instead of an
uninitialized value.

Change-Id: Ib04c0a983cba6ffe9532862bcaf516877e49746a
CRs-Fixed: 524466
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
msm: mdss: Fix watermark level calculations for pipe updates

Watermark (wm) levels for active pipes are calculated and set for every
surface update regardless of pipe parameters are changed or not. In the
current implementation if reserved MMBs are not changed compared previous
frame then wm levels are reset to zero. This is not a correct behaviour
and may lead to under-runs. Fix this by setting wm levels based on
allocated MMBs.

Change-Id: I857c161f7203b64411e9345553f88c48f7726ee2
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: Enable fixed MMBs support for RGB pipes

RGB pipes in some of the chip-sets are statically tied to dedicated
Memory Macro Blocks (MMBs) out of common shared memory pool. These MMBs
cannot be used by other pipes. Enable support for this fixed MMBs by
parsing indexes from device tree and reserving fixed MMBs first before
general pool is used.

Change-Id: Ic4bc7fa790f430a2853719fec7fd849149bc6976
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: change SMP allocations for chroma decimation

When decimation is used, the chroma components are not down sampled in
order to prevent quality loss. This means that we need to consider this
extra pixels that are being fetched from memory for buffer latency (SMPs)
and bus bandwidth.

Change-Id: I9f05e4ece9240b787a8e2b3b3f69eec86d68b2b3
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: Fix MDP hang issue for H2V1 interleaved formats

MDSS HW with decimation block present, uses two SMP clients, Y and UV,
regardless of YUV surface is interleaved or planar. Current code takes
care of planar format but not interleave YUV. Fix this by temporarily
converting those formats to pseudo-planar while calculating SMP
requirements.

CRs-Fixed: 568011
Change-Id: I917f7dfd848144bcc4a6c463cd20fb302c432cc5
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: Fix NULL pointer deference in mdss_mdp_overlay_handle_vsync

Add NULL pointer checks to avoid NULL pointer dereference
resulting in kernel panic.

CRs-Fixed: 573022
Change-Id: Ib7fd1bb75553441c1100a1c2d0cf1ae56108c125
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: Returning NOTIFY_SUSPEND while polling NOTIFY_UPDATE

mdss_fb_update_notify does not return Suspend in NOTIFY_UPDATE
case. Daemon polls on NOTIFY_UPDATE but does not get Suspend
notification. Hence Daemon would not stop polling.

Suspend Case is added in UPDATE case.

Change-Id: Iaeaf819a6849acda2eb7eb78f0fc3306866d1b64
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: Avoid variable overloading

A particular variable is overloaded and used in 2 different
contexts. This causes overwriting of original value and leads
to incorrect error handling. This code adds a new variable to
avoid such condition.

Change-Id: Ibd040e6b4ce95759cc0011304940365c70e6c12a
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
msm: mdss: Add commit handler to writeback display

Add support for a "vsync handler" for writeback displays to be able to
schedule tasks to be run as soon as the frame has completed.

Change-Id: I8c6945a6e914e307de67b2ec6df25f4509a50da7
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: Call wait4comp after commit for wb intf

Writeback path uses the comp event allocated on
stack to wait for ISR done. It crashes if
ISR tries to set the comp event after kickoff
thread timeout. This change removes the comp
event usage for writeback interface and starts
to use the wait4comp API like video/command
mode interfaces.

CRs-fixed: 555036
Change-Id: I74994a0cbe4039c6d3d4a51d573d343751182bff
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: mdss: Set correct flush bit for writeback mixer.

Wrong flush bit is being set for writeback mixer which can cause
MDP hang/unexpected behaviour when the mixer is used in line mode.
This patch addresses the issue by setting the correct flush bit.

Change-Id: Ie0c2ee27b1f466164a8fb84f7daae9309b74d1d8
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
msm: mdss: increase height constraints for panel resolution

MDP is able to support higher resolution and is only limited in height
by the MDP clock rate. There is already check in place for the MDP clock
requirement, however need to update phase step calculation to handle
proper overflow conditions for these higher resolution according to
hardware constraints based on potential overflow while scaling with some
phase steps. At the same time hardware is able to handle some conditions
that are currently failed, so enable these to allow more cases that can
go through MDP.

Change-Id: I4c5a569e115302f05db7c525c0f8a76ed1738521
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>