msm: kgsl: Add GFP_NORETRY to the page_alloc flags and handle errors

The most important thing for the memory allocator is to not crash
or otherwise behave badly during low memory situations. Adding
GFP_NORETRY keeps the OOM killer from being invoked making the 32MB
padding on the allocation redundant.  Remove the padding, add the flags
and go down the proper error path when alloc_pages() fails.

Change-Id: Ic0dedbadaf86e248b372b22cd3a41a5dabedb82e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Don't do intensive memory recovery when allocating big pages

We don't want to incur too much overhead when allocating big pages
so don't attempt to retry, perform reclaim, or run memory compaction
on high-order allocations.

Change-Id: Ic0dedbadb354c6faea34abec36aee268ac0f2c34
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ling Wan <lingw@codeaurora.org>
msm: kgsl: Use the correct length when looking for address collision

Use the right length of allocation from the aligned base address of
CPU virtual map to look for collision in the GPU vitual map. This
prevents discarding of usable address ranges due to false collision
hits.

CRs-Fixed: 492041
Change-Id: I370e6a31f98803e8ca6858a5562f47afeeaa157e
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Limit pagefault logging to 1 per page

Log only one pagefault error per page. If we log all the
pagefault errors it causes lot of messages in kernel logs
and sometimes leads to watchdog timeouts.

Change-Id: If8ee4ee28f6289277eb98d4d8ba73dfda6fc1133
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Do not hold memory spinlock when calling find region function

The function kgsl_sharedmem_find_region holds the memory spinlock
at the beginning of the function so we do not need to hold the lock
before calling the function

Change-Id: I20ee32e0ed6aee6ed61cdd4fb7a9cc08a876fc84
Signed-off-by: Shubhraprakash Das <sadas@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>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: kgsl: better handling of virtual address fragmentation

When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address
must try to match the GPU alignment requirements of the buffer,
as well as include space in the mapping for the guard page.
This can cause -ENOMEM to be returned from get_unmapped_area()
when there are a large number of mappings. When this happens,
fall back to page alignment and retry to avoid failure.

Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420
Signed-off-by: Jeremy Gebben <jgebben@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>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: kgsl: Add a check to free the kgsl_timeline object.

Add a check to free the kgsl_timeline object only after
destroy flag is set. This is to avoid further references to timeline
from kgsl if it is already freed and also to catch any unbalanced
kref count.

Change-Id: I8017b9a928a26b703eb92b17ab6a361e4b479e5a
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>