aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/cbe_cpufreq.c
diff options
context:
space:
mode:
authorChristian Krafft <krafft@de.ibm.com>2007-07-20 15:39:19 -0400
committerArnd Bergmann <arnd@klappe.arndb.de>2007-07-20 15:41:35 -0400
commita964b9be3e475f30aee334654b4ff200bcdc0092 (patch)
treeb360230a33572e0e4209bd43bd1266d4f20cd40c /arch/powerpc/platforms/cell/cbe_cpufreq.c
parent813f90728e7d74e9b753e6ef6c6915cd2a047adb (diff)
[CELL] cbe_cpufreq: fix latency measurement
This patch fixes the debug code that calculates the transition time when changing the slow modes on a Cell BE cpu. Signed-off-by: Christian Krafft <krafft@de.ibm.com> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch/powerpc/platforms/cell/cbe_cpufreq.c')
-rw-r--r--arch/powerpc/platforms/cell/cbe_cpufreq.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/arch/powerpc/platforms/cell/cbe_cpufreq.c
index 3586f5290490..5820fb9a4521 100644
--- a/arch/powerpc/platforms/cell/cbe_cpufreq.c
+++ b/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -81,7 +81,7 @@ static int set_pmode_pmi(int cpu, unsigned int pmode)
81 int ret; 81 int ret;
82 pmi_message_t pmi_msg; 82 pmi_message_t pmi_msg;
83#ifdef DEBUG 83#ifdef DEBUG
84 u64 time; 84 long time;
85#endif 85#endif
86 86
87 pmi_msg.type = PMI_TYPE_FREQ_CHANGE; 87 pmi_msg.type = PMI_TYPE_FREQ_CHANGE;
@@ -89,7 +89,7 @@ static int set_pmode_pmi(int cpu, unsigned int pmode)
89 pmi_msg.data2 = pmode; 89 pmi_msg.data2 = pmode;
90 90
91#ifdef DEBUG 91#ifdef DEBUG
92 time = (u64) get_cycles(); 92 time = jiffies;
93#endif 93#endif
94 94
95 pmi_send_message(pmi_msg); 95 pmi_send_message(pmi_msg);
@@ -98,9 +98,9 @@ static int set_pmode_pmi(int cpu, unsigned int pmode)
98 pr_debug("PMI returned slow mode %d\n", ret); 98 pr_debug("PMI returned slow mode %d\n", ret);
99 99
100#ifdef DEBUG 100#ifdef DEBUG
101 time = (u64) get_cycles() - time; /* actual cycles (not cpu cycles!) */ 101 time = jiffies - time; /* actual cycles (not cpu cycles!) */
102 time = 1000000000 * time / CLOCK_TICK_RATE; /* time in ns (10^-9) */ 102 time = jiffies_to_msecs(time);
103 pr_debug("had to wait %lu ns for a transition\n", time); 103 pr_debug("had to wait %lu ms for a transition using PMI.\n", time);
104#endif 104#endif
105 return ret; 105 return ret;
106} 106}
@@ -123,15 +123,18 @@ static int set_pmode_reg(int cpu, unsigned int pmode)
123 struct cbe_mic_tm_regs __iomem *mic_tm_regs; 123 struct cbe_mic_tm_regs __iomem *mic_tm_regs;
124 u64 flags; 124 u64 flags;
125 u64 value; 125 u64 value;
126#ifdef DEBUG
127 long time;
128#endif
126 129
127 local_irq_save(flags); 130 local_irq_save(flags);
128 131
129 mic_tm_regs = cbe_get_cpu_mic_tm_regs(cpu); 132 mic_tm_regs = cbe_get_cpu_mic_tm_regs(cpu);
130 pmd_regs = cbe_get_cpu_pmd_regs(cpu); 133 pmd_regs = cbe_get_cpu_pmd_regs(cpu);
131 134
132 pr_debug("pm register is mapped at %p\n", &pmd_regs->pmcr); 135#ifdef DEBUG
133 pr_debug("mic register is mapped at %p\n", &mic_tm_regs->slow_fast_timer_0); 136 time = jiffies;
134 137#endif
135 out_be64(&mic_tm_regs->slow_fast_timer_0, MIC_Slow_Fast_Timer_table[pmode]); 138 out_be64(&mic_tm_regs->slow_fast_timer_0, MIC_Slow_Fast_Timer_table[pmode]);
136 out_be64(&mic_tm_regs->slow_fast_timer_1, MIC_Slow_Fast_Timer_table[pmode]); 139 out_be64(&mic_tm_regs->slow_fast_timer_1, MIC_Slow_Fast_Timer_table[pmode]);
137 140
@@ -146,6 +149,7 @@ static int set_pmode_reg(int cpu, unsigned int pmode)
146 149
147 out_be64(&pmd_regs->pmcr, value); 150 out_be64(&pmd_regs->pmcr, value);
148 151
152#ifdef DEBUG
149 /* wait until new pmode appears in status register */ 153 /* wait until new pmode appears in status register */
150 value = in_be64(&pmd_regs->pmsr) & 0x07; 154 value = in_be64(&pmd_regs->pmsr) & 0x07;
151 while(value != pmode) { 155 while(value != pmode) {
@@ -153,6 +157,11 @@ static int set_pmode_reg(int cpu, unsigned int pmode)
153 value = in_be64(&pmd_regs->pmsr) & 0x07; 157 value = in_be64(&pmd_regs->pmsr) & 0x07;
154 } 158 }
155 159
160 time = jiffies - time;
161 time = jiffies_to_msecs(time);
162 pr_debug("had to wait %lu ms for a transition using " \
163 "the pervasive unit.\n", time);
164#endif
156 local_irq_restore(flags); 165 local_irq_restore(flags);
157 166
158 return 0; 167 return 0;