Skip to content

Commit

Permalink
Simple GPU Algorithm: Initial coding for devfreq based Adreno Drivers
Browse files Browse the repository at this point in the history
This is an open source user configurable simple GPU Control Algorithm used to
replace the closed sourced Qualcomm TrustZone GPU controller

Signed-off-by: Paul Reioux <reioux@gmail.com>
  • Loading branch information
faux123 authored and yank555-lu committed May 21, 2014
1 parent a837b06 commit b3c4e66
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/devfreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ config DEVFREQ_GOV_MSM_ADRENO_TZ
Sets the frequency using a "on-demand" algorithm.
This governor is unlikely to be useful for other devices.

config SIMPLE_GPU_ALGORITHM
bool "Simple GPU algorithm"
depends on DEVFREQ_GOV_MSM_ADRENO_TZ
help
Simple user configurable GPU controlling algorithm

comment "DEVFREQ Drivers"

config ARM_EXYNOS4_BUS_DEVFREQ
Expand Down
1 change: 1 addition & 0 deletions drivers/devfreq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE) += governor_performance.o
obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE) += governor_powersave.o
obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += governor_userspace.o
obj-$(CONFIG_DEVFREQ_GOV_MSM_ADRENO_TZ) += governor_msm_adreno_tz.o
obj-$(CONFIG_SIMPLE_GPU_ALGORITHM) += simple_gpu_algorithm.o

# DEVFREQ Drivers
obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ) += exynos4_bus.o
16 changes: 16 additions & 0 deletions drivers/devfreq/governor_msm_adreno_tz.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ static void _update_cutoff(struct devfreq_msm_adreno_tz_data *priv,
}
}

#ifdef CONFIG_SIMPLE_GPU_ALGORITHM
extern int simple_gpu_active;
extern int simple_gpu_algorithm(int level,
struct devfreq_msm_adreno_tz_data *priv);
#endif

static int tz_get_target_freq(struct devfreq *devfreq, unsigned long *freq,
u32 *flag)
{
Expand Down Expand Up @@ -137,10 +143,20 @@ static int tz_get_target_freq(struct devfreq *devfreq, unsigned long *freq,
if (priv->bin.busy_time > CEILING) {
val = -1 * level;
} else {
#ifdef CONFIG_SIMPLE_GPU_ALGORITHM
if (simple_gpu_active != 0)
val = simple_gpu_algorithm(level, priv);
else
val = __secure_tz_entry3(TZ_UPDATE_ID,
level,
priv->bin.total_time,
priv->bin.busy_time);
#else
val = __secure_tz_entry3(TZ_UPDATE_ID,
level,
priv->bin.total_time,
priv->bin.busy_time);
#endif
}
priv->bin.total_time = 0;
priv->bin.busy_time = 0;
Expand Down
77 changes: 77 additions & 0 deletions drivers/devfreq/simple_gpu_algorithm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Author: Paul Reioux aka Faux123 <reioux@gmail.com>
*
* Copyright 2011~2014 Paul Reioux
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/module.h>
#include <linux/devfreq.h>
#include <linux/msm_adreno_devfreq.h>

static int default_laziness = 4;
module_param_named(simple_laziness, default_laziness, int, 0664);

static int ramp_up_threshold = 5000;
module_param_named(simple_ramp_threshold, ramp_up_threshold, int, 0664);

int simple_gpu_active = 0;
module_param_named(simple_gpu_activate, simple_gpu_active, int, 0664);

static int laziness;

int simple_gpu_algorithm(int level,
struct devfreq_msm_adreno_tz_data *priv)
{
int val;

/* it's currently busy */
if (priv->bin.busy_time > ramp_up_threshold) {
if (level == 0)
val = 0; /* already maxed, so do nothing */
else if ((level > 0) &&
(level <= (priv->bus.num - 1)))
val = -1; /* bump up to next pwrlevel */
/* idle case */
} else {
if ((level >= 0) &&
(level < (priv->bus.num - 1)))
if (laziness > 0) {
/* hold off for a while */
laziness--;
val = 0; /* don't change anything yet */
} else {
val = 1; /* above min, lower it */
/* reset laziness count */
laziness = default_laziness;
} else if (level == (priv->bus.num - 1))
val = 0; /* already @ min, so do nothing */
}
return val;
}
EXPORT_SYMBOL(simple_gpu_algorithm);

static int __init simple_gpu_init(void)
{
return 0;
}
subsys_initcall(simple_gpu_init);

static void __exit simple_gpu_exit(void)
{
return;
}
module_exit(simple_gpu_exit);

MODULE_AUTHOR("Paul Reioux <reioux@gmail.com>");
MODULE_DESCRIPTION("'simple_gpu_algorithm - A Simple user configurable GPU"
"Control Algorithm for Adreno GPU series");
MODULE_LICENSE("GPL");

0 comments on commit b3c4e66

Please sign in to comment.