Skip to content

Commit

Permalink
xenbus: delay xenbus frontend resume if xenstored is not running
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Aurelien Chartier authored and Konrad Rzeszutek Wilk committed May 29, 2013
1 parent 1d7004f commit 2abb274
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
37 changes: 36 additions & 1 deletion drivers/xen/xenbus/xenbus_probe_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "xenbus_probe.h"


static struct workqueue_struct *xenbus_frontend_wq;

/* device/<type>/<id> => <type>-<id> */
static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
{
Expand Down Expand Up @@ -89,9 +91,40 @@ static void backend_changed(struct xenbus_watch *watch,
xenbus_otherend_changed(watch, vec, len, 1);
}

static void xenbus_frontend_delayed_resume(struct work_struct *w)
{
struct xenbus_device *xdev = container_of(w, struct xenbus_device, work);

xenbus_dev_resume(&xdev->dev);
}

static int xenbus_frontend_dev_resume(struct device *dev)
{
/*
* If xenstored is running in this domain, we cannot access the backend
* state at the moment, so we need to defer xenbus_dev_resume
*/
if (xen_store_domain_type == XS_LOCAL) {
struct xenbus_device *xdev = to_xenbus_device(dev);

if (!xenbus_frontend_wq) {
pr_err("%s: no workqueue to process delayed resume\n",
xdev->nodename);
return -EFAULT;
}

INIT_WORK(&xdev->work, xenbus_frontend_delayed_resume);
queue_work(xenbus_frontend_wq, &xdev->work);

return 0;
}

return xenbus_dev_resume(dev);
}

static const struct dev_pm_ops xenbus_pm_ops = {
.suspend = xenbus_dev_suspend,
.resume = xenbus_dev_resume,
.resume = xenbus_frontend_dev_resume,
.freeze = xenbus_dev_suspend,
.thaw = xenbus_dev_cancel,
.restore = xenbus_dev_resume,
Expand Down Expand Up @@ -440,6 +473,8 @@ static int __init xenbus_probe_frontend_init(void)

register_xenstore_notifier(&xenstore_notifier);

xenbus_frontend_wq = create_workqueue("xenbus_frontend");

return 0;
}
subsys_initcall(xenbus_probe_frontend_init);
Expand Down
1 change: 1 addition & 0 deletions include/xen/xenbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct xenbus_device {
struct device dev;
enum xenbus_state state;
struct completion down;
struct work_struct work;
};

static inline struct xenbus_device *to_xenbus_device(struct device *dev)
Expand Down

0 comments on commit 2abb274

Please sign in to comment.