aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorAurelien Chartier <aurelien.chartier@citrix.com>2013-05-28 13:09:56 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2013-05-29 09:04:19 -0400
commit2abb274629614bef4044a0b98ada42e977feadfd (patch)
tree0c4ef9f17333b7e6ec558a10cf7d218a52d85276 /drivers/xen
parent1d7004f0593f631b78745e4c835d8e09b31f4996 (diff)
xenbus: delay xenbus frontend resume if xenstored is not running
If the xenbus frontend is located in a domain running xenstored, the device resume is hanging because it is happening before the process resume. This patch adds extra logic to the resume code to check if we are the domain running xenstored and delay the resume if needed. Signed-off-by: Aurelien Chartier <aurelien.chartier@citrix.com> [Changes in v2: - Instead of bypassing the resume, process it in a workqueue] [Changes in v3: - Add a struct work in xenbus_device to avoid dynamic allocation - Several small code fixes] [Changes in v4: - Use a dedicated workqueue] [Changes in v5: - Move create_workqueue error handling to xenbus_frontend_dev_resume] Acked-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/xenbus/xenbus_probe_frontend.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index 3159a37d966d..a7e25073de19 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -29,6 +29,8 @@
29#include "xenbus_probe.h" 29#include "xenbus_probe.h"
30 30
31 31
32static struct workqueue_struct *xenbus_frontend_wq;
33
32/* device/<type>/<id> => <type>-<id> */ 34/* device/<type>/<id> => <type>-<id> */
33static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename) 35static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
34{ 36{
@@ -89,9 +91,40 @@ static void backend_changed(struct xenbus_watch *watch,
89 xenbus_otherend_changed(watch, vec, len, 1); 91 xenbus_otherend_changed(watch, vec, len, 1);
90} 92}
91 93
94static void xenbus_frontend_delayed_resume(struct work_struct *w)
95{
96 struct xenbus_device *xdev = container_of(w, struct xenbus_device, work);
97
98 xenbus_dev_resume(&xdev->dev);
99}
100
101static int xenbus_frontend_dev_resume(struct device *dev)
102{
103 /*
104 * If xenstored is running in this domain, we cannot access the backend
105 * state at the moment, so we need to defer xenbus_dev_resume
106 */
107 if (xen_store_domain_type == XS_LOCAL) {
108 struct xenbus_device *xdev = to_xenbus_device(dev);
109
110 if (!xenbus_frontend_wq) {
111 pr_err("%s: no workqueue to process delayed resume\n",
112 xdev->nodename);
113 return -EFAULT;
114 }
115
116 INIT_WORK(&xdev->work, xenbus_frontend_delayed_resume);
117 queue_work(xenbus_frontend_wq, &xdev->work);
118
119 return 0;
120 }
121
122 return xenbus_dev_resume(dev);
123}
124
92static const struct dev_pm_ops xenbus_pm_ops = { 125static const struct dev_pm_ops xenbus_pm_ops = {
93 .suspend = xenbus_dev_suspend, 126 .suspend = xenbus_dev_suspend,
94 .resume = xenbus_dev_resume, 127 .resume = xenbus_frontend_dev_resume,
95 .freeze = xenbus_dev_suspend, 128 .freeze = xenbus_dev_suspend,
96 .thaw = xenbus_dev_cancel, 129 .thaw = xenbus_dev_cancel,
97 .restore = xenbus_dev_resume, 130 .restore = xenbus_dev_resume,
@@ -440,6 +473,8 @@ static int __init xenbus_probe_frontend_init(void)
440 473
441 register_xenstore_notifier(&xenstore_notifier); 474 register_xenstore_notifier(&xenstore_notifier);
442 475
476 xenbus_frontend_wq = create_workqueue("xenbus_frontend");
477
443 return 0; 478 return 0;
444} 479}
445subsys_initcall(xenbus_probe_frontend_init); 480subsys_initcall(xenbus_probe_frontend_init);