kgsl_pwrscale: Rework policy sysfs implementation

In the current implementation, the pwrscale policy kobj is
created when the pwrscale driver initializes.  It is then added
to the kobj hierarchy when a governor adds sysfs files.

When a governor removes sysfs files, it frees the kobj.

Then, when a new governor starts up, it attempts to add an
uninitialized kobj.  This fails.

Instead, use a constant kobj for the policy directory,
and add governor-specific attributes under it.  If a
sysfs group is given a name, all attributes in the group
will appear in a subdirectory with that name (see cpufreq
governor tuning variables).  Use this approach for our
governor tuning.

TODO (possibly in a future patch) - Rework this so the
governor attributes can be groups attached directly to
the pwrscale kobj.

Change-Id: I7b8ae6d5e690ee107be037ccaf2e737e52062feb
msm: kgsl: pwrscale functions should be run while GPU is ACTIVE

Base the decision to call power scaling functions on the current
state, not the requested state.  The GPU may not transition to the
requested state; call through based on current GPU state instead.

Change-Id: I1524bc92c908dc50a60b5815f2221ae3feef59be
CRs-Fixed: 441847
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Bump up the GPU frequency for long batch processing

Compute workloads run without kernel interaction for long periods
of time.  If one is identified early, increase the frequency to
finish it as fast as possible, rather than waiting for the standard
algorithm to do so.

Change-Id: I213ccabfae5e1000cdc34bc1d92bdc3bad86383d
CRs-Fixed: 441847
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
(cherry picked from commit 14c9cd845d6a93d7ab91fffa90fa316aebb18942)
msm: kgsl: Add CP_WAIT_FOR_IDLE packet before updating timestamp

HW workaround to resolve MMU pagefault caused by memory
freeing early before GPU completes it.

This is race condition where timestamp is getting updated
and the event handler runs before the GPU actually got done
with the timestamp, hence freeing the buffer early while GPU
still not completed with it.

Change-Id: I6d338d7dca680f57f2c39ed5a14381b261bf8bce
Signed-off-by: Anshuman Dani <adani@codeaurora.org>
(cherry picked from commit faf69cfeeede0883b9556e532d720ab4dc95b01d)

Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno_ringbuffer.c
msm: kgsl: Properly record the size of the sglist in the memdesc

It was possible to fail out of kgsl_sharedmem_alloc after a sglist was
allocated but before we saved the size of the allocation which caused
problems when the sglist was freed during cleanup.

CRs-fixed: 464289
Change-Id: Ic0dedbadd57ec4d9422b5e3a873243d0ffed51f7
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl_sharedmem.c
msm: kgsl: KlocWork fixes

KlocWork fixes to avoid NULL pinter dereference

Change-Id: I09f0239078f99ee5281319cae2d07e91a42e9b97
Signed-off-by: Ananta Kishore K <akollipa@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Verify the user doesn't accidentally submit a zero length IB

Indirect buffers to be executed will not be (and cannot be) zero length.
Check and reject.

Change-Id: I2114ca5de5227eb34d64789e2d30f02be396c719
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Init log levels in device init

Device log levels should be initialized during device initialization,
removing this from debugfs init because customer could disable
debugfs.

Signed-off-by: Arnav Gupta <championswimmer@aokp.co>

Conflicts:

	drivers/gpu/msm/adreno.c
	drivers/gpu/msm/kgsl_debugfs.c

Change-Id: I4286af72b487022dc9bb319d03b1a1392b79b8b6
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Init FT log level in device init

Currenlty FT log level is init in debugfs init, debugfs
could be removed from commercial software and we might
miss FT logs, initializing FT log level in device init
prevents this.

Change-Id: Ic363c2603f52eb1d37347b92c2d9c43e2df4ba5d
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Do not try to resume the device from INIT state

If the device is still in INIT state there are no open instances
of it running.  Resume calls should be no-ops.  Do not attempt
to start the device at this point.

Change-Id: Ia09cc3bf89201907c2cd587b70fbf8c156a60fcb
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>

Conflicts:
	drivers/gpu/msm/kgsl.c
msm: kgsl: Configure FT behaviour from sysfs instead of debugfs

FT behaviour is changed to be configured from sysfs
instead of debugfs. Sysfs control gives us the advantage
of configuring FT at bootup and also across bootups.
Persistant configuration across bootups helps
testing by configuring FT once and testing the FT
config across bootups.

Signed-off-by: Arnav Gupta <championswimmer@aokp.co>

Conflicts:

	drivers/gpu/msm/adreno.h
	drivers/gpu/msm/adreno_debugfs.c

Change-Id: I3f3b14011c5ea470a16e7f3f3f35cb8e0fd56261
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno.h