msm: kgsl: fix MIN power constraints in non-trivial cases

Switching from a MAX to a MIN power constraint in the same
context is broken.  So is switching from a MAX context constraint
to a MIN constraint on a different context.  Clarify constraint
ownership, update the timestamps accordingly, and reset constraints
when changed by the context.

Change-Id: Id27dbc20e2aac994101817af3857451c1703219e
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Clear the memstore while destroying the context

When creating a context, we add the event group much before
initializing the memstore for that context. Between these events,
its possible that events are registered and retired and the
timestamp read in retire_events() gets us the last timestamp of
the last destroyed context. This results in the processed
timestamp to be greater than the actual retired timestamp in the
memstore which is very problematic for us.

CRs-Fixed: 640550
Change-Id: I2ace6d99e2ce417ba38f6bbbeeb787478eb4e372
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
msm: kgsl: remove power constraint on context destroy

Remove power constraint if parent context is
deleted before constraint expires.

Change-Id: I6a28fec842132733b2e9015333cc4d14c77daa8e
Signed-off-by: Oleg Perelet <operelet@codeaurora.org>
msm: kgsl: Add missing power constraint trace

Add missing trace to ensure debug logs show everything

Change-Id: I5da21b15ba498e1266d6c96b700c6c18135f92e9
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Respect power constraints for a full interval

No matter what type of constraint leave it in effect until
the constraint has expired.

Change-Id: I75118823fd484f87dda8e0f26fa3fe1ae12ca07d
Signed-off-by: Lucille Sylester <lsylvest@codeaurora.org>
msm: kgsl: Check constraint state coming out of slumber

Only set the default constraint when we come out of slumber if there
is no current constraint set. The current behavior will always override
the constraint that was set when coming out of slumber.

Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Change-Id: I58a5e2338bbee64e885edf697e83869820be2c22
msm: kgsl: Add CMA memory feature to support NOMMU for GPU

Reserves CMA memory for kgsl driver early during bootup and then
uses dma_alloc_coherent() to allocate physically contiguous memory
instead of using the MMU

Change-Id: Ica9b244fe9b9d8a902d670293a0bec2edf81bd5d
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
msm: kgsl: Use a constant mask for the memops vmflags

We don't need to define a function to return a constant.  Save
ourselves some source code and some .text space too.

Change-Id: Ic0dedbadc72c2fdd473cd4369ed772c84a923a15
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Don't set VM_IO on mmap()ed GPU memory objects

VM_IO prevents mapped memory from being peeked by ptrace(). That
kind of protection isn't really needed for nominal GPU buffers.
A process given itself up to ptrace() already expects to be
examined so there is no additional risk to let the parent examine
GPU buffers too.  This is done universally now, but there is no
reason why we wouldn't let the process choose which buffers to
keep private in the future.

That said; there is more of a concern about including GPU buffers
in a core dump since that is a more permanent and less secure
record of the memory so add VM_DONTDUMP for all GPU buffers to
protect against that.

CRs-Fixed: 654751
Change-Id: Ic0dedbade91a2ec458bcb27eff3312d4ec6e4389
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Mark mmapped objects with VM_DONTCOPY

Add VM_DONTCOPY to the default set of mmap flags to keep VM objects
from being copied on fork() and causing issues.  KGSL file descriptors
copied to a child are not expected to be usable.

Change-Id: Ic0dedbad85c07118a931ccb9f7a6fd0507da3e5a
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add a flag to mark user mapped GPU buffers

Add a flag in /sys/kernel/debug/kgsl/kgsl-3do/proc/<pid>/mem
file to indicate for each GPU buffer if it is mapped to userspace
in <pid> or not.

CRs-fixed: 634962
Change-Id: I8abda74ef5656aca6b1c0315af8deb77460fa5a9
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
re-add slim gpu boost, & interactive gpu governor after gpu upgrades

Conflicts:

	drivers/gpu/msm/kgsl_pwrscale_trustzone.c