summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroyger <royger@FreeBSD.org>2017-03-21 08:38:12 +0000
committerroyger <royger@FreeBSD.org>2017-03-21 08:38:12 +0000
commit3260b7788f203a888062cbf2e7bac1510673b39a (patch)
treed840fa5cfed6c5a4bc076fd993c7af636e22a0b9
parentf8e8a739d6001bb648c57a4b14b022c636344897 (diff)
downloadFreeBSD-src-3260b7788f203a888062cbf2e7bac1510673b39a.zip
FreeBSD-src-3260b7788f203a888062cbf2e7bac1510673b39a.tar.gz
MFC r314840:
xen: add support for canceled suspend Submitted by: Liuyingdong <liuyingdong@huawei.com> Reviewed by: royger
-rw-r--r--sys/dev/xen/blkfront/blkfront.c5
-rw-r--r--sys/dev/xen/control/control.c14
-rw-r--r--sys/dev/xen/netfront/netfront.c14
-rw-r--r--sys/xen/xen-os.h2
-rw-r--r--sys/xen/xenbus/xenbusb.c5
5 files changed, 35 insertions, 5 deletions
diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c
index 9eca220..d76fc01 100644
--- a/sys/dev/xen/blkfront/blkfront.c
+++ b/sys/dev/xen/blkfront/blkfront.c
@@ -1537,6 +1537,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);
diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c
index 58fefcc..d5aa97e 100644
--- a/sys/dev/xen/control/control.c
+++ b/sys/dev/xen/control/control.c
@@ -148,6 +148,7 @@ __FBSDID("$FreeBSD$");
#include <xen/xenbus/xenbusvar.h>
+bool xen_suspend_cancelled;
/*--------------------------- Forward Declarations --------------------------*/
/** Function signature for shutdown event handlers. */
typedef void (xctrl_shutdown_handler_t)(void);
@@ -196,7 +197,6 @@ xctrl_suspend()
#ifdef SMP
cpuset_t cpu_suspend_map;
#endif
- int suspend_cancelled;
EVENTHANDLER_INVOKE(power_suspend_early);
xs_lock();
@@ -269,16 +269,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(NULL);
+ if (!xen_suspend_cancelled) {
+ gnttab_resume(NULL);
+ }
#ifdef SMP
if (!CPU_EMPTY(&cpu_suspend_map)) {
diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
index c2e3200..ce50434 100644
--- a/sys/dev/xen/netfront/netfront.c
+++ b/sys/dev/xen/netfront/netfront.c
@@ -439,6 +439,20 @@ static int
netfront_resume(device_t dev)
{
struct netfront_info *info = device_get_softc(dev);
+ u_int i;
+
+ if (xen_suspend_cancelled) {
+ for (i = 0; i < info->num_queues; i++) {
+ XN_RX_LOCK(&info->rxq[i]);
+ XN_TX_LOCK(&info->txq[i]);
+ }
+ netfront_carrier_on(info);
+ for (i = 0; i < info->num_queues; i++) {
+ XN_RX_UNLOCK(&info->rxq[i]);
+ XN_TX_UNLOCK(&info->txq[i]);
+ }
+ return (0);
+ }
netif_disconnect_backend(info);
return (0);
diff --git a/sys/xen/xen-os.h b/sys/xen/xen-os.h
index 96e084f..044433a 100644
--- a/sys/xen/xen-os.h
+++ b/sys/xen/xen-os.h
@@ -56,6 +56,8 @@ extern char *console_page;
extern int xen_disable_pv_disks;
extern int xen_disable_pv_nics;
+extern bool xen_suspend_cancelled;
+
enum xen_domain_type {
XEN_NATIVE, /* running on bare hardware */
XEN_PV_DOMAIN, /* running in a PV domain */
diff --git a/sys/xen/xenbus/xenbusb.c b/sys/xen/xenbus/xenbusb.c
index 0352548..241efaa 100644
--- a/sys/xen/xenbus/xenbusb.c
+++ b/sys/xen/xenbus/xenbusb.c
@@ -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);
OpenPOWER on IntegriCloud