diff options
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe_frontend.c | 37 | ||||
-rw-r--r-- | include/xen/xenbus.h | 1 |
2 files changed, 37 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 | ||
32 | static struct workqueue_struct *xenbus_frontend_wq; | ||
33 | |||
32 | /* device/<type>/<id> => <type>-<id> */ | 34 | /* device/<type>/<id> => <type>-<id> */ |
33 | static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename) | 35 | static 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 | ||
94 | static 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 | |||
101 | static 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 | |||
92 | static const struct dev_pm_ops xenbus_pm_ops = { | 125 | static 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 | } |
445 | subsys_initcall(xenbus_probe_frontend_init); | 480 | subsys_initcall(xenbus_probe_frontend_init); |
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index 0a7515c1e3a4..569c07f2e344 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h | |||
@@ -70,6 +70,7 @@ struct xenbus_device { | |||
70 | struct device dev; | 70 | struct device dev; |
71 | enum xenbus_state state; | 71 | enum xenbus_state state; |
72 | struct completion down; | 72 | struct completion down; |
73 | struct work_struct work; | ||
73 | }; | 74 | }; |
74 | 75 | ||
75 | static inline struct xenbus_device *to_xenbus_device(struct device *dev) | 76 | static inline struct xenbus_device *to_xenbus_device(struct device *dev) |