mdss: display: add spin_lock to mdss_disable_irq_nosync()

Add spin_lock to mdss_lock inside mdss_disable_irq_nosync
to avoid race condition which can cause mdss_irq to be disabled
while irq_mask bits are still set.

CRs-Fixed: 624806
Change-Id: I44074a057dff49dfc7a4d2829f3c4e599dca4a69
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: mdss: Notify userspace of idle screen case

Expose two new sysfs nodes - idle_time and idle_notify - that
are used to notify userspace whenever the display is idle with
no screen updates. The idle_time node needs to be configured
with the duration in milliseconds to detect no screen updates.
The userspace app can poll on the idle_notify node to get
notifications of the idle state.

Change-Id: I7435a084ad2c928d952c5d106ff9ef92aaa385b9
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Neti Ravi Kumar <ravineti@codeaurora.org>
CRs-Fixed: 637403
msm: mdss: Make notify update waits interruptible

Wait for completion in notify update call are uninterruptible
causing excessive delay during suspend cases. Making them
interruptible.

Change-Id: I1a4ff6ce3e0add21d4e46a41372b076b277d10f5
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: fix race condition between shutdown thread and fb ioctl

Currently all entires into fb driver are synchronized with shutdown
context except fb ioctl context. fb ioctl is an asynchronous entry to
fb driver which can be called simultaneously from two different user
processes. Synchronize these fb ioctls and shutdown context to prevent
race condition.

Change-Id: I81ce48159fce69caabc3336d70df2bd15c4ee44b
CRs-Fixed: 640199
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: ensure pipe is halted before freeing buffers

When pipe is being detached from mixer, there is potential corner case
if underrun occurs at the same time which can cause pipe to flood the
VBIF. On the other hand unmapping a buffer requires VBIF to be idle to
sync TLB, so need to ensure pipe halt is done before freeing the pipe
buffers.

Change-Id: I9686b9d7d17d8dc2a8334157cfa8fa23ba5b47ee
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Handle case when pipe is not idle during cleanup.

When pipe is not idle during cleanup, MDP can go into an unrecoverable
state, which can lead into other issues. If it gets to this point we
need to recover even if it means changing display contents for a
fraction of time. To handle this follow recovery sequence:
1. Setup the pipes that are not idle to solid fill mode so that nothing
   is fetched from memory on these pipes.
2. Stage them into mixer, flush and wait for a vsync to happen and reset
   sequence to take effect on these.
3. Finally, reattach the current frame pipes to restore display back to
   normal.

Change-Id: If545b56bf32a46699871381d86e80c1980ec3cc7
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>