Release 4.11 drivers/cpufreq/cpufreq_userspace.c
/*
* linux/drivers/cpufreq/cpufreq_userspace.c
*
* Copyright (C) 2001 Russell King
* (C) 2002 - 2004 Dominik Brodowski <linux@brodo.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/cpufreq.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
static DEFINE_PER_CPU(unsigned int, cpu_is_managed);
static DEFINE_MUTEX(userspace_mutex);
/**
* cpufreq_set - set the CPU frequency
* @policy: pointer to policy struct where freq is being set
* @freq: target frequency in kHz
*
* Sets the CPU frequency to freq.
*/
static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq)
{
int ret = -EINVAL;
unsigned int *setspeed = policy->governor_data;
pr_debug("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq);
mutex_lock(&userspace_mutex);
if (!per_cpu(cpu_is_managed, policy->cpu))
goto err;
*setspeed = freq;
ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
err:
mutex_unlock(&userspace_mutex);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jones | 45 | 50.56% | 1 | 12.50% |
Sai Gurrappadi | 14 | 15.73% | 1 | 12.50% |
Thomas Renninger | 9 | 10.11% | 1 | 12.50% |
Dominik Brodowski | 9 | 10.11% | 2 | 25.00% |
Andrew Morton | 4 | 4.49% | 1 | 12.50% |
Venkatesh Pallipadi | 4 | 4.49% | 1 | 12.50% |
Mike Travis | 4 | 4.49% | 1 | 12.50% |
Total | 89 | 100.00% | 8 | 100.00% |
static ssize_t show_speed(struct cpufreq_policy *policy, char *buf)
{
return sprintf(buf, "%u\n", policy->cur);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dominik Brodowski | 22 | 81.48% | 1 | 33.33% |
Dave Jones | 4 | 14.81% | 1 | 33.33% |
Viresh Kumar | 1 | 3.70% | 1 | 33.33% |
Total | 27 | 100.00% | 3 | 100.00% |
static int cpufreq_userspace_policy_init(struct cpufreq_policy *policy)
{
unsigned int *setspeed;
setspeed = kzalloc(sizeof(*setspeed), GFP_KERNEL);
if (!setspeed)
return -ENOMEM;
policy->governor_data = setspeed;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sai Gurrappadi | 47 | 100.00% | 1 | 100.00% |
Total | 47 | 100.00% | 1 | 100.00% |
static void cpufreq_userspace_policy_exit(struct cpufreq_policy *policy)
{
mutex_lock(&userspace_mutex);
kfree(policy->governor_data);
policy->governor_data = NULL;
mutex_unlock(&userspace_mutex);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sai Gurrappadi | 18 | 50.00% | 1 | 33.33% |
Rafael J. Wysocki | 10 | 27.78% | 1 | 33.33% |
Dominik Brodowski | 8 | 22.22% | 1 | 33.33% |
Total | 36 | 100.00% | 3 | 100.00% |
static int cpufreq_userspace_policy_start(struct cpufreq_policy *policy)
{
unsigned int *setspeed = policy->governor_data;
BUG_ON(!policy->cur);
pr_debug("started managing cpu %u\n", policy->cpu);
mutex_lock(&userspace_mutex);
per_cpu(cpu_is_managed, policy->cpu) = 1;
*setspeed = policy->cur;
mutex_unlock(&userspace_mutex);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafael J. Wysocki | 27 | 38.57% | 1 | 12.50% |
Dominik Brodowski | 12 | 17.14% | 1 | 12.50% |
Dave Jones | 8 | 11.43% | 1 | 12.50% |
Sai Gurrappadi | 7 | 10.00% | 1 | 12.50% |
Viresh Kumar | 6 | 8.57% | 1 | 12.50% |
Venkatesh Pallipadi | 4 | 5.71% | 1 | 12.50% |
Mike Travis | 4 | 5.71% | 1 | 12.50% |
Andrew Morton | 2 | 2.86% | 1 | 12.50% |
Total | 70 | 100.00% | 8 | 100.00% |
static void cpufreq_userspace_policy_stop(struct cpufreq_policy *policy)
{
unsigned int *setspeed = policy->governor_data;
pr_debug("managing cpu %u stopped\n", policy->cpu);
mutex_lock(&userspace_mutex);
per_cpu(cpu_is_managed, policy->cpu) = 0;
*setspeed = 0;
mutex_unlock(&userspace_mutex);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafael J. Wysocki | 24 | 42.11% | 1 | 14.29% |
Mike Travis | 9 | 15.79% | 1 | 14.29% |
Dominik Brodowski | 7 | 12.28% | 1 | 14.29% |
Viresh Kumar | 6 | 10.53% | 1 | 14.29% |
Sai Gurrappadi | 5 | 8.77% | 1 | 14.29% |
Dave Jones | 4 | 7.02% | 1 | 14.29% |
Andrew Morton | 2 | 3.51% | 1 | 14.29% |
Total | 57 | 100.00% | 7 | 100.00% |
static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy)
{
unsigned int *setspeed = policy->governor_data;
mutex_lock(&userspace_mutex);
pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n",
policy->cpu, policy->min, policy->max, policy->cur, *setspeed);
if (policy->max < *setspeed)
__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
else if (policy->min > *setspeed)
__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
else
__cpufreq_driver_target(policy, *setspeed, CPUFREQ_RELATION_L);
mutex_unlock(&userspace_mutex);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dominik Brodowski | 42 | 38.89% | 2 | 18.18% |
Rafael J. Wysocki | 21 | 19.44% | 1 | 9.09% |
Sai Gurrappadi | 19 | 17.59% | 1 | 9.09% |
Thomas Renninger | 8 | 7.41% | 1 | 9.09% |
Dave Jones | 7 | 6.48% | 3 | 27.27% |
Viresh Kumar | 5 | 4.63% | 1 | 9.09% |
Andrew Morton | 4 | 3.70% | 1 | 9.09% |
Mike Travis | 2 | 1.85% | 1 | 9.09% |
Total | 108 | 100.00% | 11 | 100.00% |
static struct cpufreq_governor cpufreq_gov_userspace = {
.name = "userspace",
.init = cpufreq_userspace_policy_init,
.exit = cpufreq_userspace_policy_exit,
.start = cpufreq_userspace_policy_start,
.stop = cpufreq_userspace_policy_stop,
.limits = cpufreq_userspace_policy_limits,
.store_setspeed = cpufreq_set,
.show_setspeed = show_speed,
.owner = THIS_MODULE,
};
static int __init cpufreq_gov_userspace_init(void)
{
return cpufreq_register_governor(&cpufreq_gov_userspace);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dominik Brodowski | 14 | 87.50% | 1 | 50.00% |
Dave Jones | 2 | 12.50% | 1 | 50.00% |
Total | 16 | 100.00% | 2 | 100.00% |
static void __exit cpufreq_gov_userspace_exit(void)
{
cpufreq_unregister_governor(&cpufreq_gov_userspace);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dominik Brodowski | 15 | 100.00% | 1 | 100.00% |
Total | 15 | 100.00% | 1 | 100.00% |
MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, "
"Russell King <rmk@arm.linux.org.uk>");
MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'");
MODULE_LICENSE("GPL");
#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE
struct cpufreq_governor *cpufreq_default_governor(void)
{
return &cpufreq_gov_userspace;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafael J. Wysocki | 13 | 100.00% | 1 | 100.00% |
Total | 13 | 100.00% | 1 | 100.00% |
fs_initcall(cpufreq_gov_userspace_init);
#else
module_init(cpufreq_gov_userspace_init);
#endif
module_exit(cpufreq_gov_userspace_exit);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dominik Brodowski | 179 | 29.54% | 2 | 8.70% |
Rafael J. Wysocki | 118 | 19.47% | 2 | 8.70% |
Sai Gurrappadi | 113 | 18.65% | 1 | 4.35% |
Dave Jones | 80 | 13.20% | 10 | 43.48% |
Viresh Kumar | 27 | 4.46% | 2 | 8.70% |
Mike Travis | 26 | 4.29% | 1 | 4.35% |
Venkatesh Pallipadi | 19 | 3.14% | 2 | 8.70% |
Thomas Renninger | 17 | 2.81% | 1 | 4.35% |
Andrew Morton | 15 | 2.48% | 1 | 4.35% |
Johannes Weiner | 12 | 1.98% | 1 | 4.35% |
Total | 606 | 100.00% | 23 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.