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
					
				
			
		
					 19 changed files with 17 additions and 67 deletions
				
			
		|  | @ -855,7 +855,6 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||||||
| 	pr_debug("acpi_cpufreq_cpu_exit\n"); | 	pr_debug("acpi_cpufreq_cpu_exit\n"); | ||||||
| 
 | 
 | ||||||
| 	if (data) { | 	if (data) { | ||||||
| 		cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 		per_cpu(acfreq_data, policy->cpu) = NULL; | 		per_cpu(acfreq_data, policy->cpu) = NULL; | ||||||
| 		acpi_processor_unregister_performance(data->acpi_data, | 		acpi_processor_unregister_performance(data->acpi_data, | ||||||
| 						      policy->cpu); | 						      policy->cpu); | ||||||
|  |  | ||||||
|  | @ -478,7 +478,6 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy) | ||||||
| 		return -ENODEV; | 		return -ENODEV; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	put_cluster_clk_and_freq_table(cpu_dev); | 	put_cluster_clk_and_freq_table(cpu_dev); | ||||||
| 	dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); | 	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); | 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 *cpufreq_cpu_get(unsigned int cpu) | ||||||
| { | { | ||||||
| 	struct cpufreq_policy *policy = NULL; | 	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); | 	up_write(&policy->rwsem); | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_update_policy_cpu(policy); |  | ||||||
| 	blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 	blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | ||||||
| 			CPUFREQ_UPDATE_POLICY_CPU, policy); | 			CPUFREQ_UPDATE_POLICY_CPU, policy); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -382,7 +382,6 @@ static int eps_cpu_exit(struct cpufreq_policy *policy) | ||||||
| 	unsigned int cpu = policy->cpu; | 	unsigned int cpu = policy->cpu; | ||||||
| 
 | 
 | ||||||
| 	/* Bye */ | 	/* Bye */ | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	kfree(eps_cpu[cpu]); | 	kfree(eps_cpu[cpu]); | ||||||
| 	eps_cpu[cpu] = NULL; | 	eps_cpu[cpu] = NULL; | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -91,8 +91,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | ||||||
| EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Generic routine to verify policy & frequency table, requires driver to call |  * Generic routine to verify policy & frequency table, requires driver to set | ||||||
|  * cpufreq_frequency_table_get_attr() prior to it. |  * policy->freq_table prior to it. | ||||||
|  */ |  */ | ||||||
| int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) | 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); | 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 |  * 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) | 				    bool show_boost) | ||||||
| { | { | ||||||
| 	unsigned int i = 0; | 	unsigned int i = 0; | ||||||
| 	unsigned int cpu = policy->cpu; |  | ||||||
| 	ssize_t count = 0; | 	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; | 		return -ENODEV; | ||||||
| 
 | 
 | ||||||
| 	table = per_cpu(cpufreq_show_table, cpu); |  | ||||||
| 
 |  | ||||||
| 	for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 	for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | ||||||
| 		if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | 		if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | ||||||
| 			continue; | 			continue; | ||||||
|  | @ -283,49 +278,24 @@ struct freq_attr *cpufreq_generic_attr[] = { | ||||||
| }; | }; | ||||||
| EXPORT_SYMBOL_GPL(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, | int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, | ||||||
| 				      struct cpufreq_frequency_table *table) | 				      struct cpufreq_frequency_table *table) | ||||||
| { | { | ||||||
| 	int ret = cpufreq_frequency_table_cpuinfo(policy, table); | 	int ret = cpufreq_frequency_table_cpuinfo(policy, table); | ||||||
| 
 | 
 | ||||||
| 	if (!ret) | 	if (!ret) | ||||||
| 		cpufreq_frequency_table_get_attr(table, policy->cpu); | 		policy->freq_table = table; | ||||||
| 
 | 
 | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
| EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); | EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); | ||||||
| 
 | 
 | ||||||
