svn commit: r315676 - in stable/10/sys: dev/xen/blkfront dev/xen/control dev/xen/netfront xen xen/xenbus

Roger Pau Monné royger at FreeBSD.org
Tue Mar 21 09:39:01 UTC 2017


Author: royger
Date: Tue Mar 21 09:38:59 2017
New Revision: 315676
URL: https://svnweb.freebsd.org/changeset/base/315676

Log:
  MFC r314840:
  
  xen: add support for canceled suspend
  
  Submitted by:	Liuyingdong <liuyingdong at huawei.com>
  Reviewed by:	royger

Modified:
  stable/10/sys/dev/xen/blkfront/blkfront.c
  stable/10/sys/dev/xen/control/control.c
  stable/10/sys/dev/xen/netfront/netfront.c
  stable/10/sys/xen/xen-os.h
  stable/10/sys/xen/xenbus/xenbusb.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- stable/10/sys/dev/xen/blkfront/blkfront.c	Tue Mar 21 09:27:24 2017	(r315675)
+++ stable/10/sys/dev/xen/blkfront/blkfront.c	Tue Mar 21 09:38:59 2017	(r315676)
@@ -1533,6 +1533,11 @@ xbd_resume(device_t dev)
 {
 	struct xbd_softc *sc = device_get_softc(dev);
 
+	if (xen_suspend_cancelled) {
+		sc->xbd_state = XBD_STATE_CONNECTED;
+		return (0);
+	}
+
 	DPRINTK("xbd_resume: %s\n", xenbus_get_node(dev));
 
 	xbd_free(sc);

Modified: stable/10/sys/dev/xen/control/control.c
==============================================================================
--- stable/10/sys/dev/xen/control/control.c	Tue Mar 21 09:27:24 2017	(r315675)
+++ stable/10/sys/dev/xen/control/control.c	Tue Mar 21 09:38:59 2017	(r315676)
@@ -151,6 +151,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
 
+bool xen_suspend_cancelled;
 /*--------------------------- Forward Declarations --------------------------*/
 /** Function signature for shutdown event handlers. */
 typedef	void (xctrl_shutdown_handler_t)(void);
@@ -341,7 +342,6 @@ xctrl_suspend()
 #ifdef SMP
 	cpuset_t cpu_suspend_map;
 #endif
-	int suspend_cancelled;
 
 	EVENTHANDLER_INVOKE(power_suspend_early);
 	xs_lock();
@@ -396,16 +396,20 @@ xctrl_suspend()
 	intr_suspend();
 	xen_hvm_suspend();
 
-	suspend_cancelled = HYPERVISOR_suspend(0);
+	xen_suspend_cancelled = !!HYPERVISOR_suspend(0);
 
-	xen_hvm_resume(suspend_cancelled != 0);
-	intr_resume(suspend_cancelled != 0);
+	if (!xen_suspend_cancelled) {
+		xen_hvm_resume(false);
+	}
+	intr_resume(xen_suspend_cancelled != 0);
 	enable_intr();
 
 	/*
 	 * Reset grant table info.
 	 */
-	gnttab_resume();
+	if (!xen_suspend_cancelled) {
+		gnttab_resume();
+	}
 
 #ifdef SMP
 	/* Send an IPI_BITMAP in case there are pending bitmap IPIs. */

Modified: stable/10/sys/dev/xen/netfront/netfront.c
==============================================================================
--- stable/10/sys/dev/xen/netfront/netfront.c	Tue Mar 21 09:27:24 2017	(r315675)
+++ stable/10/sys/dev/xen/netfront/netfront.c	Tue Mar 21 09:38:59 2017	(r315676)
@@ -509,6 +509,15 @@ netfront_resume(device_t dev)
 {
 	struct netfront_info *info = device_get_softc(dev);
 
+	if (xen_suspend_cancelled) {
+		XN_RX_LOCK(info);
+		XN_TX_LOCK(info);
+		netfront_carrier_on(info);
+		XN_TX_UNLOCK(info);
+		XN_RX_UNLOCK(info);
+		return (0);
+	}
+
 	info->xn_resume = true;
 	netif_disconnect_backend(info);
 	return (0);

Modified: stable/10/sys/xen/xen-os.h
==============================================================================
--- stable/10/sys/xen/xen-os.h	Tue Mar 21 09:27:24 2017	(r315675)
+++ stable/10/sys/xen/xen-os.h	Tue Mar 21 09:38:59 2017	(r315676)
@@ -57,6 +57,8 @@ extern int xen_disable_pv_disks;
 extern int xen_disable_pv_nics;
 #endif
 
+extern bool xen_suspend_cancelled;
+
 enum xen_domain_type {
 	XEN_NATIVE,             /* running on bare hardware    */
 	XEN_PV_DOMAIN,          /* running in a PV domain      */

Modified: stable/10/sys/xen/xenbus/xenbusb.c
==============================================================================
--- stable/10/sys/xen/xenbus/xenbusb.c	Tue Mar 21 09:27:24 2017	(r315675)
+++ stable/10/sys/xen/xenbus/xenbusb.c	Tue Mar 21 09:38:59 2017	(r315676)
@@ -791,6 +791,11 @@ xenbusb_resume(device_t dev)
 			if (device_get_state(kids[i]) == DS_NOTPRESENT)
 				continue;
 
+			if (xen_suspend_cancelled) {
+				DEVICE_RESUME(kids[i]);
+				continue;
+			}
+
 			ivars = device_get_ivars(kids[i]);
 
 			xs_unregister_watch(&ivars->xd_otherend_watch);


More information about the svn-src-stable-10 mailing list