# HG changeset patch
# User Jimi Xenidis <[EMAIL PROTECTED]>
# Node ID 584e21f08d0c092170a6879892b43efe860e2a9c
# Parent  8a5663668eed06e69bf09f67a5d37f6e1d4bbc80
[POWERPC] get the UDB delay correct

This patch makes sure that an absolute time is used to set the timer.

Signed-off-by: Jimi Xenidis <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/xen/setup.c    |    5 -----
 arch/powerpc/platforms/xen/setup.h    |   10 ++++++++++
 arch/powerpc/platforms/xen/udbg_xen.c |   10 +++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)

diff -r 8a5663668eed -r 584e21f08d0c arch/powerpc/platforms/xen/setup.c
--- a/arch/powerpc/platforms/xen/setup.c        Thu Aug 10 15:43:50 2006 -0400
+++ b/arch/powerpc/platforms/xen/setup.c        Thu Aug 10 16:36:39 2006 -0400
@@ -155,11 +155,6 @@ static u64 jiffies_to_ns(unsigned long j
 static u64 jiffies_to_ns(unsigned long j) 
 {
        return j * (1000000000UL / HZ);
-}
-
-static u64 tb_to_ns(u64 tb)
-{
-       return tb * (1000000000UL / tb_ticks_per_sec);
 }
 
 static void xen_idle(void)
diff -r 8a5663668eed -r 584e21f08d0c arch/powerpc/platforms/xen/setup.h
--- a/arch/powerpc/platforms/xen/setup.h        Thu Aug 10 15:43:50 2006 -0400
+++ b/arch/powerpc/platforms/xen/setup.h        Thu Aug 10 16:36:39 2006 -0400
@@ -1,6 +1,16 @@
+
+#include <asm/machdep.h>
 
 extern void evtchn_init_IRQ(void);
 extern void xen_init_IRQ(void);
 extern void xen_reboot_init(struct machdep_calls *);
 extern void xen_maple_init_IRQ(void);
 extern int xen_get_irq(struct pt_regs *regs);
+
+static inline u64 tb_to_ns(u64 tb)
+{
+       if (likely(tb_ticks_per_sec)) {
+               return tb * (1000000000UL / tb_ticks_per_sec);
+       }
+       return 0;
+}
diff -r 8a5663668eed -r 584e21f08d0c arch/powerpc/platforms/xen/udbg_xen.c
--- a/arch/powerpc/platforms/xen/udbg_xen.c     Thu Aug 10 15:43:50 2006 -0400
+++ b/arch/powerpc/platforms/xen/udbg_xen.c     Thu Aug 10 16:36:39 2006 -0400
@@ -4,6 +4,7 @@
 #include <xen/evtchn.h>
 #include <asm/udbg.h>
 #include <asm/hypervisor.h>
+#include "setup.h"
 
 static void udbg_putc_dom0_xen(char c)
 {
@@ -52,9 +53,12 @@ static int udbg_getc_dom0_xen(void)
        for (;;) {
                ch = udbg_getc_poll_dom0_xen();
                if (ch == -1) {
-                       /* nano seconds */
-                       HYPERVISOR_set_timer_op(100000000);
-                       HYPERVISOR_sched_op(SCHEDOP_block, NULL);
+                       u64 now_ns = tb_to_ns(get_tb());
+                       if (now_ns > 0) {
+                               u64 offset_ns = 100000000; /* 100ms */
+                               HYPERVISOR_set_timer_op(now_ns + offset_ns);
+                               HYPERVISOR_sched_op(SCHEDOP_block, NULL);
+                       }
                } else {
                        return ch;
                }

_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel

Reply via email to