From 01d14d60bfc05975ae11e31062b0a2fcc66db815 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Fri, 6 Feb 2009 18:46:47 -0800 Subject: [PATCH] --- yaml --- r: 145840 b: refs/heads/master c: 818fd20673df82031e604bb784d836f1fc2e2451 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/xen/manage.c | 9 ++-- trunk/drivers/xen/xenbus/xenbus_probe.c | 61 +++++++++++++++++++++---- trunk/drivers/xen/xenbus/xenbus_xs.c | 2 - trunk/drivers/xen/xenfs/super.c | 19 +++++++- trunk/include/xen/xenbus.h | 3 +- 6 files changed, 77 insertions(+), 19 deletions(-) diff --git a/[refs] b/[refs] index d19d1d27bdd1..08ee5ad8763e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c6a960ce8858f20036cc3afc3b9422670d0d9021 +refs/heads/master: 818fd20673df82031e604bb784d836f1fc2e2451 diff --git a/trunk/drivers/xen/manage.c b/trunk/drivers/xen/manage.c index 5269bb4d2496..b703dd2c9f11 100644 --- a/trunk/drivers/xen/manage.c +++ b/trunk/drivers/xen/manage.c @@ -104,8 +104,9 @@ static void do_suspend(void) goto out; } - printk(KERN_DEBUG "suspending xenstore...\n"); - xs_suspend(); + printk("suspending xenbus...\n"); + /* XXX use normal device tree? */ + xenbus_suspend(); err = stop_machine(xen_suspend, &cancelled, cpumask_of(0)); if (err) { @@ -115,9 +116,9 @@ static void do_suspend(void) if (!cancelled) { xen_arch_resume(); - xs_resume(); + xenbus_resume(); } else - xs_suspend_cancel(); + xenbus_suspend_cancel(); device_resume(PMSG_RESUME); diff --git a/trunk/drivers/xen/xenbus/xenbus_probe.c b/trunk/drivers/xen/xenbus/xenbus_probe.c index d42e25d5968d..773d1cf23283 100644 --- a/trunk/drivers/xen/xenbus/xenbus_probe.c +++ b/trunk/drivers/xen/xenbus/xenbus_probe.c @@ -71,9 +71,6 @@ static int xenbus_probe_frontend(const char *type, const char *name); static void xenbus_dev_shutdown(struct device *_dev); -static int xenbus_dev_suspend(struct device *dev, pm_message_t state); -static int xenbus_dev_resume(struct device *dev); - /* If something in array of ids matches this device, return it. */ static const struct xenbus_device_id * match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev) @@ -191,9 +188,6 @@ static struct xen_bus_type xenbus_frontend = { .remove = xenbus_dev_remove, .shutdown = xenbus_dev_shutdown, .dev_attrs = xenbus_dev_attrs, - - .suspend = xenbus_dev_suspend, - .resume = xenbus_dev_resume, }, }; @@ -660,7 +654,6 @@ void xenbus_dev_changed(const char *node, struct xen_bus_type *bus) kfree(root); } -EXPORT_SYMBOL_GPL(xenbus_dev_changed); static void frontend_changed(struct xenbus_watch *watch, const char **vec, unsigned int len) @@ -676,7 +669,7 @@ static struct xenbus_watch fe_watch = { .callback = frontend_changed, }; -static int xenbus_dev_suspend(struct device *dev, pm_message_t state) +static int suspend_dev(struct device *dev, void *data) { int err = 0; struct xenbus_driver *drv; @@ -689,14 +682,35 @@ static int xenbus_dev_suspend(struct device *dev, pm_message_t state) drv = to_xenbus_driver(dev->driver); xdev = container_of(dev, struct xenbus_device, dev); if (drv->suspend) - err = drv->suspend(xdev, state); + err = drv->suspend(xdev); if (err) printk(KERN_WARNING "xenbus: suspend %s failed: %i\n", dev_name(dev), err); return 0; } -static int xenbus_dev_resume(struct device *dev) +static int suspend_cancel_dev(struct device *dev, void *data) +{ + int err = 0; + struct xenbus_driver *drv; + struct xenbus_device *xdev; + + DPRINTK(""); + + if (dev->driver == NULL) + return 0; + drv = to_xenbus_driver(dev->driver); + xdev = container_of(dev, struct xenbus_device, dev); + if (drv->suspend_cancel) + err = drv->suspend_cancel(xdev); + if (err) + printk(KERN_WARNING + "xenbus: suspend_cancel %s failed: %i\n", + dev_name(dev), err); + return 0; +} + +static int resume_dev(struct device *dev, void *data) { int err; struct xenbus_driver *drv; @@ -741,6 +755,33 @@ static int xenbus_dev_resume(struct device *dev) return 0; } +void xenbus_suspend(void) +{ + DPRINTK(""); + + bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev); + xenbus_backend_suspend(suspend_dev); + xs_suspend(); +} +EXPORT_SYMBOL_GPL(xenbus_suspend); + +void xenbus_resume(void) +{ + xb_init_comms(); + xs_resume(); + bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev); + xenbus_backend_resume(resume_dev); +} +EXPORT_SYMBOL_GPL(xenbus_resume); + +void xenbus_suspend_cancel(void) +{ + xs_suspend_cancel(); + bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_cancel_dev); + xenbus_backend_resume(suspend_cancel_dev); +} +EXPORT_SYMBOL_GPL(xenbus_suspend_cancel); + /* A flag to determine if xenstored is 'ready' (i.e. has started) */ int xenstored_ready = 0; diff --git a/trunk/drivers/xen/xenbus/xenbus_xs.c b/trunk/drivers/xen/xenbus/xenbus_xs.c index eab33f1dbdf7..e325eab4724d 100644 --- a/trunk/drivers/xen/xenbus/xenbus_xs.c +++ b/trunk/drivers/xen/xenbus/xenbus_xs.c @@ -673,8 +673,6 @@ void xs_resume(void) struct xenbus_watch *watch; char token[sizeof(watch) * 2 + 1]; - xb_init_comms(); - mutex_unlock(&xs_state.response_mutex); mutex_unlock(&xs_state.request_mutex); up_write(&xs_state.transaction_mutex); diff --git a/trunk/drivers/xen/xenfs/super.c b/trunk/drivers/xen/xenfs/super.c index 515741a8e6b8..6559e0c752ce 100644 --- a/trunk/drivers/xen/xenfs/super.c +++ b/trunk/drivers/xen/xenfs/super.c @@ -20,10 +20,27 @@ MODULE_DESCRIPTION("Xen filesystem"); MODULE_LICENSE("GPL"); +static ssize_t capabilities_read(struct file *file, char __user *buf, + size_t size, loff_t *off) +{ + char *tmp = ""; + + if (xen_initial_domain()) + tmp = "control_d\n"; + + return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp)); +} + +static const struct file_operations capabilities_file_ops = { + .read = capabilities_read, +}; + static int xenfs_fill_super(struct super_block *sb, void *data, int silent) { static struct tree_descr xenfs_files[] = { - [2] = {"xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR}, + [1] = {}, + { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR }, + { "capabilities", &capabilities_file_ops, S_IRUGO }, {""}, }; diff --git a/trunk/include/xen/xenbus.h b/trunk/include/xen/xenbus.h index b9763badbd77..f87f9614844d 100644 --- a/trunk/include/xen/xenbus.h +++ b/trunk/include/xen/xenbus.h @@ -91,7 +91,8 @@ struct xenbus_driver { void (*otherend_changed)(struct xenbus_device *dev, enum xenbus_state backend_state); int (*remove)(struct xenbus_device *dev); - int (*suspend)(struct xenbus_device *dev, pm_message_t state); + int (*suspend)(struct xenbus_device *dev); + int (*suspend_cancel)(struct xenbus_device *dev); int (*resume)(struct xenbus_device *dev); int (*uevent)(struct xenbus_device *, char **, int, char *, int); struct device_driver driver;