msm: kgsl: Fixup the idle_timer save/store functions

Use standard kernel functions to convert between jiffies and
milliseconds.

Change-Id: Ic0dedbad8244518ec77024aaae170736dec9b93a
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

msm: kgsl: Streamline power level changes

Gather all power level restrictions in one place.  Make as
few paths through power level changes as possible.

Change-Id: I672fea958e965d6b65b697f16829553f4e8a99fd
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>

msm: kgsl: Enable frequency cycling for thermal mitigation

Allow thermal mitigation to select effective GPU frequencies
between the supported frequencies.  This gives more flexiblity
in the thermal performance limitations.

Change-Id: I618da263b02f09f293d737a13de567a3c31b37f0
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>

msm: kgsl: Skip dispatcher mutex owner check

Skip dispatcher mutex owner checking in adreno_idle
when we know that current thread doesn't own it.

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

msm: kgsl: Support offset and size for cache operations

Currently, IOCTL_KGSL_GPUMEM_SYNC_CACHE performs cache
operations on the entire memdesc. This change adds
support for performing the cache operation on a range
of memory defined by an offset and size

Change-Id: Icd8bf6f5a5c1a0335c6d278b950e19bdda0c95f6
Signed-off-by: Sushmita Susheelendra <ssusheel@codeaurora.org>

msm: kgsl: Restrict GPU memory object alignment to 32MB

The code was being very generous in giving the user the ability to
align GPU objects on 4GB boundaries. Cut the restriction down to
32MB which is still pretty generous but within the realm of
possiblity (especially for a 32 bit GPU).  While we are at it fix
a bug in the page_alloc code that was accidently resetting the
alignment to the alloc page size.  The alignment cannot be _less_
than the max page_alloc size but there certainly isn't any reason
why you couldn't specify a larger alignment if you so wished.

Change-Id: Ic0dedbadebd4c6fd98e3bf2f3d6d5bb924223157
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

msm: kgsl: Split out adreno_idle into a lighter weight function

In most cases idling the GPU is a heavy weight operation: stop the
dispatcher, wait for the hardware, deal with faults, etc. The idle
following ME_INIT is not one of those cases. The init sequence
is a controlled operation with a stopped dispatcher so we can forgo
the heavier bits of adreno_idle(). Break out the idle loop
and turn it into adreno_spin_idle() for use by both adreno_idle()
and ringbuffer init.

Change-Id: Ic0dedbad870ea65cc78d2a45d90ed895b87a7f5e
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: enable CPU IRQ while suspending context

Make sure that CPU interrupt is enabled before calling adreno
suspend_context when moving from NAP/SLEEP to SLUMBER state.
We send commands to GPU in adreno_drawctxt_switch() which will generate
GPU interrupt. Since CPU interrupt is not enabled, adreno_idle() will
fail because pending interrupt will not be served by CPU this causes
false GPU hang.

CRs-Fixed: 547813

Change-Id: Ia4b730b8f8cda1e820f571ffb7ddb00336ca1a8c
Signed-off-by: Gaurav Gagrani <ggagrani@codeaurora.org>
qseecom: Add support to handle multiple app load & unload

Media server is associated with multiple apps on TZ-side.
Unloading a single app for clean up is not enought. QSEECOM
needs to handle the app load & unload of multiple apps
associated with the client. During app_load & app_unload
along with app_id, app_name should also be checked. Besides,
keymaster will not be unloaded and app search execution
during app unload is optimized.

Change-Id: Ie92e97b9154851b713a8c3394b8ed10fdbdebd2f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: William Clark <wclark@codeaurora.org>