Module Name: src Committed By: jym Date: Sun Feb 12 14:38:18 UTC 2012
Modified Files: src/sys/arch/x86/include: cpu.h src/sys/arch/xen/xen: clock.c xen_machdep.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.60 -r1.61 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/xen/xen/xen_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.46 src/sys/arch/x86/include/cpu.h:1.47 --- src/sys/arch/x86/include/cpu.h:1.46 Sat Jan 28 07:19:17 2012 +++ src/sys/arch/x86/include/cpu.h Sun Feb 12 14:38:18 2012 @@ -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 child_trampoline(void); 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); Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.60 src/sys/arch/xen/xen/clock.c:1.61 --- src/sys/arch/xen/xen/clock.c:1.60 Mon Jan 9 13:35:42 2012 +++ src/sys/arch/xen/xen/clock.c Sun Feb 12 14:38:18 2012 @@ -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 @@ static struct evcnt hardclock_called[MAX void xen_initclocks(void) { - int err, evtch; + int err; static bool tcdone = false; struct cpu_info *ci = curcpu(); @@ -438,8 +438,6 @@ xen_initclocks(void) 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 @@ xen_initclocks(void) 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 @@ xen_initclocks(void) err = HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, ci->ci_cpuid, NULL); - 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 @@ xen_initclocks(void) } void -xen_suspendclocks(void) +xen_suspendclocks(struct cpu_info *ci) { int evtch; @@ -498,13 +494,13 @@ xen_suspendclocks(void) 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 @@ xen_resumeclocks(void) 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); Index: src/sys/arch/xen/xen/xen_machdep.c diff -u src/sys/arch/xen/xen/xen_machdep.c:1.9 src/sys/arch/xen/xen/xen_machdep.c:1.10 --- src/sys/arch/xen/xen/xen_machdep.c:1.9 Sun Nov 20 19:41:27 2011 +++ src/sys/arch/xen/xen/xen_machdep.c Sun Feb 12 14:38:18 2012 @@ -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 @@ xen_prepare_suspend(void) 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_prepare_resume(void) xen_suspend_allow = false; - xen_resumeclocks(); + xen_resumeclocks(curcpu()); kpreempt_enable();