Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Xen clock management routines keep track of CPU (fo...



details:   https://anonhg.NetBSD.org/src/rev/64522e4eba64
branches:  trunk
changeset: 773670:64522e4eba64
user:      jym <jym%NetBSD.org@localhost>
date:      Sun Feb 12 14:38:18 2012 +0000

description:
Xen clock management routines keep track of CPU (following MP merge).
Reflect this change in the suspend/resume routines so they can cope with
domU CPU suspend, instead of setting their cpu_info pointer to NULL.

Avoid copy/pasting by using the resume routines during attachement.

ok releng@.

No regression observed, and allows domU to suspend successfully again.
Restore is a different beast as PD/PT flags are marked "invalid" by Xen-4
hypervisor, and blocks resuming. Looking into it.

diffstat:

 sys/arch/x86/include/cpu.h     |   6 +++---
 sys/arch/xen/xen/clock.c       |  24 ++++++++++--------------
 sys/arch/xen/xen/xen_machdep.c |   8 ++++----
 3 files changed, 17 insertions(+), 21 deletions(-)

diffs (154 lines):

diff -r 42897e1b9d0e -r 64522e4eba64 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Sun Feb 12 14:24:08 2012 +0000
+++ b/sys/arch/x86/include/cpu.h        Sun Feb 12 14:38:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.46 2012/01/28 07:19:17 cherry Exp $  */
+/*     $NetBSD: cpu.h,v 1.47 2012/02/12 14:38:18 jym Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -413,8 +413,8 @@
 void   startrtclock(void);
 void   xen_delay(unsigned int);
 void   xen_initclocks(void);
-void   xen_suspendclocks(void);
-void   xen_resumeclocks(void);
+void   xen_suspendclocks(struct cpu_info *);
+void   xen_resumeclocks(struct cpu_info *);
 #else
 /* clock.c */
 void   initrtclock(u_long);
diff -r 42897e1b9d0e -r 64522e4eba64 sys/arch/xen/xen/clock.c
--- a/sys/arch/xen/xen/clock.c  Sun Feb 12 14:24:08 2012 +0000
+++ b/sys/arch/xen/xen/clock.c  Sun Feb 12 14:38:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.60 2012/01/09 13:35:42 cherry Exp $        */
+/*     $NetBSD: clock.c,v 1.61 2012/02/12 14:38:18 jym Exp $   */
 
 /*
  *
@@ -29,7 +29,7 @@
 #include "opt_xen.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.60 2012/01/09 13:35:42 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.61 2012/02/12 14:38:18 jym Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -419,7 +419,7 @@
 void
 xen_initclocks(void)
 {
-       int err, evtch;
+       int err;
        static bool tcdone = false;
 
        struct cpu_info *ci = curcpu();
@@ -438,8 +438,6 @@
                callout_init(&xen_timepush_co, 0);
        }
 #endif
-       evtch = bind_virq_to_evtch(VIRQ_TIMER);
-       aprint_verbose("Xen clock: using event channel %d\n", evtch);
 
        if (!tcdone) { /* Do this only once */
                mutex_init(&tmutex, MUTEX_DEFAULT, IPL_CLOCK);
@@ -451,7 +449,9 @@
        if (!tcdone) { /* Do this only once */
                tc_init(&xen_timecounter);
        }
+
        /* The splhigh requirements start here. */
+       xen_resumeclocks(ci);
 
        /*
         * The periodic timer looks buggy, we stop receiving events
@@ -461,16 +461,12 @@
        err = HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
                                 ci->ci_cpuid,
                                 NULL);
+       KASSERT(err == 0);
 
-       KASSERT(err == 0);
        err = HYPERVISOR_set_timer_op(
            vcpu_system_time[ci->ci_cpuid] + NS_PER_TICK);
        KASSERT(err == 0);
 
-       event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
-           ci, IPL_CLOCK, "clock");
-       hypervisor_enable_event(evtch);
-
 #ifdef DOM0OPS
        if (!tcdone) { /* Do this only once */
 
@@ -490,7 +486,7 @@
 }
 
 void
-xen_suspendclocks(void)
+xen_suspendclocks(struct cpu_info *ci)
 {
        int evtch;
 
@@ -498,13 +494,13 @@
        KASSERT(evtch != -1);
 
        hypervisor_mask_event(evtch);
-       event_remove_handler(evtch, (int (*)(void *))xen_timer_handler, NULL);
+       event_remove_handler(evtch, (int (*)(void *))xen_timer_handler, ci);
 
        aprint_verbose("Xen clock: removed event channel %d\n", evtch);
 }
 
 void
-xen_resumeclocks(void)
+xen_resumeclocks(struct cpu_info *ci)
 {
        int evtch;
        
@@ -512,7 +508,7 @@
        KASSERT(evtch != -1);
 
        event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
-           NULL, IPL_CLOCK, "clock");
+           ci, IPL_CLOCK, "clock");
        hypervisor_enable_event(evtch);
 
        aprint_verbose("Xen clock: using event channel %d\n", evtch);
diff -r 42897e1b9d0e -r 64522e4eba64 sys/arch/xen/xen/xen_machdep.c
--- a/sys/arch/xen/xen/xen_machdep.c    Sun Feb 12 14:24:08 2012 +0000
+++ b/sys/arch/xen/xen/xen_machdep.c    Sun Feb 12 14:38:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xen_machdep.c,v 1.9 2011/11/20 19:41:27 jym Exp $      */
+/*     $NetBSD: xen_machdep.c,v 1.10 2012/02/12 14:38:18 jym Exp $     */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.9 2011/11/20 19:41:27 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.10 2012/02/12 14:38:18 jym Exp $");
 
 #include "opt_xen.h"
 
@@ -286,7 +286,7 @@
        kpreempt_disable();
 
        pmap_xen_suspend();
-       xen_suspendclocks();
+       xen_suspendclocks(curcpu());
 
        /*
         * save/restore code does not translate these MFNs to their
@@ -337,7 +337,7 @@
 
        xen_suspend_allow = false;
 
-       xen_resumeclocks();
+       xen_resumeclocks(curcpu());
 
        kpreempt_enable();
 



Home | Main Index | Thread Index | Old Index