board-8974: enable ram console
msm: kgsl: Only turn on the idle timer when active_cnt is 0

Only turn on the idle timer when the GPU expected to be quiet.
If the idle timer is enabled while the GPU is busy, there is
a chance it might unnecessarily fire during heavy GPU activity
such as a compute job.

Additionally, rather than trying to NAP directly from
kgsl_active_count_put(), just trigger the idle check work.

All of this makes the idle check happen more consistently.

Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448
Signed-off-by: Jordan Crouse <jcrouse@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: validate fb backlight inputs

Ensure backlight level is less than the max backlight
brightness and the backlight scaling factor is at most
1.

Change-Id: I424ed22af48ecae46371291fe88a114cf3fc7c31
CRs-Fixed: 516699
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
msm: mdss: Make vsync wait non-interruptible in video_wait4comp

Currently in MDSS driver, vsync wait is getting interrupted due
to which input buffer to RGB pipe is getting unmapped/freed even
when the pipe is still connected to LM0 resulting in IOMMU fault.
So, making the vsync wait non-interruptible fixes the issue.

CRs-Fixed: 510352
Change-Id: I16d157079cc943ddfddc27a5317fc26c4fee1f0b
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: Return standard errno for error conditions

Replace ENOTSUPP with standard lib error EOPNOTSUPP in order
to update errno. Return EPERM error when VSYNC_ENABLED called
in suspend state in order to reflect the actual state of the
device. if no error returned applications would assume vsync
events are being generated when this is not true.

Change-Id: I72a7347ebecc71376884cf21b7e757f75ba9b40e
Signed-off-by: Ramkumar Radhakrishnan <ramkumar@codeaurora.org>
msm: mdss: Compensate for low VBP in MDP clock calculations

MDP latency is 4 lines with CAF and when the panel's vertical
Back porch value is lower than 4, the MDP clk rate needs to
be increased by 25% to compensate for the latency.

Change-Id: I732de52b4f5387d5c7992e893ea7cad5c6951811
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
mdss: ppp: Correct ppp bw request

Integer overflow occurred in calculating ib, this value was then
given to bw request resulting in an invalid request.

Change-Id: I71c56ecb7b412a8343ac400295a97f00207316e2
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
msm: mdss: hdmi-cec: bounds check cec frame size

Ensure that the frame size for the HDMI-CEC message
frame size doesn't exceed the maximum size when
reading message from userspace through sysfs interface.
This avoids potential overflow in cec send msg routine.

Change-Id: I891f23ed70ed5a6c0e3af1f47869effa079ffac8
CRs-Fixed: 520140
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
msm: mdss: hdmi: NUL-terminate spd data

NUL-terminate SPD Vendor name and SPD
Product description data stored in the
control structure of hdmi driver. This
avoids overflows in print messages and info
frames.

Change-Id: I0a0adcfad06625e4d7368d3c5cd0ec38f0e047d8
CRs-Fixed: 520148
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
msm: mdss: Avoid deadlock in interrupt handler

Reduce the locking scope in irq_dispatch so that
mdss_lock is not held when the irq_handler is dispatched.
The dispatched irq_handler will try to acquire mdp_lock but
another active process can already have mdp_lock and tries to
procure mdss_lock creating a deadlock situation. Not locking
with mdss_lock is acceptable as the calls will be synchronized
through mdp_lock from MDP clients.

CRs-Fixed: 528550
Change-Id: I586b7e00c046dd4081b4e838e62e0a0556f4c717
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: delay freeing buffers for additional vsync

There are cases where if commit happens very close to vsync or in other
uncommon conditions, where MDP will continue fetching from old buffer
address when unmap of the buffer happens. In order to avoid such
scenarios keep a reference of buffers for an additional commit before
unmapping to avoid potential iommu page fault.

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

Conflicts:

	drivers/video/msm/mdss/mdss_mdp_overlay.c
msm: mdss: Reset rotator_mode of writeback mixer in block mode on finish

The variable rotator_mode of mixer structure is used to program writeback
mixer in block mode. This structure member must be cleared on finish.

CRs-Fixed: 528743
Change-Id: I09b938def0cf1745f18e20d3bb04555209d1f269
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: disable MDP hw underflow recovery

When MDP underflows, hardware will automatically try to issue a reset to
recover from it. Potential issue has been identified when reset happens
on two video interfaces at the same time which may lead to a hw lockup.
To avoid such situations disable the hardware underflow recovery, MDP
will still automatically recover at the beginning of next frame.

Change-Id: I3473486e229e67f6213db83a0ecb34333a977d4f
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
mdss: display: unmap 'bl_fb_addr_va' when the mapping is no longer needed

Remove the mapping to the original continuous splash frame buffer
once its contents have been copied. This avoids a virtual address
leak, and holding a mapping to memory that may be eventually
reclaimed for use by other subsystem.

Change-Id: I8d7b6d954809a74d5a1ae60491e295b95458a2b7
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: mdss: Fix slower clocks during histogram and hist LUT accesses

Slower CNOC clock rates cause histogram and hist LUT access to take
longer time. Fix CNOC clock configuration at optimum rate in order
to avoid slow accesses to histogram and hist LUT.

Change-Id: I066bae9fd0b4261b71248cffea65d8949ff6aae2
Signed-off-by: Ping Li <quicpingli@codeaurora.org>

Conflicts:

	drivers/video/msm/mdss/mdss_mdp_overlay.c
msm: mdss: Reorder code to avoid null pointer dereference

Set mdss_res to NULL after mdss_mdp_pp_term function in err
case inside mdss_mdp_probe function. This change can avoid
null pointer dereference if err occurs during mdss_mdp_probe.

Change-Id: I90b289e03f2711d45dcb80d9fa6eeb78b447cfd4
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: sanitize histogram bin count

Ensure that histogram bin count value is sanitized,
this ensures that the length of data copied back to
user remains in check. This prevents excessive
data in kernel memory from being copied back to user.

Change-Id: I0f7787603bad950c0b187d8c38d4fa3366bc06b6
CRs-Fixed: 517476
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
msm: mdss: fix the incorrect default error code

In the default case, it should return success, instead
of an error.

Change-Id: Ic2c947fad59896f9e71d9af721c458e444db91d4
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: Fix register address range check

Register address range was incorrect. Fixed the bounds of the check

Change-Id: Ide6d912c77aa9e182e854d502551fc71f4bd3615
Signed-off-by: Benet Clark <benetc@codeaurora.org>