From 32ee8c3e470d86588b51dc42ed01e85c5fa0f180 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Tue, 28 Feb 2006 00:43:23 -0500 Subject: [CPUFREQ] Lots of whitespace & CodingStyle cleanup. Signed-off-by: Dave Jones --- drivers/cpufreq/cpufreq.c | 54 +++++++++++----------- drivers/cpufreq/cpufreq_ondemand.c | 86 +++++++++++++++++------------------ drivers/cpufreq/cpufreq_performance.c | 2 +- drivers/cpufreq/cpufreq_powersave.c | 2 +- drivers/cpufreq/cpufreq_stats.c | 6 +-- drivers/cpufreq/cpufreq_userspace.c | 12 ++--- drivers/cpufreq/freq_table.c | 12 ++--- 7 files changed, 86 insertions(+), 88 deletions(-) (limited to 'drivers') diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9582de1c9cad..cb7d6e0db759 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -5,7 +5,7 @@ * (C) 2002 - 2003 Dominik Brodowski * * Oct 2005 - Ashok Raj - * Added handling for CPU hotplug + * Added handling for CPU hotplug * * 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 @@ -44,8 +44,8 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) static void handle_update(void *data); /** - * Two notifier lists: the "policy" list is involved in the - * validation process for a new CPU frequency policy; the + * Two notifier lists: the "policy" list is involved in the + * validation process for a new CPU frequency policy; the * "transition" list for kernel code that needs to handle * changes to devices when the CPU clock speed changes. * The mutex locks both lists. @@ -151,7 +151,7 @@ void cpufreq_debug_printk(unsigned int type, const char *prefix, const char *fmt va_list args; unsigned int len; unsigned long flags; - + WARN_ON(!prefix); if (type & debug) { spin_lock_irqsave(&disable_ratelimit_lock, flags); @@ -198,7 +198,7 @@ static inline void cpufreq_debug_disable_ratelimit(void) { return; } * * This function alters the system "loops_per_jiffy" for the clock * speed change. Note that loops_per_jiffy cannot be updated on SMP - * systems as each CPU might be scaled differently. So, use the arch + * systems as each CPU might be scaled differently. So, use the arch * per-CPU loops_per_jiffy value wherever possible. */ #ifndef CONFIG_SMP @@ -233,7 +233,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) { * * This function calls the transition notifiers and the "adjust_jiffies" * function. It is called twice on all CPU frequency changes that have - * external effects. + * external effects. */ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) { @@ -251,7 +251,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) switch (state) { case CPUFREQ_PRECHANGE: - /* detect if the driver reported a value as "old frequency" + /* detect if the driver reported a value as "old frequency" * which is not equal to what the cpufreq core thinks is * "old frequency". */ @@ -335,11 +335,11 @@ extern struct sysdev_class cpu_sysdev_class; * "unsigned int". */ -#define show_one(file_name, object) \ -static ssize_t show_##file_name \ -(struct cpufreq_policy * policy, char *buf) \ -{ \ - return sprintf (buf, "%u\n", policy->object); \ +#define show_one(file_name, object) \ +static ssize_t show_##file_name \ +(struct cpufreq_policy * policy, char *buf) \ +{ \ + return sprintf (buf, "%u\n", policy->object); \ } show_one(cpuinfo_min_freq, cpuinfo.min_freq); @@ -404,8 +404,8 @@ static ssize_t show_scaling_governor (struct cpufreq_policy * policy, char *buf) /** * store_scaling_governor - store policy for the specified CPU */ -static ssize_t store_scaling_governor (struct cpufreq_policy * policy, - const char *buf, size_t count) +static ssize_t store_scaling_governor (struct cpufreq_policy * policy, + const char *buf, size_t count) { unsigned int ret = -EINVAL; char str_governor[16]; @@ -528,7 +528,7 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf) return ret; } -static ssize_t store(struct kobject * kobj, struct attribute * attr, +static ssize_t store(struct kobject * kobj, struct attribute * attr, const char * buf, size_t count) { struct cpufreq_policy * policy = to_policy(kobj); @@ -564,7 +564,7 @@ static struct kobj_type ktype_cpufreq = { /** * cpufreq_add_dev - add a CPU device * - * Adds the cpufreq interface for a CPU device. + * Adds the cpufreq interface for a CPU device. */ static int cpufreq_add_dev (struct sys_device * sys_dev) { @@ -724,7 +724,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) #ifdef CONFIG_SMP /* if this isn't the CPU which is the parent of the kobj, we - * only need to unlink, put and exit + * only need to unlink, put and exit */ if (unlikely(cpu != data->cpu)) { dprintk("removing link\n"); @@ -740,7 +740,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) if (!kobject_get(&data->kobj)) { spin_unlock_irqrestore(&cpufreq_driver_lock, flags); cpufreq_debug_enable_ratelimit(); - return -EFAULT; + return -EFAULT; } #ifdef CONFIG_SMP @@ -783,7 +783,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) kobject_put(&data->kobj); /* we need to make sure that the underlying kobj is actually - * not referenced anymore by anybody before we proceed with + * not referenced anymore by anybody before we proceed with * unloading. */ dprintk("waiting for dropping of refcount\n"); @@ -831,7 +831,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne } -/** +/** * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur * @cpu: CPU number * @@ -855,7 +855,7 @@ unsigned int cpufreq_quick_get(unsigned int cpu) EXPORT_SYMBOL(cpufreq_quick_get); -/** +/** * cpufreq_get - get the current CPU frequency (in kHz) * @cpu: CPU number * @@ -1072,7 +1072,7 @@ static struct sysdev_driver cpufreq_sysdev_driver = { * @nb: notifier function to register * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER * - * Add a driver to one of two lists: either a list of drivers that + * Add a driver to one of two lists: either a list of drivers that * are notified about clock rate changes (once before and once after * the transition), or a list of drivers that are notified about * changes in cpufreq policy. @@ -1225,7 +1225,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) return -EINVAL; mutex_lock(&cpufreq_governor_mutex); - + list_for_each_entry(t, &cpufreq_governor_list, governor_list) { if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) { mutex_unlock(&cpufreq_governor_mutex); @@ -1234,7 +1234,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) } list_add(&governor->governor_list, &cpufreq_governor_list); - mutex_unlock(&cpufreq_governor_mutex); + mutex_unlock(&cpufreq_governor_mutex); return 0; } EXPORT_SYMBOL_GPL(cpufreq_register_governor); @@ -1497,9 +1497,9 @@ static struct notifier_block cpufreq_cpu_notifier = * @driver_data: A struct cpufreq_driver containing the values# * submitted by the CPU Frequency driver. * - * Registers a CPU Frequency driver to this core code. This code + * Registers a CPU Frequency driver to this core code. This code * returns zero on success, -EBUSY when another driver got here first - * (and isn't unregistered in the meantime). + * (and isn't unregistered in the meantime). * */ int cpufreq_register_driver(struct cpufreq_driver *driver_data) @@ -1560,7 +1560,7 @@ EXPORT_SYMBOL_GPL(cpufreq_register_driver); /** * cpufreq_unregister_driver - unregister the current CPUFreq driver * - * Unregister the current CPUFreq driver. Only call this if you have + * Unregister the current CPUFreq driver. Only call this if you have * the right to do so, i.e. if you have succeeded in initialising before! * Returns zero if successful, and -EINVAL if the cpufreq_driver is * currently not initialised. diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 9ee9411f186f..69aa1db8336c 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -38,17 +38,17 @@ #define MIN_FREQUENCY_UP_THRESHOLD (11) #define MAX_FREQUENCY_UP_THRESHOLD (100) -/* - * The polling frequency of this governor depends on the capability of +/* + * The polling frequency of this governor depends on the capability of * the processor. Default polling frequency is 1000 times the transition - * latency of the processor. The governor will work on any processor with - * transition latency <= 10mS, using appropriate sampling + * latency of the processor. The governor will work on any processor with + * transition latency <= 10mS, using appropriate sampling * rate. * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL) * this governor will not work. * All times here are in uS. */ -static unsigned int def_sampling_rate; +static unsigned int def_sampling_rate; #define MIN_SAMPLING_RATE_RATIO (2) /* for correct statistics, we need at least 10 ticks between each measure */ #define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) @@ -62,28 +62,28 @@ static unsigned int def_sampling_rate; static void do_dbs_timer(void *data); struct cpu_dbs_info_s { - struct cpufreq_policy *cur_policy; - unsigned int prev_cpu_idle_up; - unsigned int prev_cpu_idle_down; - unsigned int enable; + struct cpufreq_policy *cur_policy; + unsigned int prev_cpu_idle_up; + unsigned int prev_cpu_idle_down; + unsigned int enable; }; static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); static unsigned int dbs_enable; /* number of CPUs using this policy */ -static DEFINE_MUTEX (dbs_mutex); +static DEFINE_MUTEX (dbs_mutex); static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); struct dbs_tuners { - unsigned int sampling_rate; - unsigned int sampling_down_factor; - unsigned int up_threshold; - unsigned int ignore_nice; + unsigned int sampling_rate; + unsigned int sampling_down_factor; + unsigned int up_threshold; + unsigned int ignore_nice; }; static struct dbs_tuners dbs_tuners_ins = { - .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, - .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, + .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, + .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, }; static inline unsigned int get_cpu_idle_time(unsigned int cpu) @@ -106,8 +106,8 @@ static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) return sprintf (buf, "%u\n", MIN_SAMPLING_RATE); } -#define define_one_ro(_name) \ -static struct freq_attr _name = \ +#define define_one_ro(_name) \ +static struct freq_attr _name = \ __ATTR(_name, 0444, show_##_name, NULL) define_one_ro(sampling_rate_max); @@ -125,7 +125,7 @@ show_one(sampling_down_factor, sampling_down_factor); show_one(up_threshold, up_threshold); show_one(ignore_nice_load, ignore_nice); -static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, +static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, const char *buf, size_t count) { unsigned int input; @@ -144,7 +144,7 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, return count; } -static ssize_t store_sampling_rate(struct cpufreq_policy *unused, +static ssize_t store_sampling_rate(struct cpufreq_policy *unused, const char *buf, size_t count) { unsigned int input; @@ -163,7 +163,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, return count; } -static ssize_t store_up_threshold(struct cpufreq_policy *unused, +static ssize_t store_up_threshold(struct cpufreq_policy *unused, const char *buf, size_t count) { unsigned int input; @@ -171,7 +171,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, ret = sscanf (buf, "%u", &input); mutex_lock(&dbs_mutex); - if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || + if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || input < MIN_FREQUENCY_UP_THRESHOLD) { mutex_unlock(&dbs_mutex); return -EINVAL; @@ -190,14 +190,14 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, int ret; unsigned int j; - + ret = sscanf (buf, "%u", &input); if ( ret != 1 ) return -EINVAL; if ( input > 1 ) input = 1; - + mutex_lock(&dbs_mutex); if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ mutex_unlock(&dbs_mutex); @@ -259,16 +259,16 @@ static void dbs_check_cpu(int cpu) return; policy = this_dbs_info->cur_policy; - /* + /* * Every sampling_rate, we check, if current idle time is less * than 20% (default), then we try to increase frequency * Every sampling_rate*sampling_down_factor, we look for a the lowest * frequency which can sustain the load while keeping idle time over * 30%. If such a frequency exist, we try to decrease to this frequency. * - * Any frequency increase takes it to the maximum frequency. - * Frequency reduction happens at minimum steps of - * 5% (default) of current frequency + * Any frequency increase takes it to the maximum frequency. + * Frequency reduction happens at minimum steps of + * 5% (default) of current frequency */ /* Check for frequency increase */ @@ -298,14 +298,14 @@ static void dbs_check_cpu(int cpu) struct cpu_dbs_info_s *j_dbs_info; j_dbs_info = &per_cpu(cpu_dbs_info, j); - j_dbs_info->prev_cpu_idle_down = + j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; } /* if we are already at full speed then break out early */ if (policy->cur == policy->max) return; - - __cpufreq_driver_target(policy, policy->max, + + __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); return; } @@ -347,7 +347,7 @@ static void dbs_check_cpu(int cpu) * policy. To be safe, we focus 10 points under the threshold. */ freq_next = ((total_ticks - idle_ticks) * 100) / total_ticks; - freq_next = (freq_next * policy->cur) / + freq_next = (freq_next * policy->cur) / (dbs_tuners_ins.up_threshold - 10); if (freq_next <= ((policy->cur * 95) / 100)) @@ -355,15 +355,15 @@ static void dbs_check_cpu(int cpu) } static void do_dbs_timer(void *data) -{ +{ int i; mutex_lock(&dbs_mutex); for_each_online_cpu(i) dbs_check_cpu(i); - schedule_delayed_work(&dbs_work, + schedule_delayed_work(&dbs_work, usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); mutex_unlock(&dbs_mutex); -} +} static inline void dbs_timer_init(void) { @@ -390,7 +390,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, switch (event) { case CPUFREQ_GOV_START: - if ((!cpu_online(cpu)) || + if ((!cpu_online(cpu)) || (!policy->cur)) return -EINVAL; @@ -399,13 +399,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, return -EINVAL; if (this_dbs_info->enable) /* Already enabled */ break; - + mutex_lock(&dbs_mutex); for_each_cpu_mask(j, policy->cpus) { struct cpu_dbs_info_s *j_dbs_info; j_dbs_info = &per_cpu(cpu_dbs_info, j); j_dbs_info->cur_policy = policy; - + j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; @@ -435,7 +435,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, dbs_timer_init(); } - + mutex_unlock(&dbs_mutex); break; @@ -448,9 +448,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, * Stop the timerschedule work, when this governor * is used for first time */ - if (dbs_enable == 0) + if (dbs_enable == 0) dbs_timer_exit(); - + mutex_unlock(&dbs_mutex); break; @@ -460,11 +460,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, if (policy->max < this_dbs_info->cur_policy->cur) __cpufreq_driver_target( this_dbs_info->cur_policy, - policy->max, CPUFREQ_RELATION_H); + policy->max, CPUFREQ_RELATION_H); else if (policy->min > this_dbs_info->cur_policy->cur) __cpufreq_driver_target( this_dbs_info->cur_policy, - policy->min, CPUFREQ_RELATION_L); + policy->min, CPUFREQ_RELATION_L); mutex_unlock(&dbs_mutex); break; } diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index 8d536b40deb8..de91e3371ef8 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c @@ -32,7 +32,7 @@ static int cpufreq_governor_performance(struct cpufreq_policy *policy, } return 0; } - + struct cpufreq_governor cpufreq_gov_performance = { .name = "performance", .governor = cpufreq_governor_performance, diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index c85edda7feb0..0a2596044e65 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c @@ -31,7 +31,7 @@ static int cpufreq_governor_powersave(struct cpufreq_policy *policy, } return 0; } - + static struct cpufreq_governor cpufreq_gov_powersave = { .name = "powersave", .governor = cpufreq_governor_powersave, diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 0bddb8e694d9..c25bdb7aec51 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -2,7 +2,7 @@ * drivers/cpufreq/cpufreq_stats.c * * Copyright (C) 2003-2004 Venkatesh Pallipadi . - * (C) 2004 Zou Nan hai . + * (C) 2004 Zou Nan hai . * * 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 @@ -90,7 +90,7 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf) return 0; cpufreq_stats_update(stat->cpu); for (i = 0; i < stat->state_num; i++) { - len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], + len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i])); } return len; @@ -171,7 +171,7 @@ cpufreq_stats_free_table (unsigned int cpu) { struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); - if (policy && policy->cpu == cpu) + if (policy && policy->cpu == cpu) sysfs_remove_group(&policy->kobj, &stats_attr_group); if (stat) { kfree(stat->time_in_state); diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 92a0be22a2a9..071ee4f1bbf2 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c @@ -41,7 +41,7 @@ static DEFINE_MUTEX (userspace_mutex); #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) /* keep track of frequency transitions */ -static int +static int userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, void *data) { @@ -58,7 +58,7 @@ static struct notifier_block userspace_cpufreq_notifier_block = { }; -/** +/** * cpufreq_set - set the CPU frequency * @freq: target frequency in kHz * @cpu: CPU for which the frequency is to be set @@ -103,8 +103,8 @@ static ssize_t show_speed (struct cpufreq_policy *policy, char *buf) return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]); } -static ssize_t -store_speed (struct cpufreq_policy *policy, const char *buf, size_t count) +static ssize_t +store_speed (struct cpufreq_policy *policy, const char *buf, size_t count) { unsigned int freq = 0; unsigned int ret; @@ -118,7 +118,7 @@ store_speed (struct cpufreq_policy *policy, const char *buf, size_t count) return count; } -static struct freq_attr freq_attr_scaling_setspeed = +static struct freq_attr freq_attr_scaling_setspeed = { .attr = { .name = "scaling_setspeed", .mode = 0644, .owner = THIS_MODULE }, .show = show_speed, @@ -135,7 +135,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, return -EINVAL; BUG_ON(!policy->cur); mutex_lock(&userspace_mutex); - cpu_is_managed[cpu] = 1; + cpu_is_managed[cpu] = 1; cpu_min_freq[cpu] = policy->min; cpu_max_freq[cpu] = policy->max; cpu_cur_freq[cpu] = policy->cur; diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index ba460bdea60f..a4818ce88919 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -59,9 +59,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, if (!cpu_online(policy->cpu)) return -EINVAL; - cpufreq_verify_within_limits(policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); + cpufreq_verify_within_limits(policy, + policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { unsigned int freq = table[i].frequency; @@ -76,9 +75,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, if (!count) policy->max = next_larger; - cpufreq_verify_within_limits(policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); + cpufreq_verify_within_limits(policy, + policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); dprintk("verification lead to (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); @@ -199,7 +197,7 @@ EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); * 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, +void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, unsigned int cpu) { dprintk("setting show_table for cpu %u to %p\n", cpu, table); -- cgit v1.2.3-55-g7522 From 8ff69732d484ea9ccbf242cc49b4fe9538e64c71 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Sun, 5 Mar 2006 03:37:23 -0500 Subject: [CPUFREQ] Fix handling for CPU hotplug This patch adds proper logic to cpufreq driver in order to handle CPU Hotplug. When CPUs go on/offline, the affected CPUs data, cpufreq_policy->cpus, is not updated properly. This causes sysfs directories and symlinks to be in an incorrect state after few CPU on/offlines. Signed-off-by: Jacob Shin Signed-off-by: Dave Jones --- drivers/cpufreq/cpufreq.c | 51 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index cb7d6e0db759..aed80e6aec6d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -6,6 +6,8 @@ * * Oct 2005 - Ashok Raj * Added handling for CPU hotplug + * Feb 2006 - Jacob Shin + * Fix handling for CPU hotplug -- affected CPUs * * 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 @@ -573,8 +575,12 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) struct cpufreq_policy new_policy; struct cpufreq_policy *policy; struct freq_attr **drv_attr; + struct sys_device *cpu_sys_dev; unsigned long flags; unsigned int j; +#ifdef CONFIG_SMP + struct cpufreq_policy *managed_policy; +#endif if (cpu_is_offline(cpu)) return 0; @@ -587,8 +593,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) * CPU because it is in the same boat. */ policy = cpufreq_cpu_get(cpu); if (unlikely(policy)) { - dprintk("CPU already managed, adding link\n"); - sysfs_create_link(&sys_dev->kobj, &policy->kobj, "cpufreq"); + cpufreq_cpu_put(policy); cpufreq_debug_enable_ratelimit(); return 0; } @@ -623,6 +628,32 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) goto err_out; } +#ifdef CONFIG_SMP + for_each_cpu_mask(j, policy->cpus) { + if (cpu == j) + continue; + + /* check for existing affected CPUs. They may not be aware + * of it due to CPU Hotplug. + */ + managed_policy = cpufreq_cpu_get(j); + if (unlikely(managed_policy)) { + spin_lock_irqsave(&cpufreq_driver_lock, flags); + managed_policy->cpus = policy->cpus; + cpufreq_cpu_data[cpu] = managed_policy; + spin_unlock_irqrestore(&cpufreq_driver_lock, flags); + + dprintk("CPU already managed, adding link\n"); + sysfs_create_link(&sys_dev->kobj, + &managed_policy->kobj, "cpufreq"); + + cpufreq_debug_enable_ratelimit(); + mutex_unlock(&policy->lock); + ret = 0; + goto err_out_driver_exit; /* call driver->exit() */ + } + } +#endif memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); /* prepare interface data */ @@ -650,6 +681,21 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) for_each_cpu_mask(j, policy->cpus) cpufreq_cpu_data[j] = policy; spin_unlock_irqrestore(&cpufreq_driver_lock, flags); + + /* symlink affected CPUs */ + for_each_cpu_mask(j, policy->cpus) { + if (j == cpu) + continue; + if (!cpu_online(j)) + continue; + + dprintk("CPU already managed, adding link\n"); + cpufreq_cpu_get(cpu); + cpu_sys_dev = get_cpu_sysdev(j); + sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, + "cpufreq"); + } + policy->governor = NULL; /* to assure that the starting sequence is * run in cpufreq_set_policy */ mutex_unlock(&policy->lock); @@ -728,6 +774,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) */ if (unlikely(cpu != data->cpu)) { dprintk("removing link\n"); + cpu_clear(cpu, data->cpus); spin_unlock_irqrestore(&cpufreq_driver_lock, flags); sysfs_remove_link(&sys_dev->kobj, "cpufreq"); cpufreq_cpu_put(data); -- cgit v1.2.3-55-g7522 From bb1a813d3c49e57814958d2d52b5bb299204032e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 11 Mar 2006 19:22:53 +0100 Subject: [PATCH] cpufreq: fix section mismatch warnings cpufreq are the only remaining bit to be solved for me to have a modpost clean build for sparc64 - so I took one more look at it. changelog entry: Fix section mismatch warnings in cpufreq: WARNING: drivers/cpufreq/cpufreq_stats.o - Section mismatch: reference to .init.text: from .data between 'cpufreq_stat_cpu_notifier' (at offset 0xa8) and 'notifier_policy_block' WARNING: drivers/cpufreq/cpufreq_stats.o - Section mismatch: reference to .init.text: from .exit.text after 'cleanup_module' (at offset 0x30) The culprint is the function: cpufreq_stat_cpu_callback It is marked __cpuinit which get's redefined to __init in case HOTPLUG_CPU is not enabled as per. init.h: #ifdef CONFIG_HOTPLUG_CPU #define __cpuinit #else #define __cpuinit __init #endif $> grep HOTPLUG .config CONFIG_HOTPLUG=y But cpufreq_stat_cpu_callback() is used in: __exit cpufreq_stats_exit() static struct notifier_block cpufreq_stat_cpu_notifier cpufreq_stat_cpu_notifier is again used in: __init cpufreq_stats_init() __exit cpufreq_stats_exit() So in both cases used from both __init and __exit context. Only solution seems to drop __cpuinit tag. Signed-off-by: Sam Ravnborg Signed-off-by: Dave Jones --- drivers/cpufreq/cpufreq_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c25bdb7aec51..9694b6ed3268 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -303,7 +303,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val, return 0; } -static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, +static int cpufreq_stat_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; -- cgit v1.2.3-55-g7522