diff options
author | Paul Mackerras <paulus@samba.org> | 2007-10-31 07:25:35 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-11-07 22:15:31 -0500 |
commit | 43875cc0a54d936132010e58545269e183741fae (patch) | |
tree | 65409e7b9161fcaf8a88b67ebe91ffdb2ad97809 /include/asm-powerpc | |
parent | 465ccab9eb8209a2a402710b24a9bff127b25b94 (diff) |
[POWERPC] Fix off-by-one error in setting decrementer on Book E/4xx (v2)
The decrementer in Book E and 4xx processors interrupts on the
transition from 1 to 0, rather than on the 0 to -1 transition as on
64-bit server and 32-bit "classic" (6xx/7xx/7xxx) processors. At the
moment we subtract 1 from the count of how many decrementer ticks are
required before the next interrupt before putting it into the
decrementer, which is correct for server/classic processors, but could
possibly cause the interrupt to happen too early on Book E and 4xx if
the timebase/decrementer frequency is low.
This fixes the problem by making set_dec subtract 1 from the count for
server and classic processors, instead of having the callers subtract
1. Since set_dec already had a bunch of ifdefs to handle different
processor types, there is no net increase in ugliness. :)
Note that calling set_dec(0) may not generate an interrupt on some
processors. To make sure that decrementer_set_next_event always calls
set_dec with an interval of at least 1 tick, we set min_delta_ns of
the decrementer_clockevent to correspond to 2 ticks (2 rather than 1
to compensate for truncations in the conversions between ticks and
ns).
This also removes a redundant call to set the decrementer to
0x7fffffff - it was already set to that earlier in timer_interrupt.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc')
-rw-r--r-- | include/asm-powerpc/time.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h index f05895522f7f..780f82642756 100644 --- a/include/asm-powerpc/time.h +++ b/include/asm-powerpc/time.h | |||
@@ -176,25 +176,31 @@ static inline unsigned int get_dec(void) | |||
176 | #endif | 176 | #endif |
177 | } | 177 | } |
178 | 178 | ||
179 | /* | ||
180 | * Note: Book E and 4xx processors differ from other PowerPC processors | ||
181 | * in when the decrementer generates its interrupt: on the 1 to 0 | ||
182 | * transition for Book E/4xx, but on the 0 to -1 transition for others. | ||
183 | */ | ||
179 | static inline void set_dec(int val) | 184 | static inline void set_dec(int val) |
180 | { | 185 | { |
181 | #if defined(CONFIG_40x) | 186 | #if defined(CONFIG_40x) |
182 | mtspr(SPRN_PIT, val); | 187 | mtspr(SPRN_PIT, val); |
183 | #elif defined(CONFIG_8xx_CPU6) | 188 | #elif defined(CONFIG_8xx_CPU6) |
184 | set_dec_cpu6(val); | 189 | set_dec_cpu6(val - 1); |
185 | #else | 190 | #else |
191 | #ifndef CONFIG_BOOKE | ||
192 | --val; | ||
193 | #endif | ||
186 | #ifdef CONFIG_PPC_ISERIES | 194 | #ifdef CONFIG_PPC_ISERIES |
187 | int cur_dec; | ||
188 | |||
189 | if (firmware_has_feature(FW_FEATURE_ISERIES) && | 195 | if (firmware_has_feature(FW_FEATURE_ISERIES) && |
190 | get_lppaca()->shared_proc) { | 196 | get_lppaca()->shared_proc) { |
191 | get_lppaca()->virtual_decr = val; | 197 | get_lppaca()->virtual_decr = val; |
192 | cur_dec = get_dec(); | 198 | if (get_dec() > val) |
193 | if (cur_dec > val) | ||
194 | HvCall_setVirtualDecr(); | 199 | HvCall_setVirtualDecr(); |
195 | } else | 200 | return; |
201 | } | ||
196 | #endif | 202 | #endif |
197 | mtspr(SPRN_DEC, val); | 203 | mtspr(SPRN_DEC, val); |
198 | #endif /* not 40x or 8xx_CPU6 */ | 204 | #endif /* not 40x or 8xx_CPU6 */ |
199 | } | 205 | } |
200 | 206 | ||