Revert "cpufreq: performance: lock to 4 cores (metallice)"

This reverts commit 804b0198780a4cf39942d0c1d9569ae82164cf61.
cpuquiet: cleanup Kconfig and Makefile

Add options to enable/disable individual governors and adjust the Makefile
to only build the selected governors.

Change-Id: Ia3d36afd0f1d2e8cc622956fa0dc16c23cc9904d
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/131436
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

Rebase-Id: R0353ccd8d52227302fe7a890b9805b6c9170f58c

Conflicts:
	drivers/cpuquiet/Kconfig
	drivers/cpuquiet/governors/Makefile
cpuquiet: Update averaging of nr_runnables

Doing a Exponential moving average per nr_running++/-- does not
guarantee a fixed sample rate which induces errors if there are lots of
threads being enqueued/dequeued from the rq (Linpack mt). Instead of
keeping track of the avg, the scheduler now keeps track of the integral
of nr_running and allows the readers to perform filtering on top.

Implemented a proper exponential moving average for the runnables
governor and a straight 100ms average for the balanced governor. Tweaked
the thresholds for the runnables governor to minimize latency. Also,
decreased sample_rate for the runnables governor to the absolute minimum
of 10msecs.

Updated to K3.4

Change-Id: Ia25bf8baf2a1a015ba188b2c06e551e89b16c5f8
Signed-off-by: Sai Charan Gurrappadi <sgurrappadi@nvidia.com>
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/131147
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

Conflicts:
	drivers/cpuquiet/governors/balanced.c
cpuquiet: balanced governor requires cpufreq

The balanced governor relies on cpufreq for some of its decisions. Fail
initialization if there are no cpufreq OPP tables available.

Change-Id: I5d64215d56f50d5df52c1433208b1eb40440c812
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/131437
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

Rebase-Id: R03bb471218a088a816a67232861759cba2b91f38
cpuquiet: initialize runnable threads first as the default governor

Add the necessary code to initialize the runnable threads governor first when
selected as the default governor.

Change-Id: Iebbf304f3934b429d8a217011b3cb45ecddfd558
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/131438
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

Rebase-Id: Rb5009930e554648a17d78edf9d8bdd17199c9c6a
cpuquiet: Update runnable gov param 20/100ms (1.25/2.25/2.5 +.5)

Sampling interval: 20ms
Window size: 100ms

Thresholds: 1.25/2.25/2.5 thread
Hysteresis: .5 thread

Bug 1050445

Change-Id: I5138bed06e6f3548ec440d2b9ee17460fc37adfb
Signed-off-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-on: http://git-master/r/163105
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
cpuquiet: Make stats optional

Make the per CPU statistics a configureable option.

bug 1049625

Change-Id: I28b248bbbad89a19e8d8d69400733dfd4a2cf052
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/168749
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

Conflicts:
	drivers/cpuquiet/driver.c
cpuquiet: Fix race in runnable governor

Fixed a race where the cpuquiet driver would call device_free() before
the governor was started, which would lead to a kernel panic because
runnables_timer was not initialized.

Introduced RUNNING state, so states are:
- DISABLED: truly disabled
- IDLE: enabled, but not polling upon request from the driver
- RUNNING: actively polling

Bug 1189042

Change-Id: I45b9ce40e61e1cfddde74ff7b2691722204045bb
Signed-off-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-on: http://git-master/r/168803
Reviewed-by: Sang-Hun Lee <sanlee@nvidia.com>
Tested-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
cpuquiet: Add GCOV_PROFILE

Include cpuquiet in GCOV profiling when enabled by defconfig.

Change-Id: I448602d2c79f4113b99e6546743585e629fa726e
Signed-off-by: Juha Tukkinen <jtukkinen@nvidia.com>
Reviewed-on: http://git-master/r/131127
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

Rebase-Id: R7daa534f10a211bf7b15a253f5cfee7a126428f0
cpuquiet: Add GCOV_PROFILE for governors

Include cpuquiet in GCOV profiling when enabled by defconfig.

Change-Id: Iadac806d4b7efd9e34afa765dbec59f0491b96a8
Signed-off-by: Juha Tukkinen <jtukkinen@nvidia.com>
Reviewed-on: http://git-master/r/192980
Reviewed-by: Automatic_Commit_Validation_User
cpuquiet: Fix warning about unused variable

drivers/cpuquiet/governors/runnable_threads.c: In function 'runnables_work_func':
drivers/cpuquiet/governors/runnable_threads.c:184:14: warning: unused variable 'state' [-Wunused-variable]

Change-Id: I26c2288876043cf3dd21e1b57317a1f5b2de5a9b
Signed-off-by: Sami Liedes <sliedes@nvidia.com>
Reviewed-on: http://git-master/r/197469
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
cpuquiet: Remove synchronization from runnables_work_func()

runnables_stop() can deadlock when cancel_work_sync() waits for the
work function to end and the work function blocks on the same lock
held by runnables_stop().

Removing the locks from runnables_work_func() fixes this. This should
be safe because runnables_lock protects runnables_state and
runnables_work_func() only reads runnables_state. Also, the functions
that change state to DISABLED do a cancel_work_sync() to guarantee the
work function stopped running.

Bug 1215668

Change-Id: I70617b3b0fc81db8555869e67e3b11652af8d94c
Signed-off-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-on: http://git-master/r/193881
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
ARM: tegra: cpuquiet: make userspace governor actions synchronous

Userspace expects changes to happen synchronously. Implement this by waiting
with a (configureable) timeout for the action to happen.

Bug 1220065

Change-Id: I81301719707e4baf2b3aea62c38fc771ffe1205d
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/200013
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

Conflicts:
	arch/arm/mach-tegra/cpuquiet.c
cpuquiet: balanced: WQ_RESCUER has been removed

Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
cpuquiet: move back cpuquiet_lock

Moved cpuquiet_lock to the back of cpuquiet_switch_governor().
cpuquiet_switch_governor() has to be protected by cpuquiet_lock.
In the runnable cpuquiet_governor case, it can occur a kernel panic or BUG_ON
because schedule_work() and INIT_WORK() can be performed at the same time.

Bug 1410816

Change-Id: I6d3d69bd8896e5425a762cbc4a58343a319edf29
Signed-off-by: Jubeom Kim <jubeomk@nvidia.com>
(cherry picked from commit 8502d0b7c057f96b7cd0495b49e37fc968d4bf8a)
Reviewed-on: http://git-master/r/337335
Reviewed-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Tested-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
cpuquiet: Fix locking in driver_unregister

cpuquiet_switch_governors needs to be protected with the cpuquiet_lock.

Change-Id: I948d1190a270b9e8b732eaad80a303560fe9f282
Signed-off-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-on: http://git-master/r/345013
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>