msm: kgsl: Consolidate and correctly update reading pwrstats

Only read the various power counters before turning the clocks
off or when reporting to devfreq.  Reading them at other times
is redundant.  Make sure to accumulate the same set of counters
at both points.

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

msm: kgsl: Change call timing to alleviate mutex contention

Finish the state transition in the _idle_check function before
calling to update devfreq.  With this reordering the devfreq
notifier won't be stalled waiting for the GPU's device mutex.

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

msm: kgsl: Remove the frequency stepping work-around

In older hardware variants while running at GPU frequency x,
there was a .5x-2x limitation on changing it while the GPU was
active.  Therefore all frequency changes were stepped to avoid
stability issues.  This limitation is no longer in effect, so
remove the work-around.

Change-Id: I9716ba4cb40148d4db5ac1478b512a93707d88a1
CRs-fixed: 598694
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>

msm: kgsl: Consolidate sysfs store functions

Many of our sysfs _store hooks grok unsigned ints.  Use a common
function to replace the various sscanf() and strtoul() calls
scattered throughout the code.

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

msm: kgsl: Avoid mixing signed and unsigned ints in kgsl_sysfs_store

kstrtou32 returns negative on error or 0 on success.  kgsl_sysfs_store
then proceeded to either return the negative value or the unsigned int
'count'.  Furthermore it compared the return value of kgsl_sysfs_store
against an unsigned int so streams were crossed everywhere.

Remove the uneeded count paramater, return 0 or negative from
kgsl_sysfs_store and handle it appropriately.

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

msm: kgsl: Make sure the bus is on to consider power enabled

In theory only reg reads/writes should be using this check, and
they don't need the bus.  But just in case, make sure it is on
before allowing any activity.

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

msm: kgsl: Remove redundant logging on state change

This code would cause issues in the SLEEP state transition.
As the information it provides can be deduced other ways
remove the logging.

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

msm: kgsl: Rework the gpubusy and gputop sysfs variables

Remove gputop as the devfreq sysfs files make it redundant.
Update gpubusy to reflect the busy counter used by GPU DCVS
rather than the SW controled clock gating.  Users expect gpubusy
to reflect the GPU's running frequency.

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

msm: kgsl: Fixing min_pwrlevel kgsl sysfs element

The change 30a2b23 modified kgsl_sysfs_store function calls
everywhere except in the kgsl_pwrctrl_min_pwrlevel_store()
function. As a result min_pwrlevel sysfs item behaved incorrectly.

Correct the return code check for kgsl_sysfs_store call in
kgsl_pwrctrl_min_pwrlevel_store().

Change-Id: If2b0cc9b26625c1a326b6644ab183a36868666f9
Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: Reset the bus_mod value when power is re-enabled

kgsl_pwrctrl_pwrlevel_change() resets the bus_mod level when the
power level is changed but the power level doesn't get changed
on re-init if constraints are enabled with the net effect of
turning on the bus at a lower level than we would expect.  Reset
bus_mod in  kgsl_pwrctrl_enable() to make sure it always comes
up at the expected level.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: Remove io_fraction as it is no longer used

io_fraction was originally used as a way to influence the CPU
frequency governor.  Due to governor updates and timing changes
no targets use io_fraction now and there is no plan to do so in
the future.

Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>