| void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy) | struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu); | ||||||
| { |  | ||||||
| 	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_frequency_table *cpufreq_frequency_get_table(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); | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -332,7 +332,6 @@ acpi_cpufreq_cpu_exit ( | ||||||
| 	pr_debug("acpi_cpufreq_cpu_exit\n"); | 	pr_debug("acpi_cpufreq_cpu_exit\n"); | ||||||
| 
 | 
 | ||||||
| 	if (data) { | 	if (data) { | ||||||
| 		cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 		acpi_io_data[policy->cpu] = NULL; | 		acpi_io_data[policy->cpu] = NULL; | ||||||
| 		acpi_processor_unregister_performance(&data->acpi_data, | 		acpi_processor_unregister_performance(&data->acpi_data, | ||||||
| 		                                      policy->cpu); | 		                                      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) | static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) | ||||||
| { | { | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	clk_put(policy->clk); | 	clk_put(policy->clk); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -143,7 +143,6 @@ fail: | ||||||
| 
 | 
 | ||||||
| static int omap_cpu_exit(struct cpufreq_policy *policy) | static int omap_cpu_exit(struct cpufreq_policy *policy) | ||||||
| { | { | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	freq_table_free(); | 	freq_table_free(); | ||||||
| 	clk_put(policy->clk); | 	clk_put(policy->clk); | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -234,7 +234,6 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||||||
| 	if (sdcpwr_mapbase) | 	if (sdcpwr_mapbase) | ||||||
| 		iounmap(sdcpwr_mapbase); | 		iounmap(sdcpwr_mapbase); | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -231,7 +231,6 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy) | ||||||
| 		if (i == max_multiplier) | 		if (i == max_multiplier) | ||||||
| 			powernow_k6_target(policy, i); | 			powernow_k6_target(policy, i); | ||||||
| 	} | 	} | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -664,8 +664,6 @@ static int powernow_cpu_init(struct cpufreq_policy *policy) | ||||||
| 
 | 
 | ||||||
| static int powernow_cpu_exit(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 | #ifdef CONFIG_X86_POWERNOW_K7_ACPI | ||||||
| 	if (acpi_processor_perf) { | 	if (acpi_processor_perf) { | ||||||
| 		acpi_processor_unregister_performance(acpi_processor_perf, 0); | 		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); | 	powernow_k8_cpu_exit_acpi(data); | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_put_attr(pol->cpu); |  | ||||||
| 
 |  | ||||||
| 	kfree(data->powernow_table); | 	kfree(data->powernow_table); | ||||||
| 	kfree(data); | 	kfree(data); | ||||||
| 	for_each_cpu(cpu, pol->cpus) | 	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); | 	struct cpu_data *data = per_cpu(cpu_data, policy->cpu); | ||||||
| 	unsigned int cpu; | 	unsigned int cpu; | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	of_node_put(data->parent); | 	of_node_put(data->parent); | ||||||
| 	kfree(data->table); | 	kfree(data->table); | ||||||
| 	kfree(data); | 	kfree(data); | ||||||
|  |  | ||||||
|  | @ -143,7 +143,6 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||||||
| 	unsigned int cpu = policy->cpu; | 	unsigned int cpu = policy->cpu; | ||||||
| 	struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu); | 	struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu); | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_put_attr(cpu); |  | ||||||
| 	clk_put(cpuclk); | 	clk_put(cpuclk); | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	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) | static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) | ||||||
| { | { | ||||||
| 	if (cpufreq_us2e_driver) { | 	if (cpufreq_us2e_driver) | ||||||
| 		cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 		us2e_freq_target(policy, 0); | 		us2e_freq_target(policy, 0); | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	return 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) | static int us3_freq_cpu_exit(struct cpufreq_policy *policy) | ||||||
| { | { | ||||||
| 	if (cpufreq_us3_driver) { | 	if (cpufreq_us3_driver) | ||||||
| 		cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 		us3_freq_target(policy, 0); | 		us3_freq_target(policy, 0); | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -406,8 +406,6 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy) | ||||||
| 	if (!per_cpu(centrino_model, cpu)) | 	if (!per_cpu(centrino_model, cpu)) | ||||||
| 		return -ENODEV; | 		return -ENODEV; | ||||||
| 
 | 
 | ||||||
| 	cpufreq_frequency_table_put_attr(cpu); |  | ||||||
| 
 |  | ||||||
| 	per_cpu(centrino_model, cpu) = NULL; | 	per_cpu(centrino_model, cpu) = NULL; | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -136,7 +136,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) | ||||||
| 
 | 
 | ||||||
| static int tegra_cpu_exit(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(cpu_clk); | ||||||
| 	clk_disable_unprepare(emc_clk); | 	clk_disable_unprepare(emc_clk); | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -85,6 +85,7 @@ struct cpufreq_policy { | ||||||
| 					 * called, but you're in IRQ context */ | 					 * called, but you're in IRQ context */ | ||||||
| 
 | 
 | ||||||
| 	struct cpufreq_real_policy	user_policy; | 	struct cpufreq_real_policy	user_policy; | ||||||
|  | 	struct cpufreq_frequency_table	*freq_table; | ||||||
| 
 | 
 | ||||||
| 	struct list_head        policy_list; | 	struct list_head        policy_list; | ||||||
| 	struct kobject		kobj; | 	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, | int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, | ||||||
| 		unsigned int freq); | 		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); | ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf); | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_CPU_FREQ | #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 */ | /* the following are really really optional */ | ||||||
| extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; | extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; | ||||||
| extern struct freq_attr *cpufreq_generic_attr[]; | 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, | int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, | ||||||
| 				      struct cpufreq_frequency_table *table); | 				      struct cpufreq_frequency_table *table); | ||||||
| 
 | 
 | ||||||
|  | @ -513,7 +510,6 @@ int cpufreq_generic_init(struct cpufreq_policy *policy, | ||||||
| 		unsigned int transition_latency); | 		unsigned int transition_latency); | ||||||
| static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) | static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) | ||||||
| { | { | ||||||
| 	cpufreq_frequency_table_put_attr(policy->cpu); |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Viresh Kumar
				Viresh Kumar