diff options
author | Fabio Baltieri <fabio.baltieri@linaro.org> | 2012-11-26 13:10:12 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-27 08:11:19 -0500 |
commit | 3e33ee9e0804748f1b7a01af9ba0e8e1e10f772f (patch) | |
tree | c92467d4430a9aa941cbc638a3756e04a3ec2112 /drivers/cpufreq/cpufreq_ondemand.c | |
parent | 420993221175a45db5af012c53fd2fef4d9533dc (diff) |
cpufreq: ondemand: update sampling rate only on right CPUs
Fix cpufreq_gov_ondemand to skip CPU where another governor is used.
The bug present itself as NULL pointer access on the mutex_lock() call,
an can be reproduced on an SMP machine by setting the default governor
to anything other than ondemand, setting a single CPU's governor to
ondemand, then changing the sample rate by writing on:
> /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
Backtrace:
Nov 26 17:36:54 balto kernel: [ 839.585241] BUG: unable to handle kernel NULL pointer dereference at (null)
Nov 26 17:36:54 balto kernel: [ 839.585311] IP: [<ffffffff8174e082>] __mutex_lock_slowpath+0xb2/0x170
[snip]
Nov 26 17:36:54 balto kernel: [ 839.587005] Call Trace:
Nov 26 17:36:54 balto kernel: [ 839.587030] [<ffffffff8174da82>] mutex_lock+0x22/0x40
Nov 26 17:36:54 balto kernel: [ 839.587067] [<ffffffff81610b8f>] store_sampling_rate+0xbf/0x150
Nov 26 17:36:54 balto kernel: [ 839.587110] [<ffffffff81031e9c>] ? __do_page_fault+0x1cc/0x4c0
Nov 26 17:36:54 balto kernel: [ 839.587153] [<ffffffff813309bf>] kobj_attr_store+0xf/0x20
Nov 26 17:36:54 balto kernel: [ 839.587192] [<ffffffff811bb62d>] sysfs_write_file+0xcd/0x140
Nov 26 17:36:54 balto kernel: [ 839.587234] [<ffffffff8114c12c>] vfs_write+0xac/0x180
Nov 26 17:36:54 balto kernel: [ 839.587271] [<ffffffff8114c472>] sys_write+0x52/0xa0
Nov 26 17:36:54 balto kernel: [ 839.587306] [<ffffffff810321ce>] ? do_page_fault+0xe/0x10
Nov 26 17:36:54 balto kernel: [ 839.587345] [<ffffffff81751202>] system_call_fastpath+0x16/0x1b
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index cca3e9fee9a7..7731f7c7e79a 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -40,6 +40,10 @@ | |||
40 | static struct dbs_data od_dbs_data; | 40 | static struct dbs_data od_dbs_data; |
41 | static DEFINE_PER_CPU(struct od_cpu_dbs_info_s, od_cpu_dbs_info); | 41 | static DEFINE_PER_CPU(struct od_cpu_dbs_info_s, od_cpu_dbs_info); |
42 | 42 | ||
43 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | ||
44 | static struct cpufreq_governor cpufreq_gov_ondemand; | ||
45 | #endif | ||
46 | |||
43 | static struct od_dbs_tuners od_tuners = { | 47 | static struct od_dbs_tuners od_tuners = { |
44 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, | 48 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, |
45 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, | 49 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, |
@@ -279,6 +283,10 @@ static void update_sampling_rate(unsigned int new_rate) | |||
279 | policy = cpufreq_cpu_get(cpu); | 283 | policy = cpufreq_cpu_get(cpu); |
280 | if (!policy) | 284 | if (!policy) |
281 | continue; | 285 | continue; |
286 | if (policy->governor != &cpufreq_gov_ondemand) { | ||
287 | cpufreq_cpu_put(policy); | ||
288 | continue; | ||
289 | } | ||
282 | dbs_info = &per_cpu(od_cpu_dbs_info, policy->cpu); | 290 | dbs_info = &per_cpu(od_cpu_dbs_info, policy->cpu); |
283 | cpufreq_cpu_put(policy); | 291 | cpufreq_cpu_put(policy); |
284 | 292 | ||