msm: kgsl: Fixes from caf 3.5

msm: kgsl: Get reference to process private when attaching mem entry

When a memory entry is attached with to a process private list then
increment the refcount of the process private structure so that the
structure is valid as long as the entry is around. The context
structure is also handled in similar manner. Also, the refcount to
the entry needs to be decremented when the handle that created the
entry goes away and not when the process private structure is
destroyed.

Conflicts:
        drivers/gpu/msm/kgsl.c

Change-Id: I225698ad4081947a93eb553104e5259bbf31f293
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl.c

msm: kgsl: avoid vmap failure while allocating big buffers

Limit the amount of pages vmapped at one time during allocation,
to avoid requesting more vmalloc space than is likely available.

CRs-Fixed: 445005
Change-Id: Icee5912687edf4da585d88308ee0e1c971964785
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl_sharedmem.c

msm: kgsl: Fix page align allocation overflow

KGSL does alignments for all user memory requests. If the
request is large enough the alignment operation will overflow
resulting in a valid request of size 0. It's just a matter of
time until the kernel or user tries to then do something useful
with this buffer resulting in a hang. Perform a sanity check
after doing the alignments to ensure the overflow did not occur.

Change-Id: I68f0f2c7dfdfb117e6d1320ec594cbdf75407a3e
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

msm: kgsl: Don't open kgsl device in erroneous case

If kgsl_get_process_private() returns NULL, it goes to
err_stop with result = -ENOMEM. If open_count is 0,
adreno_stop() overwrites the result variable with 0.
This leads to kgsl_open() to be successful while it
shouldn't.

Change-Id: Ic12d92a099280e4d958fa192fa5128211120d361
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>

msm: kgsl: prevent kgsl_get_pagetable from returning a destroyed pt

A race condition exists between kref_get_pagetable and
kref_put_pagetable such that is is possible to put the last
reference to a pagetable slightly before it has been removed
from the list. By checking kref_get_unless_zero we can determine
if the last reference has already been released. This is safe
because the list is protected by a ptlock.

Change-Id: If6a75e9ca0dec6a12bda5739f835c936a4c3a3b4
Signed-off-by: Jeff Boody <jboody@codeaurora.org>