direct-io.hg

view xen/arch/powerpc/time.c @ 11522:1fae74cd3963

[POWERPC][XEN] Fix infinite loop caused by hdec storm

This was the cause of the periodic hang on secondary processors that has
been holding back the submission of the SMP patch.

Signed-off-by: Amos Waterland <apw@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Thu Sep 14 22:06:15 2006 -0400 (2006-09-14)
parents 94aa7e921ccd
children 4da585fb62f9
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright (C) IBM Corp. 2005
17 *
18 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
19 */
21 #include <xen/config.h>
22 #include <xen/time.h>
23 #include <xen/smp.h>
24 #include <xen/lib.h>
25 #include <xen/sched.h>
26 #include <asm/processor.h>
27 #include <asm/current.h>
28 #include <asm/misc.h>
30 #define Dprintk(x...) printk(x)
32 static int cpu_has_hdec = 1;
33 ulong ticks_per_usec;
34 unsigned long cpu_khz;
35 unsigned int timebase_freq;
37 s_time_t get_s_time(void)
38 {
39 return tb_to_ns(get_timebase());
40 }
42 static void set_preempt(unsigned ns)
43 {
44 ulong ticks = ns_to_tb(ns);
45 if (cpu_has_hdec) {
46 mthdec(ticks);
47 } else {
48 mtdec(ticks);
49 }
50 }
52 /*
53 * set preemption timer Timeout value is in ticks from start of boot
54 * returns 1 on success
55 * returns 0 if the timeout value is too small or in the past.
56 */
57 extern int reprogram_timer(s_time_t timeout);
58 int reprogram_timer(s_time_t timeout)
59 {
60 s_time_t expire;
62 if (timeout == 0) {
63 expire = INT_MAX;
64 } else {
65 s_time_t now;
67 now = get_s_time();
68 expire = timeout - now; /* value from now */
70 if (expire <= 0) {
71 Dprintk("%s[%02d] Timeout in the past "
72 "0x%08X%08X > 0x%08X%08X\n", __func__,
73 smp_processor_id(), (u32)(now >> 32),
74 (u32)now, (u32)(timeout >> 32), (u32)timeout);
75 return 0;
76 }
77 }
78 set_preempt(expire);
79 return 1;
80 }
82 void send_timer_event(struct vcpu *v)
83 {
84 v->arch.dec = 1;
85 vcpu_unblock(v);
86 }
88 /* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
89 void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
90 {
91 unimplemented();
92 }
94 void update_vcpu_system_time(struct vcpu *v)
95 {
96 unimplemented();
97 }