msm: kgsl: Save/restore performance counters across GPU power collapse

Physical performance counters are reset on GPU power collapse.
Save the values of the performance counters when the GPU goes to
power collapse and restore them on restart.

Change-Id: I63bec7b20e7fe516bbac4901cac0af3a1c1f4959
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Protect against a potential overflow in kgsl_sg_alloc

Avoid allocating a scatterlist so large that it overflows the size
passed to the memory allocators.

CRs-fixed: 564448
Change-Id: Ic0dedbad2ab421ddec8f3be38d61c9bdf9ae5bd4
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Add TSE performance counter to software hang detection

Our current hang detection logic covers rendering pass by checking for
shader performance counters but it does not cover the case where there
is long binning or resolve pass. For long binning pass shader is inactive
making our current hang detection logic faulty. Checking for TSE number of
input primitives covers binning and resolve passes and makes our hang
detection logic robust.

CRs-fixed: 521284
Change-Id: Ifdec4b53685903456feb367f64380119b1485408
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Get reference to process private when attaching mem entry

When a memory entry is attached with to a process private list then
increment the refcount of the process private structure so that the
structure is valid as long as the entry is around. The context
structure is also handled in similar manner. Also, the refcount to
the entry needs to be decremented when the handle that created the
entry goes away and not when the process private structure is
destroyed.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

Conflicts:
        drivers/gpu/msm/kgsl.c

Change-Id: I225698ad4081947a93eb553104e5259bbf31f293
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Allow GPU start to run in a high priority queue

The GPU start sequence needs to run with low latency when coming
out of slumber for the first draw command. For those cases allow the
start function to be queued into a high priority workqueue to reduce
the chance of it getting scheduled out.

Change-Id: Ic0dedbada7ef4d63b54e826862fbefdfb71a092a
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: Add an input handler to power up the GPU on a touch event

On a device where the primary input is a touchscreen nobody is
surprised that touch events are often the catalyst for drawing
frames. If the GPU is in slumber we can get a jump on the action
by watching for touch events and turning the GPU on in anticipation
of a draw call. Register for events from all input drivers
returning EV_ABS events and queue a work task to power up the GPU
if it is currently in slumber.

Change-Id: Ic0dedbadbdc96ef9ddd78252ea65f8e1cdd00110
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

Conflicts:
	drivers/gpu/msm/adreno_ringbuffer.c
cpufreq: interactive: lets push the input_boost_freq a notch.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
smp: patches from mainline 3.5 to hopefully help with hotplug
efficiency

Thomas Gleixner's generic-idle patches:

smp: Add task_struct argument to __cpu_up()
Preparatory patch to make the idle thread allocation for secondary
cpus generic.
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=8239c25f47d2b318156993b15f33900a86ea5e17

smp: Add generic smpboot facility
Start a new file, which will hold SMP and CPU hotplug related generic
infrastructure.
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=38498a67aa2cf8c80754b8d304bfacc10bc582b5

smp: Provide generic idle thread allocation
All SMP architectures have magic to fork the idle task and to store it
for reusage when cpu hotplug is enabled. Provide a generic
infrastructure for it.
Create/reinit the idle thread for the cpu which is brought up in the
generic code and hand the thread pointer to the architecture code via
__cpu_up().
Note, that fork_idle() is called via a workqueue, because this
guarantees that the idle thread does not get a reference to a user
space VM. This can happen when the boot process did not bring up all
possible cpus and a later cpu_up() is initiated via the sysfs
interface. In that case fork_idle() would be called in the context of
the user space task and take a reference on the user space VM.
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=29d5e0476e1c4a513859e7858845ad172f560389

arm: Use generic idle thread allocation
http://git.kernel.org/?p=linux/kernel/git/tip/tip.git;a=commit;h=84ec6d5796e095e2f8698bd2b5d33849ed26d9e2
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
cpufreq: interactive: remove input_wq high priority flag.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
sched: LOAD_FREQ (4*HZ+61) avoids loadavg Moire. From http://ripke.com/loadavg/moire

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
block: row: add magic values.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Add overclock capabilities. Grabbed the CPU tables from @morfic

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Merge https://github.com/franciscofranco/hammerhead into android-msm-hammerhead-3.4-kitkat-mr1