Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 May 2016 18:23:48 +0000 (UTC)
From:      =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298934 - head/sys/dev/xen/control
Message-ID:  <201605021823.u42INmKr092879@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605021823.u42INmKr092879>