svn commit: r298934 - head/sys/dev/xen/control

Roger Pau Monné royger at FreeBSD.org
Mon May 2 18:23:50 UTC 2016


Author: royger
Date: Mon May  2 18:23:48 2016
New Revision: 298934
URL: https://svnweb.freebsd.org/changeset/base/298934

Log:
  xen/control: improve suspend/resume
  
  Implement several small improvements to the suspend/resume Xen sequence:
  
   - Call the power_suspend_early event before stopping all processes.
   - Stop all processes. This was done implicitly previously by putting all
     the CPUs in a known IPI handler.
   - Warm up the timecounter.
   - Re-initialize the time of day register.
  
  Sponsored by: Citrix Systems R&D

Modified:
  head/sys/dev/xen/control/control.c

Modified: head/sys/dev/xen/control/control.c
==============================================================================
--- head/sys/dev/xen/control/control.c	Mon May  2 18:00:38 2016	(r298933)
+++ head/sys/dev/xen/control/control.c	Mon May  2 18:23:48 2016	(r298934)
@@ -122,6 +122,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sched.h>
 #include <sys/smp.h>
 #include <sys/eventhandler.h>
+#include <sys/timetc.h>
 
 #include <geom/geom.h>
 
@@ -197,6 +198,8 @@ xctrl_suspend()
 #endif
 	int suspend_cancelled;
 
+	EVENTHANDLER_INVOKE(power_suspend_early);
+	stop_all_proc();
 	EVENTHANDLER_INVOKE(power_suspend);
 
 	if (smp_started) {
@@ -222,7 +225,6 @@ xctrl_suspend()
 		printf("%s: device_suspend failed\n", __func__);
 		return;
 	}
-	mtx_unlock(&Giant);
 
 #ifdef SMP
 	CPU_ZERO(&cpu_suspend_map);	/* silence gcc */
@@ -273,16 +275,24 @@ xctrl_suspend()
 	 * FreeBSD really needs to add DEVICE_SUSPEND_CANCEL or
 	 * similar.
 	 */
-	mtx_lock(&Giant);
 	DEVICE_RESUME(root_bus);
 	mtx_unlock(&Giant);
 
+	/*
+	 * Warm up timecounter again and reset system clock.
+	 */
+	timecounter->tc_get_timecount(timecounter);
+	timecounter->tc_get_timecount(timecounter);
+	inittodr(time_second);
+
 	if (smp_started) {
 		thread_lock(curthread);
 		sched_unbind(curthread);
 		thread_unlock(curthread);
 	}
 
+	resume_all_proc();
+
 	EVENTHANDLER_INVOKE(power_resume);
 
 	if (bootverbose)


More information about the svn-src-head mailing list