From 371cb820f479047848d0991cbab9908e1ce45cd7 Mon Sep 17 00:00:00 2001 From: royger Date: Tue, 21 Mar 2017 09:27:24 +0000 Subject: [PATCH] MFC r314841: xenstore: fix suspension when using the xenstore device Submitted by: Liuyingdong Reviewed by: royger git-svn-id: svn://svn.freebsd.org/base/stable/10@315675 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/xen/control/control.c | 6 ++++++ sys/xen/xenstore/xenstore.c | 17 +++++++++++++++++ sys/xen/xenstore/xenstorevar.h | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c index 60e448a1a..37ba72257 100644 --- a/sys/dev/xen/control/control.c +++ b/sys/dev/xen/control/control.c @@ -343,6 +343,10 @@ xctrl_suspend() #endif int suspend_cancelled; + EVENTHANDLER_INVOKE(power_suspend_early); + xs_lock(); + stop_all_proc(); + xs_unlock(); EVENTHANDLER_INVOKE(power_suspend); if (smp_started) { @@ -429,6 +433,8 @@ xctrl_suspend() thread_unlock(curthread); } + resume_all_proc(); + EVENTHANDLER_INVOKE(power_resume); if (bootverbose) diff --git a/sys/xen/xenstore/xenstore.c b/sys/xen/xenstore/xenstore.c index d404862ab..2c193acde 100644 --- a/sys/xen/xenstore/xenstore.c +++ b/sys/xen/xenstore/xenstore.c @@ -1657,3 +1657,20 @@ xs_unregister_watch(struct xs_watch *watch) sx_xunlock(&xs.xenwatch_mutex); } } + +void +xs_lock(void) +{ + + sx_xlock(&xs.request_mutex); + return; +} + +void +xs_unlock(void) +{ + + sx_xunlock(&xs.request_mutex); + return; +} + diff --git a/sys/xen/xenstore/xenstorevar.h b/sys/xen/xenstore/xenstorevar.h index 208e5bf09..4c612b4b6 100644 --- a/sys/xen/xenstore/xenstorevar.h +++ b/sys/xen/xenstore/xenstorevar.h @@ -338,4 +338,15 @@ void xs_unregister_watch(struct xs_watch *watch); */ struct sbuf *xs_join(const char *, const char *); +/** + * Lock the xenstore request mutex. + */ +void xs_lock(void); + +/** + * Unlock the xenstore request mutex. + */ +void xs_unlock(void); + #endif /* _XEN_XENSTORE_XENSTOREVAR_H */ + -- 2.45.0