msm: mdss: fix double sync fence put in buf sync function

If an error occurs after setting acquire fds, the list of sync fences
will be put for cleanup. However if mdss_fb_wait_for_fence() is called
this will also wait and clear the list of fences, since we are relying
on local variable for cleanup, it may not reflect the state after the
function call. Fix this by maintaining the proper state of the list.

CRs-fixed: 548042
Change-Id: I4885eb393ac9bd2b4818292b9a60f53fb4baacc8
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: mdss: Fix race condition during device shutdown

During device shutdown or restart, two separate contexts can call
mdss_fb_release. One system shutdown/restart thread which calls
shutdown routine registered through device driver. Other closing
of frame buffer devices from user processes. Fix race condition
between these two contexts by using proper locking mechanism and
releasing all the resources.

Change-Id: I583b0f1273d984215e276daf3b6307f3b6e9e8c6
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: release all overlay resources on last fb release

There are cases where the last frame buffer reference is released from a
different pid than the one who originally allocated the resource.
In these cases we can still deallocate all resources currently allocated
as we know that all references on fb dev have been released.

This issue was previously fixed by a42150bd. But later it again resurfaced
with 831a828.

Change-Id: Ie35194b1e11ae90ff886b1be22cf02c842a76d1a
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: release all overlay resources if calling process is unknown

There are cases where fb release is called from a process which is
unknown to internal process tracking list. This usually happens when
a crash handlers closes open fds in a kernel worker thread rather than
in process context. In such cases if fb open happens from a completely
new process then it may lead to pipe leakage due to race condition
between unknown process and this new, fb open, process. Prevent this by
releasing all overlay resources when fb release is called from an
unknown process context.

Change-Id: I07157116413dfb26e0b87c61f9def916a653340a
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
mdss: fb: Unblock blit ioctl calls when commit is occuring

Since BLIT calls have no effect on the frame being commited it
does not need to block in pan_idle.

Change-Id: Ic0cfa7c0c275ddc051b60ff8823fcd7299cb8b57
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
Merge branch 'cm-11.0' into martincz