]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-3.0/pm-wip/cpufreq/0019-OMAP2-CPUfreq-update-lpj-with-reference-value-to-avo.patch
c2c9a2263c187abb42ce4028d3718701f5bded84
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-3.0 / pm-wip / cpufreq / 0019-OMAP2-CPUfreq-update-lpj-with-reference-value-to-avo.patch
1 From 9b352c30c2ddb0dec7f6597148f22ae5bbc27877 Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@arm.linux.org.uk>
3 Date: Mon, 11 Jul 2011 23:10:04 +0530
4 Subject: [PATCH 19/19] OMAP2+: CPUfreq: update lpj with reference value to avoid progressive error.
6 Adjust _both_ the per-cpu loops_per_jiffy and global lpj. Calibrate them
7 with with reference to the initial values to avoid a progressively
8 bigger and bigger error in the value over time.
10 While at this, re-use the notifiers for UP/SMP since on
11 UP machine or UP_ON_SMP policy->cpus mask would contain only
12 the boot CPU.
14 Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
15 [santosh.shilimkar@ti.com: re-based against omap cpufreq
16 upstream branch and fixed notifiers]
17 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
18 Cc: Kevin Hilman <khilman@ti.com>
19 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
20 ---
21  arch/arm/mach-omap2/omap2plus-cpufreq.c |   50 ++++++++++++++++--------------
22  1 files changed, 27 insertions(+), 23 deletions(-)
24 diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c
25 index 1f3b2e1..de82e87 100644
26 --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
27 +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
28 @@ -38,6 +38,16 @@
29  
30  #include <mach/hardware.h>
31  
32 +#ifdef CONFIG_SMP
33 +struct lpj_info {
34 +       unsigned long   ref;
35 +       unsigned int    freq;
36 +};
37 +
38 +static DEFINE_PER_CPU(struct lpj_info, lpj_ref);
39 +static struct lpj_info global_lpj_ref;
40 +#endif
41 +
42  static struct cpufreq_frequency_table *freq_table;
43  static atomic_t freq_table_users = ATOMIC_INIT(0);
44  static struct clk *mpu_clk;
45 @@ -96,37 +106,18 @@ static int omap_target(struct cpufreq_policy *policy,
46         if (freqs.old == freqs.new && policy->cur == freqs.new)
47                 return ret;
48  
49 -       if (!is_smp()) {
50 -               cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
51 -               goto set_freq;
52 -       }
53 -
54         /* notifiers */
55         for_each_cpu(i, policy->cpus) {
56                 freqs.cpu = i;
57                 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
58         }
59  
60 -set_freq:
61  #ifdef CONFIG_CPU_FREQ_DEBUG
62         pr_info("cpufreq-omap: transition: %u --> %u\n", freqs.old, freqs.new);
63  #endif
64  
65         ret = clk_set_rate(mpu_clk, freqs.new * 1000);
66 -
67 -       /*
68 -        * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies
69 -        * won't get updated when UP machine cpufreq build with
70 -        * CONFIG_SMP enabled. Below code is added only to manage that
71 -        * scenario
72 -        */
73         freqs.new = omap_getspeed(policy->cpu);
74 -       if (!is_smp()) {
75 -               loops_per_jiffy =
76 -                        cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new);
77 -               cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
78 -               goto skip_lpj;
79 -       }
80  
81  #ifdef CONFIG_SMP
82         /*
83 @@ -134,10 +125,24 @@ set_freq:
84          * cpufreq driver. So, update the per-CPU loops_per_jiffy value
85          * on frequency transition. We need to update all dependent CPUs.
86          */
87 -       for_each_cpu(i, policy->cpus)
88 +       for_each_cpu(i, policy->cpus) {
89 +               struct lpj_info *lpj = &per_cpu(lpj_ref, i);
90 +               if (!lpj->freq) {
91 +                       lpj->ref = per_cpu(cpu_data, i).loops_per_jiffy;
92 +                       lpj->freq = freqs.old;
93 +               }
94 +
95                 per_cpu(cpu_data, i).loops_per_jiffy =
96 -                       cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
97 -                                       freqs.old, freqs.new);
98 +                       cpufreq_scale(lpj->ref, lpj->freq, freqs.new);
99 +       }
101 +       /* And don't forget to adjust the global one */
102 +       if (!global_lpj_ref.freq) {
103 +               global_lpj_ref.ref = loops_per_jiffy;
104 +               global_lpj_ref.freq = freqs.old;
105 +       }
106 +       loops_per_jiffy = cpufreq_scale(global_lpj_ref.ref, global_lpj_ref.freq,
107 +                                       freqs.new);
108  #endif
109  
110         /* notifiers */
111 @@ -146,7 +151,6 @@ set_freq:
112                 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
113         }
114  
115 -skip_lpj:
116         return ret;
117  }
118  
119 -- 
120 1.6.6.1