Release 4.7 drivers/cpufreq/ia64-acpi-cpufreq.c
/*
* This file provides the ACPI based P-state support. This
* module works with generic cpufreq infrastructure. Most of
* the code is based on i386 version
* (arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c)
*
* Copyright (C) 2005 Intel Corp
* Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/cpufreq.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/pal.h>
#include <linux/acpi.h>
#include <acpi/processor.h>
MODULE_AUTHOR("Venkatesh Pallipadi");
MODULE_DESCRIPTION("ACPI Processor P-States Driver");
MODULE_LICENSE("GPL");
struct cpufreq_acpi_io {
struct acpi_processor_performance acpi_data;
unsigned int resume;
};
static struct cpufreq_acpi_io *acpi_io_data[NR_CPUS];
static struct cpufreq_driver acpi_cpufreq_driver;
static int
processor_set_pstate (
u32 value)
{
s64 retval;
pr_debug("processor_set_pstate\n");
retval = ia64_pal_set_pstate((u64)value);
if (retval) {
pr_debug("Failed to set freq to 0x%x, with error 0x%lx\n",
value, retval);
return -ENODEV;
}
return (int)retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 49 | 94.23% | 1 | 33.33% |
dominik brodowski | dominik brodowski | 2 | 3.85% | 1 | 33.33% |
denis v. lunev | denis v. lunev | 1 | 1.92% | 1 | 33.33% |
| Total | 52 | 100.00% | 3 | 100.00% |
static int
processor_get_pstate (
u32 *value)
{
u64 pstate_index = 0;
s64 retval;
pr_debug("processor_get_pstate\n");
retval = ia64_pal_get_pstate(&pstate_index,
PAL_GET_PSTATE_TYPE_INSTANT);
*value = (u32) pstate_index;
if (retval)
pr_debug("Failed to get current freq with "
"error 0x%lx, idx 0x%x\n", retval, *value);
return (int)retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 59 | 95.16% | 2 | 50.00% |
dominik brodowski | dominik brodowski | 2 | 3.23% | 1 | 25.00% |
denis v. lunev | denis v. lunev | 1 | 1.61% | 1 | 25.00% |
| Total | 62 | 100.00% | 4 | 100.00% |
/* To be used only after data->acpi_data is initialized */
static unsigned
extract_clock (
struct cpufreq_acpi_io *data,
unsigned value,
unsigned int cpu)
{
unsigned long i;
pr_debug("extract_clock\n");
for (i = 0; i < data->acpi_data.state_count; i++) {
if (value == data->acpi_data.states[i].status)
return data->acpi_data.states[i].core_frequency;
}
return data->acpi_data.states[i-1].core_frequency;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 86 | 98.85% | 2 | 66.67% |
dominik brodowski | dominik brodowski | 1 | 1.15% | 1 | 33.33% |
| Total | 87 | 100.00% | 3 | 100.00% |
static unsigned int
processor_get_freq (
struct cpufreq_acpi_io *data,
unsigned int cpu)
{
int ret = 0;
u32 value = 0;
cpumask_t saved_mask;
unsigned long clock_freq;
pr_debug("processor_get_freq\n");
saved_mask = current->cpus_allowed;
set_cpus_allowed_ptr(current, cpumask_of(cpu));
if (smp_processor_id() != cpu)
goto migrate_end;
/* processor_get_pstate gets the instantaneous frequency */
ret = processor_get_pstate(&value);
if (ret) {
set_cpus_allowed_ptr(current, &saved_mask);
pr_warn("get performance failed with error %d\n", ret);
ret = 0;
goto migrate_end;
}
clock_freq = extract_clock(data, value, cpu);
ret = (clock_freq*1000);
migrate_end:
set_cpus_allowed_ptr(current, &saved_mask);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 124 | 93.23% | 2 | 33.33% |
julia lawall | julia lawall | 6 | 4.51% | 1 | 16.67% |
dominik brodowski | dominik brodowski | 1 | 0.75% | 1 | 16.67% |
joe perches | joe perches | 1 | 0.75% | 1 | 16.67% |
alex williamson | alex williamson | 1 | 0.75% | 1 | 16.67% |
| Total | 133 | 100.00% | 6 | 100.00% |
static int
processor_set_freq (
struct cpufreq_acpi_io *data,
struct cpufreq_policy *policy,
int state)
{
int ret = 0;
u32 value = 0;
cpumask_t saved_mask;
int retval;
pr_debug("processor_set_freq\n");
saved_mask = current->cpus_allowed;
set_cpus_allowed_ptr(current, cpumask_of(policy->cpu));
if (smp_processor_id() != policy->cpu) {
retval = -EAGAIN;
goto migrate_end;
}
if (state == data->acpi_data.state) {
if (unlikely(data->resume)) {
pr_debug("Called after resume, resetting to P%d\n", state);
data->resume = 0;
} else {
pr_debug("Already at target state (P%d)\n", state);
retval = 0;
goto migrate_end;
}
}
pr_debug("Transitioning from P%d to P%d\n",
data->acpi_data.state, state);
/*
* First we write the target state's 'control' value to the
* control_register.
*/
value = (u32) data->acpi_data.states[state].control;
pr_debug("Transitioning to state: 0x%08x\n", value);
ret = processor_set_pstate(value);
if (ret) {
pr_warn("Transition failed with error %d\n", ret);
retval = -ENODEV;
goto migrate_end;
}
data->acpi_data.state = state;
retval = 0;
migrate_end:
set_cpus_allowed_ptr(current, &saved_mask);
return (retval);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 204 | 91.89% | 1 | 20.00% |
viresh kumar | viresh kumar | 8 | 3.60% | 1 | 20.00% |
dominik brodowski | dominik brodowski | 5 | 2.25% | 1 | 20.00% |
julia lawall | julia lawall | 4 | 1.80% | 1 | 20.00% |
joe perches | joe perches | 1 | 0.45% | 1 | 20.00% |
| Total | 222 | 100.00% | 5 | 100.00% |
static unsigned int
acpi_cpufreq_get (
unsigned int cpu)
{
struct cpufreq_acpi_io *data = acpi_io_data[cpu];
pr_debug("acpi_cpufreq_get\n");
return processor_get_freq(data, cpu);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 33 | 97.06% | 1 | 50.00% |
dominik brodowski | dominik brodowski | 1 | 2.94% | 1 | 50.00% |
| Total | 34 | 100.00% | 2 | 100.00% |
static int
acpi_cpufreq_target (
struct cpufreq_policy *policy,
unsigned int index)
{
return processor_set_freq(acpi_io_data[policy->cpu], policy, index);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 25 | 83.33% | 1 | 50.00% |
viresh kumar | viresh kumar | 5 | 16.67% | 1 | 50.00% |
| Total | 30 | 100.00% | 2 | 100.00% |
static int
acpi_cpufreq_cpu_init (
struct cpufreq_policy *policy)
{
unsigned int i;
unsigned int cpu = policy->cpu;
struct cpufreq_acpi_io *data;
unsigned int result = 0;
struct cpufreq_frequency_table *freq_table;
pr_debug("acpi_cpufreq_cpu_init\n");
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return (-ENOMEM);
acpi_io_data[cpu] = data;
result = acpi_processor_register_performance(&data->acpi_data, cpu);
if (result)
goto err_free;
/* capability check */
if (data->acpi_data.state_count <= 1) {
pr_debug("No P-States\n");
result = -ENODEV;
goto err_unreg;
}
if ((data->acpi_data.control_register.space_id !=
ACPI_ADR_SPACE_FIXED_HARDWARE) ||
(data->acpi_data.status_register.space_id !=
ACPI_ADR_SPACE_FIXED_HARDWARE)) {
pr_debug("Unsupported address space [%d, %d]\n",
(u32) (data->acpi_data.control_register.space_id),
(u32) (data->acpi_data.status_register.space_id));
result = -ENODEV;
goto err_unreg;
}
/* alloc freq_table */
freq_table = kzalloc(sizeof(*freq_table) *
(data->acpi_data.state_count + 1),
GFP_KERNEL);
if (!freq_table) {
result = -ENOMEM;
goto err_unreg;
}
/* detect transition latency */
policy->cpuinfo.transition_latency = 0;
for (i=0; i<data->acpi_data.state_count; i++) {
if ((data->acpi_data.states[i].transition_latency * 1000) >
policy->cpuinfo.transition_latency) {
policy->cpuinfo.transition_latency =
data->acpi_data.states[i].transition_latency * 1000;
}
}
/* table init */
for (i = 0; i <= data->acpi_data.state_count; i++)
{
if (i < data->acpi_data.state_count) {
freq_table[i].frequency =
data->acpi_data.states[i].core_frequency * 1000;
} else {
freq_table[i].frequency = CPUFREQ_TABLE_END;
}
}
result = cpufreq_table_validate_and_show(policy, freq_table);
if (result) {
goto err_freqfree;
}
/* notify BIOS that we exist */
acpi_processor_notify_smm(THIS_MODULE);
pr_info("CPU%u - ACPI performance management activated\n", cpu);
for (i = 0; i < data->acpi_data.state_count; i++)
pr_debug(" %cP%d: %d MHz, %d mW, %d uS, %d uS, 0x%x 0x%x\n",
(i == data->acpi_data.state?'*':' '), i,
(u32) data->acpi_data.states[i].core_frequency,
(u32) data->acpi_data.states[i].power,
(u32) data->acpi_data.states[i].transition_latency,
(u32) data->acpi_data.states[i].bus_master_latency,
(u32) data->acpi_data.states[i].status,
(u32) data->acpi_data.states[i].control);
/* the first call to ->target() should result in us actually
* writing something to the appropriate registers. */
data->resume = 1;
return (result);
err_freqfree:
kfree(freq_table);
err_unreg:
acpi_processor_unregister_performance(cpu);
err_free:
kfree(data);
acpi_io_data[cpu] = NULL;
return (result);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 542 | 96.79% | 1 | 11.11% |
viresh kumar | viresh kumar | 6 | 1.07% | 3 | 33.33% |
pan xinhui | pan xinhui | 5 | 0.89% | 1 | 11.11% |
dominik brodowski | dominik brodowski | 4 | 0.71% | 1 | 11.11% |
joe perches | joe perches | 2 | 0.36% | 2 | 22.22% |
burman yan | burman yan | 1 | 0.18% | 1 | 11.11% |
| Total | 560 | 100.00% | 9 | 100.00% |
static int
acpi_cpufreq_cpu_exit (
struct cpufreq_policy *policy)
{
struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu];
pr_debug("acpi_cpufreq_cpu_exit\n");
if (data) {
acpi_io_data[policy->cpu] = NULL;
acpi_processor_unregister_performance(policy->cpu);
kfree(policy->freq_table);
kfree(data);
}
return (0);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 59 | 88.06% | 1 | 33.33% |
pan xinhui | pan xinhui | 7 | 10.45% | 1 | 33.33% |
dominik brodowski | dominik brodowski | 1 | 1.49% | 1 | 33.33% |
| Total | 67 | 100.00% | 3 | 100.00% |
static struct cpufreq_driver acpi_cpufreq_driver = {
.verify = cpufreq_generic_frequency_table_verify,
.target_index = acpi_cpufreq_target,
.get = acpi_cpufreq_get,
.init = acpi_cpufreq_cpu_init,
.exit = acpi_cpufreq_cpu_exit,
.name = "acpi-cpufreq",
.attr = cpufreq_generic_attr,
};
static int __init
acpi_cpufreq_init (void)
{
pr_debug("acpi_cpufreq_init\n");
return cpufreq_register_driver(&acpi_cpufreq_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 20 | 95.24% | 1 | 50.00% |
dominik brodowski | dominik brodowski | 1 | 4.76% | 1 | 50.00% |
| Total | 21 | 100.00% | 2 | 100.00% |
static void __exit
acpi_cpufreq_exit (void)
{
pr_debug("acpi_cpufreq_exit\n");
cpufreq_unregister_driver(&acpi_cpufreq_driver);
return;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 20 | 95.24% | 1 | 50.00% |
dominik brodowski | dominik brodowski | 1 | 4.76% | 1 | 50.00% |
| Total | 21 | 100.00% | 2 | 100.00% |
late_initcall(acpi_cpufreq_init);
module_exit(acpi_cpufreq_exit);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
venkatesh pallipadi | venkatesh pallipadi | 1346 | 94.26% | 2 | 10.53% |
viresh kumar | viresh kumar | 23 | 1.61% | 7 | 36.84% |
dominik brodowski | dominik brodowski | 19 | 1.33% | 1 | 5.26% |
pan xinhui | pan xinhui | 12 | 0.84% | 2 | 10.53% |
joe perches | joe perches | 11 | 0.77% | 2 | 10.53% |
julia lawall | julia lawall | 10 | 0.70% | 1 | 5.26% |
tejun heo | tejun heo | 3 | 0.21% | 1 | 5.26% |
denis v. lunev | denis v. lunev | 2 | 0.14% | 1 | 5.26% |
alex williamson | alex williamson | 1 | 0.07% | 1 | 5.26% |
burman yan | burman yan | 1 | 0.07% | 1 | 5.26% |
| Total | 1428 | 100.00% | 19 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.