diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes')
6 files changed, 341 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0001-OMAP2-cpufreq-free-up-table-on-exit.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0001-OMAP2-cpufreq-free-up-table-on-exit.patch new file mode 100644 index 00000000..9e9a8a0b --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0001-OMAP2-cpufreq-free-up-table-on-exit.patch | |||
@@ -0,0 +1,38 @@ | |||
1 | From 38dd5aadc86725f6018d23679e9daa60ca0a8319 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nishanth Menon <nm@ti.com> | ||
3 | Date: Thu, 12 May 2011 07:59:52 -0500 | ||
4 | Subject: [PATCH 1/6] OMAP2+: cpufreq: free up table on exit | ||
5 | |||
6 | freq_table allocated by opp_init_cpufreq_table in omap_cpu_init | ||
7 | needs to be freed in omap_cpu_exit. | ||
8 | |||
9 | Signed-off-by: Nishanth Menon <nm@ti.com> | ||
10 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
11 | --- | ||
12 | arch/arm/mach-omap2/omap2plus-cpufreq.c | 3 +++ | ||
13 | 1 files changed, 3 insertions(+), 0 deletions(-) | ||
14 | |||
15 | diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
16 | index d53ce23..e38ebb8 100644 | ||
17 | --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
18 | +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
19 | @@ -26,6 +26,7 @@ | ||
20 | #include <linux/clk.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/opp.h> | ||
23 | +#include <linux/slab.h> | ||
24 | #include <linux/cpu.h> | ||
25 | |||
26 | #include <asm/system.h> | ||
27 | @@ -216,6 +217,8 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
28 | static int omap_cpu_exit(struct cpufreq_policy *policy) | ||
29 | { | ||
30 | clk_exit_cpufreq_table(&freq_table); | ||
31 | + kfree(freq_table); | ||
32 | + freq_table = NULL; | ||
33 | clk_put(mpu_clk); | ||
34 | return 0; | ||
35 | } | ||
36 | -- | ||
37 | 1.6.6.1 | ||
38 | |||
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0002-OMAP2-cpufreq-handle-invalid-cpufreq-table.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0002-OMAP2-cpufreq-handle-invalid-cpufreq-table.patch new file mode 100644 index 00000000..087724d1 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0002-OMAP2-cpufreq-handle-invalid-cpufreq-table.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | From 5febdc0482e545c2a598f035c5e03931e0c3c808 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nishanth Menon <nm@ti.com> | ||
3 | Date: Thu, 12 May 2011 08:14:41 -0500 | ||
4 | Subject: [PATCH 2/6] OMAP2+: cpufreq: handle invalid cpufreq table | ||
5 | |||
6 | Handle the case when cpufreq_frequency_table_cpuinfo fails. freq_table | ||
7 | that we passed failed the internal test of cpufreq generic driver, | ||
8 | so we should'nt be using the freq_table as such. Instead, warn and | ||
9 | fallback to clock functions for validation and operation. | ||
10 | |||
11 | Signed-off-by: Nishanth Menon <nm@ti.com> | ||
12 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
13 | --- | ||
14 | arch/arm/mach-omap2/omap2plus-cpufreq.c | 12 ++++++++++-- | ||
15 | 1 files changed, 10 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
18 | index e38ebb8..6e3666a 100644 | ||
19 | --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
20 | +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
21 | @@ -182,10 +182,18 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
22 | |||
23 | if (freq_table) { | ||
24 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
25 | - if (!result) | ||
26 | + if (!result) { | ||
27 | cpufreq_frequency_table_get_attr(freq_table, | ||
28 | policy->cpu); | ||
29 | - } else { | ||
30 | + } else { | ||
31 | + WARN(true, "%s: fallback to clk_round(freq_table=%d)\n", | ||
32 | + __func__, result); | ||
33 | + kfree(freq_table); | ||
34 | + freq_table = NULL; | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + if (!freq_table) { | ||
39 | policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000; | ||
40 | policy->cpuinfo.max_freq = clk_round_rate(mpu_clk, | ||
41 | VERY_HI_RATE) / 1000; | ||
42 | -- | ||
43 | 1.6.6.1 | ||
44 | |||
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0003-OMAP2-cpufreq-minor-comment-cleanup.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0003-OMAP2-cpufreq-minor-comment-cleanup.patch new file mode 100644 index 00000000..4f4cdb14 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0003-OMAP2-cpufreq-minor-comment-cleanup.patch | |||
@@ -0,0 +1,33 @@ | |||
1 | From aef7e862873e6125159a18d22a2e37b1fbab2153 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nishanth Menon <nm@ti.com> | ||
3 | Date: Thu, 12 May 2011 16:27:45 -0700 | ||
4 | Subject: [PATCH 3/6] OMAP2+: cpufreq: minor comment cleanup | ||
5 | |||
6 | this should probably get squashed in.. | ||
7 | |||
8 | Signed-off-by: Nishanth Menon <nm@ti.com> | ||
9 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
10 | --- | ||
11 | arch/arm/mach-omap2/omap2plus-cpufreq.c | 6 ++++-- | ||
12 | 1 files changed, 4 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
15 | index 6e3666a..45f1e9e 100644 | ||
16 | --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
17 | +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
18 | @@ -84,8 +84,10 @@ static int omap_target(struct cpufreq_policy *policy, | ||
19 | if (is_smp() && (num_online_cpus() < NR_CPUS)) | ||
20 | return ret; | ||
21 | |||
22 | - /* Ensure desired rate is within allowed range. Some govenors | ||
23 | - * (ondemand) will just pass target_freq=0 to get the minimum. */ | ||
24 | + /* | ||
25 | + * Ensure desired rate is within allowed range. Some govenors | ||
26 | + * (ondemand) will just pass target_freq=0 to get the minimum. | ||
27 | + */ | ||
28 | if (target_freq < policy->min) | ||
29 | target_freq = policy->min; | ||
30 | if (target_freq > policy->max) | ||
31 | -- | ||
32 | 1.6.6.1 | ||
33 | |||
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0004-OMAP2-cpufreq-use-clk_init_cpufreq_table-if-OPPs-not.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0004-OMAP2-cpufreq-use-clk_init_cpufreq_table-if-OPPs-not.patch new file mode 100644 index 00000000..dd23c082 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0004-OMAP2-cpufreq-use-clk_init_cpufreq_table-if-OPPs-not.patch | |||
@@ -0,0 +1,48 @@ | |||
1 | From f231980dbd0f05229f2020e59b7242872576416f Mon Sep 17 00:00:00 2001 | ||
2 | From: Nishanth Menon <nm@ti.com> | ||
3 | Date: Fri, 13 May 2011 05:34:35 -0700 | ||
4 | Subject: [PATCH 4/6] OMAP2: cpufreq: use clk_init_cpufreq_table if OPPs not available | ||
5 | |||
6 | OMAP2 does not use OPP tables at the moment for DVFS. Currently, | ||
7 | we depend on opp table initialization to give us the freq_table, | ||
8 | which makes sense for OMAP3+. for OMAP2, we should be using | ||
9 | clk_init_cpufreq_table - so if the opp based frequency table | ||
10 | initilization fails, fall back to clk_init_cpufreq_table to give | ||
11 | us the table. | ||
12 | |||
13 | Signed-off-by: Nishanth Menon <nm@ti.com> | ||
14 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
15 | --- | ||
16 | arch/arm/mach-omap2/omap2plus-cpufreq.c | 9 ++++++++- | ||
17 | 1 files changed, 8 insertions(+), 1 deletions(-) | ||
18 | |||
19 | diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
20 | index 45f1e9e..854f4b3 100644 | ||
21 | --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
22 | +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
23 | @@ -180,7 +180,13 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
24 | pr_warning("%s: unable to get the mpu device\n", __func__); | ||
25 | return -EINVAL; | ||
26 | } | ||
27 | - opp_init_cpufreq_table(mpu_dev, &freq_table); | ||
28 | + | ||
29 | + /* | ||
30 | + * if we dont get cpufreq table using opp, use traditional omap2 lookup | ||
31 | + * as a fallback | ||
32 | + */ | ||
33 | + if (opp_init_cpufreq_table(mpu_dev, &freq_table)) | ||
34 | + clk_init_cpufreq_table(&freq_table); | ||
35 | |||
36 | if (freq_table) { | ||
37 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
38 | @@ -188,6 +194,7 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
39 | cpufreq_frequency_table_get_attr(freq_table, | ||
40 | policy->cpu); | ||
41 | } else { | ||
42 | + clk_exit_cpufreq_table(&freq_table); | ||
43 | WARN(true, "%s: fallback to clk_round(freq_table=%d)\n", | ||
44 | __func__, result); | ||
45 | kfree(freq_table); | ||
46 | -- | ||
47 | 1.6.6.1 | ||
48 | |||
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0005-OMAP2-cpufreq-use-cpufreq_frequency_table_target.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0005-OMAP2-cpufreq-use-cpufreq_frequency_table_target.patch new file mode 100644 index 00000000..504d1916 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0005-OMAP2-cpufreq-use-cpufreq_frequency_table_target.patch | |||
@@ -0,0 +1,78 @@ | |||
1 | From 272d76bcb22b9509ccc1b59d3a62e3930d902d17 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nishanth Menon <nm@ti.com> | ||
3 | Date: Fri, 13 May 2011 05:43:49 -0700 | ||
4 | Subject: [PATCH 5/6] OMAP2+: cpufreq: use cpufreq_frequency_table_target | ||
5 | |||
6 | Use cpufreq_frequency_table_target for finding the proper target | ||
7 | instead of seeing if the frequency requested is divisible alone. | ||
8 | if we have a frequency table, we should restrict ourselves to | ||
9 | selecting the "approved" frequencies alone and only in the case | ||
10 | where the frequency table is not available should we attempt at | ||
11 | closest roundable clock frequency. | ||
12 | |||
13 | Signed-off-by: Nishanth Menon <nm@ti.com> | ||
14 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
15 | --- | ||
16 | arch/arm/mach-omap2/omap2plus-cpufreq.c | 38 ++++++++++++++++++++++-------- | ||
17 | 1 files changed, 28 insertions(+), 10 deletions(-) | ||
18 | |||
19 | diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
20 | index 854f4b3..d0b4f97 100644 | ||
21 | --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
22 | +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
23 | @@ -77,24 +77,42 @@ static int omap_target(struct cpufreq_policy *policy, | ||
24 | unsigned int target_freq, | ||
25 | unsigned int relation) | ||
26 | { | ||
27 | - int i, ret = 0; | ||
28 | + unsigned int i; | ||
29 | + int ret = 0; | ||
30 | struct cpufreq_freqs freqs; | ||
31 | |||
32 | /* Changes not allowed until all CPUs are online */ | ||
33 | if (is_smp() && (num_online_cpus() < NR_CPUS)) | ||
34 | return ret; | ||
35 | |||
36 | - /* | ||
37 | - * Ensure desired rate is within allowed range. Some govenors | ||
38 | - * (ondemand) will just pass target_freq=0 to get the minimum. | ||
39 | - */ | ||
40 | - if (target_freq < policy->min) | ||
41 | - target_freq = policy->min; | ||
42 | - if (target_freq > policy->max) | ||
43 | - target_freq = policy->max; | ||
44 | + if (freq_table) { | ||
45 | + ret = cpufreq_frequency_table_target(policy, freq_table, | ||
46 | + target_freq, relation, &i); | ||
47 | + if (ret) { | ||
48 | + pr_debug("%s: cpu%d: no freq match for %d(ret=%d)\n", | ||
49 | + __func__, policy->cpu, target_freq, ret); | ||
50 | + return ret; | ||
51 | + } | ||
52 | + freqs.new = freq_table[i].frequency; | ||
53 | + } else { | ||
54 | + /* | ||
55 | + * Ensure desired rate is within allowed range. Some govenors | ||
56 | + * (ondemand) will just pass target_freq=0 to get the minimum. | ||
57 | + */ | ||
58 | + if (target_freq < policy->min) | ||
59 | + target_freq = policy->min; | ||
60 | + if (target_freq > policy->max) | ||
61 | + target_freq = policy->max; | ||
62 | + | ||
63 | + freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; | ||
64 | + } | ||
65 | + if (!freqs.new) { | ||
66 | + pr_err("%s: cpu%d: no match for freq %d\n", __func__, | ||
67 | + policy->cpu, target_freq); | ||
68 | + return -EINVAL; | ||
69 | + } | ||
70 | |||
71 | freqs.old = omap_getspeed(policy->cpu); | ||
72 | - freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; | ||
73 | freqs.cpu = policy->cpu; | ||
74 | |||
75 | if (freqs.old == freqs.new) | ||
76 | -- | ||
77 | 1.6.6.1 | ||
78 | |||
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0006-OMAP2-cpufreq-fix-freq_table-leak.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0006-OMAP2-cpufreq-fix-freq_table-leak.patch new file mode 100644 index 00000000..0cb4c91f --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-fixes/0006-OMAP2-cpufreq-fix-freq_table-leak.patch | |||
@@ -0,0 +1,100 @@ | |||
1 | From 42a384af80e07534913d9002ec8d9caf5d4d305c Mon Sep 17 00:00:00 2001 | ||
2 | From: Nishanth Menon <nm@ti.com> | ||
3 | Date: Wed, 18 May 2011 01:48:23 -0500 | ||
4 | Subject: [PATCH 6/6] OMAP2+: cpufreq: fix freq_table leak | ||
5 | |||
6 | Since we have two cpus the cpuinit call for cpu1 causes | ||
7 | freq_table of cpu0 to be overwritten. instead, we maintain | ||
8 | a counter to keep track of cpus who use the cpufreq table | ||
9 | allocate it once(one freq table for all CPUs) and free them | ||
10 | once the last user is done with it. | ||
11 | |||
12 | Signed-off-by: Nishanth Menon <nm@ti.com> | ||
13 | Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> | ||
14 | --- | ||
15 | arch/arm/mach-omap2/omap2plus-cpufreq.c | 33 ++++++++++++++++++++++++------ | ||
16 | 1 files changed, 26 insertions(+), 7 deletions(-) | ||
17 | |||
18 | diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
19 | index d0b4f97..fc3d0fb 100644 | ||
20 | --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
21 | +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c | ||
22 | @@ -42,6 +42,9 @@ | ||
23 | #define VERY_HI_RATE 900000000 | ||
24 | |||
25 | static struct cpufreq_frequency_table *freq_table; | ||
26 | +static int freq_table_users; | ||
27 | +static DEFINE_MUTEX(freq_table_lock); | ||
28 | + | ||
29 | static struct clk *mpu_clk; | ||
30 | |||
31 | static int omap_verify_speed(struct cpufreq_policy *policy) | ||
32 | @@ -172,6 +175,18 @@ skip_lpj: | ||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | +static void freq_table_free(void) | ||
37 | +{ | ||
38 | + if (!freq_table_users) | ||
39 | + return; | ||
40 | + freq_table_users--; | ||
41 | + if (freq_table_users) | ||
42 | + return; | ||
43 | + clk_exit_cpufreq_table(&freq_table); | ||
44 | + kfree(freq_table); | ||
45 | + freq_table = NULL; | ||
46 | +} | ||
47 | + | ||
48 | static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
49 | { | ||
50 | int result = 0; | ||
51 | @@ -199,14 +214,18 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
52 | return -EINVAL; | ||
53 | } | ||
54 | |||
55 | + mutex_lock(&freq_table_lock); | ||
56 | /* | ||
57 | * if we dont get cpufreq table using opp, use traditional omap2 lookup | ||
58 | * as a fallback | ||
59 | */ | ||
60 | - if (opp_init_cpufreq_table(mpu_dev, &freq_table)) | ||
61 | - clk_init_cpufreq_table(&freq_table); | ||
62 | + if (!freq_table) { | ||
63 | + if (opp_init_cpufreq_table(mpu_dev, &freq_table)) | ||
64 | + clk_init_cpufreq_table(&freq_table); | ||
65 | + } | ||
66 | |||
67 | if (freq_table) { | ||
68 | + freq_table_users++; | ||
69 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
70 | if (!result) { | ||
71 | cpufreq_frequency_table_get_attr(freq_table, | ||
72 | @@ -215,10 +234,10 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
73 | clk_exit_cpufreq_table(&freq_table); | ||
74 | WARN(true, "%s: fallback to clk_round(freq_table=%d)\n", | ||
75 | __func__, result); | ||
76 | - kfree(freq_table); | ||
77 | - freq_table = NULL; | ||
78 | + freq_table_free(); | ||
79 | } | ||
80 | } | ||
81 | + mutex_unlock(&freq_table_lock); | ||
82 | |||
83 | if (!freq_table) { | ||
84 | policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000; | ||
85 | @@ -251,9 +270,9 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | ||
86 | |||
87 | static int omap_cpu_exit(struct cpufreq_policy *policy) | ||
88 | { | ||
89 | - clk_exit_cpufreq_table(&freq_table); | ||
90 | - kfree(freq_table); | ||
91 | - freq_table = NULL; | ||
92 | + mutex_lock(&freq_table_lock); | ||
93 | + freq_table_free(); | ||
94 | + mutex_unlock(&freq_table_lock); | ||
95 | clk_put(mpu_clk); | ||
96 | return 0; | ||
97 | } | ||
98 | -- | ||
99 | 1.6.6.1 | ||
100 | |||