mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-04 14:10:46 +00:00
cpufreq: add 'freq_table' in struct cpufreq_policy
freq table is not per CPU but per policy, so it makes more sense to keep it within struct cpufreq_policy instead of a per-cpu variable. This patch does it. Over that, there is no need to set policy->freq_table to NULL in ->exit(), as policy structure is going to be freed soon. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
e837f9b58b
commit
e0b3165ba5
@ -855,7 +855,6 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
|
||||
pr_debug("acpi_cpufreq_cpu_exit\n");
|
||||
|
||||
if (data) {
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
per_cpu(acfreq_data, policy->cpu) = NULL;
|
||||
acpi_processor_unregister_performance(data->acpi_data,
|
||||
policy->cpu);
|
||||
|
@ -478,7 +478,6 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
put_cluster_clk_and_freq_table(cpu_dev);
|
||||
dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu);
|
||||
|
||||
|
@ -191,6 +191,12 @@ unsigned int cpufreq_generic_get(unsigned int cpu)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpufreq_generic_get);
|
||||
|
||||
/* Only for cpufreq core internal use */
|
||||
struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
|
||||
{
|
||||
return per_cpu(cpufreq_cpu_data, cpu);
|
||||
}
|
||||
|
||||
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
|
||||
{
|
||||
struct cpufreq_policy *policy = NULL;
|
||||
@ -1031,7 +1037,6 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
|
||||
|
||||
up_write(&policy->rwsem);
|
||||
|
||||
cpufreq_frequency_table_update_policy_cpu(policy);
|
||||
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
|
||||
CPUFREQ_UPDATE_POLICY_CPU, policy);
|
||||
}
|
||||
|
@ -382,7 +382,6 @@ static int eps_cpu_exit(struct cpufreq_policy *policy)
|
||||
unsigned int cpu = policy->cpu;
|
||||
|
||||
/* Bye */
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
kfree(eps_cpu[cpu]);
|
||||
eps_cpu[cpu] = NULL;
|
||||
return 0;
|
||||
|
@ -91,8 +91,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
|
||||
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
|
||||
|
||||
/*
|
||||
* Generic routine to verify policy & frequency table, requires driver to call
|
||||
* cpufreq_frequency_table_get_attr() prior to it.
|
||||
* Generic routine to verify policy & frequency table, requires driver to set
|
||||
* policy->freq_table prior to it.
|
||||
*/
|
||||
int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy)
|
||||
{
|
||||
@ -203,8 +203,6 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index);
|
||||
|
||||
static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table);
|
||||
|
||||
/**
|
||||
* show_available_freqs - show available frequencies for the specified CPU
|
||||
*/
|
||||
@ -212,15 +210,12 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,
|
||||
bool show_boost)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
unsigned int cpu = policy->cpu;
|
||||
ssize_t count = 0;
|
||||
struct cpufreq_frequency_table *table;
|
||||
struct cpufreq_frequency_table *table = policy->freq_table;
|
||||
|
||||
if (!per_cpu(cpufreq_show_table, cpu))
|
||||
if (!table)
|
||||
return -ENODEV;
|
||||
|
||||
table = per_cpu(cpufreq_show_table, cpu);
|
||||
|
||||
for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
|
||||
if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
|
||||
continue;
|
||||
@ -283,49 +278,24 @@ struct freq_attr *cpufreq_generic_attr[] = {
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cpufreq_generic_attr);
|
||||
|
||||
/*
|
||||
* if you use these, you must assure that the frequency table is valid
|
||||
* all the time between get_attr and put_attr!
|
||||
*/
|
||||
void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
|
||||
unsigned int cpu)
|
||||
{
|
||||
pr_debug("setting show_table for cpu %u to %p\n", cpu, table);
|
||||
per_cpu(cpufreq_show_table, cpu) = table;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
|
||||
|
||||
void cpufreq_frequency_table_put_attr(unsigned int cpu)
|
||||
{
|
||||
pr_debug("clearing show_table for cpu %u\n", cpu);
|
||||
per_cpu(cpufreq_show_table, cpu) = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
|
||||
|
||||
int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
|
||||
struct cpufreq_frequency_table *table)
|
||||
{
|
||||
int ret = cpufreq_frequency_table_cpuinfo(policy, table);
|
||||
|
||||
if (!ret)
|
||||
cpufreq_frequency_table_get_attr(table, policy->cpu);
|
||||
policy->freq_table = table;
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show);
|
||||
|
||||
void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy)
|
||||
{
|
||||
pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n",
|
||||
policy->cpu, policy->last_cpu);
|
||||
per_cpu(cpufreq_show_table, policy->cpu) = per_cpu(cpufreq_show_table,
|
||||
policy->last_cpu);
|
||||
per_cpu(cpufreq_show_table, policy->last_cpu) = NULL;
|
||||
}
|
||||
struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
|
||||
|
||||
struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
|
||||
{
|
||||
return per_cpu(cpufreq_show_table, cpu);
|
||||
struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
|
||||
return policy ? policy->freq_table : NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
|
||||
|
||||
|
@ -332,7 +332,6 @@ acpi_cpufreq_cpu_exit (
|
||||
pr_debug("acpi_cpufreq_cpu_exit\n");
|
||||
|
||||
if (data) {
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
acpi_io_data[policy->cpu] = NULL;
|
||||
acpi_processor_unregister_performance(&data->acpi_data,
|
||||
policy->cpu);
|
||||
|
@ -104,7 +104,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
|
||||
|
||||
static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
clk_put(policy->clk);
|
||||
return 0;
|
||||
}
|
||||
|
@ -143,7 +143,6 @@ fail:
|
||||
|
||||
static int omap_cpu_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
freq_table_free();
|
||||
clk_put(policy->clk);
|
||||
return 0;
|
||||
|
@ -234,7 +234,6 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
|
||||
if (sdcpwr_mapbase)
|
||||
iounmap(sdcpwr_mapbase);
|
||||
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,6 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
|
||||
if (i == max_multiplier)
|
||||
powernow_k6_target(policy, i);
|
||||
}
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -664,8 +664,6 @@ static int powernow_cpu_init(struct cpufreq_policy *policy)
|
||||
|
||||
static int powernow_cpu_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
|
||||
#ifdef CONFIG_X86_POWERNOW_K7_ACPI
|
||||
if (acpi_processor_perf) {
|
||||
acpi_processor_unregister_performance(acpi_processor_perf, 0);
|
||||
|
@ -1164,8 +1164,6 @@ static int powernowk8_cpu_exit(struct cpufreq_policy *pol)
|
||||
|
||||
powernow_k8_cpu_exit_acpi(data);
|
||||
|
||||
cpufreq_frequency_table_put_attr(pol->cpu);
|
||||
|
||||
kfree(data->powernow_table);
|
||||
kfree(data);
|
||||
for_each_cpu(cpu, pol->cpus)
|
||||
|
@ -228,7 +228,6 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)
|
||||
struct cpu_data *data = per_cpu(cpu_data, policy->cpu);
|
||||
unsigned int cpu;
|
||||
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
of_node_put(data->parent);
|
||||
kfree(data->table);
|
||||
kfree(data);
|
||||
|
@ -143,7 +143,6 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy)
|
||||
unsigned int cpu = policy->cpu;
|
||||
struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu);
|
||||
|
||||
cpufreq_frequency_table_put_attr(cpu);
|
||||
clk_put(cpuclk);
|
||||
|
||||
return 0;
|
||||
|
@ -301,10 +301,8 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
|
||||
|
||||
static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
if (cpufreq_us2e_driver) {
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
if (cpufreq_us2e_driver)
|
||||
us2e_freq_target(policy, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -156,10 +156,8 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
|
||||
|
||||
static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
if (cpufreq_us3_driver) {
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
if (cpufreq_us3_driver)
|
||||
us3_freq_target(policy, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -406,8 +406,6 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)
|
||||
if (!per_cpu(centrino_model, cpu))
|
||||
return -ENODEV;
|
||||
|
||||
cpufreq_frequency_table_put_attr(cpu);
|
||||
|
||||
per_cpu(centrino_model, cpu) = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -136,7 +136,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
|
||||
|
||||
static int tegra_cpu_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
clk_disable_unprepare(cpu_clk);
|
||||
clk_disable_unprepare(emc_clk);
|
||||
return 0;
|
||||
|
@ -85,6 +85,7 @@ struct cpufreq_policy {
|
||||
* called, but you're in IRQ context */
|
||||
|
||||
struct cpufreq_real_policy user_policy;
|
||||
struct cpufreq_frequency_table *freq_table;
|
||||
|
||||
struct list_head policy_list;
|
||||
struct kobject kobj;
|
||||
@ -474,7 +475,6 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
|
||||
int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
|
||||
unsigned int freq);
|
||||
|
||||
void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy);
|
||||
ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
|
||||
|
||||
#ifdef CONFIG_CPU_FREQ
|
||||
@ -501,9 +501,6 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
|
||||
/* the following are really really optional */
|
||||
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
|
||||
extern struct freq_attr *cpufreq_generic_attr[];
|
||||
void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
|
||||
unsigned int cpu);
|
||||
void cpufreq_frequency_table_put_attr(unsigned int cpu);
|
||||
int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
|
||||
struct cpufreq_frequency_table *table);
|
||||
|
||||
@ -513,7 +510,6 @@ int cpufreq_generic_init(struct cpufreq_policy *policy,
|
||||
unsigned int transition_latency);
|
||||
static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
|
||||
{
|
||||
cpufreq_frequency_table_put_attr(policy->cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user