Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xenbus: move xenbus_dev_shutdown() into frontend code...

...and make it static

xenbus_dev_shutdown() is seemingly intended to cause clean shutdown of PV
frontends when a guest is rebooted. Indeed the function waits for a
conpletion which is only set by a call to xenbus_frontend_closed().

This patch removes the shutdown() method from backends and moves
xenbus_dev_shutdown() from xenbus_probe.c into xenbus_probe_frontend.c,
renaming it appropriately and making it static.

NOTE: In the case where the backend is running in a driver domain, the
toolstack should have already terminated any frontends that may be
using it (since Xen does not support re-startable PV driver domains)
so xenbus_dev_shutdown() should never be called.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Paul Durrant and committed by
Juergen Gross
c534374e 589b7289

+23 -27
-2
drivers/xen/xenbus/xenbus.h
··· 116 116 117 117 void xenbus_dev_changed(const char *node, struct xen_bus_type *bus); 118 118 119 - void xenbus_dev_shutdown(struct device *_dev); 120 - 121 119 int xenbus_dev_suspend(struct device *dev); 122 120 int xenbus_dev_resume(struct device *dev); 123 121 int xenbus_dev_cancel(struct device *dev);
-23
drivers/xen/xenbus/xenbus_probe.c
··· 281 281 } 282 282 EXPORT_SYMBOL_GPL(xenbus_dev_remove); 283 283 284 - void xenbus_dev_shutdown(struct device *_dev) 285 - { 286 - struct xenbus_device *dev = to_xenbus_device(_dev); 287 - unsigned long timeout = 5*HZ; 288 - 289 - DPRINTK("%s", dev->nodename); 290 - 291 - get_device(&dev->dev); 292 - if (dev->state != XenbusStateConnected) { 293 - pr_info("%s: %s: %s != Connected, skipping\n", 294 - __func__, dev->nodename, xenbus_strstate(dev->state)); 295 - goto out; 296 - } 297 - xenbus_switch_state(dev, XenbusStateClosing); 298 - timeout = wait_for_completion_timeout(&dev->down, timeout); 299 - if (!timeout) 300 - pr_info("%s: %s timeout closing device\n", 301 - __func__, dev->nodename); 302 - out: 303 - put_device(&dev->dev); 304 - } 305 - EXPORT_SYMBOL_GPL(xenbus_dev_shutdown); 306 - 307 284 int xenbus_register_driver_common(struct xenbus_driver *drv, 308 285 struct xen_bus_type *bus, 309 286 struct module *owner, const char *mod_name)
-1
drivers/xen/xenbus/xenbus_probe_backend.c
··· 198 198 .uevent = xenbus_uevent_backend, 199 199 .probe = xenbus_dev_probe, 200 200 .remove = xenbus_dev_remove, 201 - .shutdown = xenbus_dev_shutdown, 202 201 .dev_groups = xenbus_dev_groups, 203 202 }, 204 203 };
+23 -1
drivers/xen/xenbus/xenbus_probe_frontend.c
··· 126 126 return xenbus_dev_probe(dev); 127 127 } 128 128 129 + static void xenbus_frontend_dev_shutdown(struct device *_dev) 130 + { 131 + struct xenbus_device *dev = to_xenbus_device(_dev); 132 + unsigned long timeout = 5*HZ; 133 + 134 + DPRINTK("%s", dev->nodename); 135 + 136 + get_device(&dev->dev); 137 + if (dev->state != XenbusStateConnected) { 138 + pr_info("%s: %s: %s != Connected, skipping\n", 139 + __func__, dev->nodename, xenbus_strstate(dev->state)); 140 + goto out; 141 + } 142 + xenbus_switch_state(dev, XenbusStateClosing); 143 + timeout = wait_for_completion_timeout(&dev->down, timeout); 144 + if (!timeout) 145 + pr_info("%s: %s timeout closing device\n", 146 + __func__, dev->nodename); 147 + out: 148 + put_device(&dev->dev); 149 + } 150 + 129 151 static const struct dev_pm_ops xenbus_pm_ops = { 130 152 .suspend = xenbus_dev_suspend, 131 153 .resume = xenbus_frontend_dev_resume, ··· 168 146 .uevent = xenbus_uevent_frontend, 169 147 .probe = xenbus_frontend_dev_probe, 170 148 .remove = xenbus_dev_remove, 171 - .shutdown = xenbus_dev_shutdown, 149 + .shutdown = xenbus_frontend_dev_shutdown, 172 150 .dev_groups = xenbus_dev_groups, 173 151 174 152 .pm = &xenbus_pm_ops,