Commit 672b7763 authored by Paul Durrant's avatar Paul Durrant Committed by Juergen Gross

xenbus: limit when state is forced to closed

If a driver probe() fails then leave the xenstore state alone. There is no
reason to modify it as the failure may be due to transient resource
allocation issues and hence a subsequent probe() may succeed.

If the driver supports re-binding then only force state to closed during
remove() only in the case when the toolstack may need to clean up. This can
be detected by checking whether the state in xenstore has been set to
closing prior to device removal.

NOTE: Re-bind support is indicated by new boolean in struct xenbus_driver,
      which defaults to false. Subsequent patches will add support to
      some backend drivers.
Signed-off-by: default avatarPaul Durrant <pdurrant@amazon.com>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent c534374e
...@@ -255,7 +255,6 @@ int xenbus_dev_probe(struct device *_dev) ...@@ -255,7 +255,6 @@ int xenbus_dev_probe(struct device *_dev)
module_put(drv->driver.owner); module_put(drv->driver.owner);
fail: fail:
xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename);
xenbus_switch_state(dev, XenbusStateClosed);
return err; return err;
} }
EXPORT_SYMBOL_GPL(xenbus_dev_probe); EXPORT_SYMBOL_GPL(xenbus_dev_probe);
...@@ -276,7 +275,16 @@ int xenbus_dev_remove(struct device *_dev) ...@@ -276,7 +275,16 @@ int xenbus_dev_remove(struct device *_dev)
free_otherend_details(dev); free_otherend_details(dev);
xenbus_switch_state(dev, XenbusStateClosed); /*
* If the toolstack has forced the device state to closing then set
* the state to closed now to allow it to be cleaned up.
* Similarly, if the driver does not support re-bind, set the
* closed.
*/
if (!drv->allow_rebind ||
xenbus_read_driver_state(dev->nodename) == XenbusStateClosing)
xenbus_switch_state(dev, XenbusStateClosed);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(xenbus_dev_remove); EXPORT_SYMBOL_GPL(xenbus_dev_remove);
......
...@@ -93,6 +93,7 @@ struct xenbus_device_id ...@@ -93,6 +93,7 @@ struct xenbus_device_id
struct xenbus_driver { struct xenbus_driver {
const char *name; /* defaults to ids[0].devicetype */ const char *name; /* defaults to ids[0].devicetype */
const struct xenbus_device_id *ids; const struct xenbus_device_id *ids;
bool allow_rebind; /* avoid setting xenstore closed during remove */
int (*probe)(struct xenbus_device *dev, int (*probe)(struct xenbus_device *dev,
const struct xenbus_device_id *id); const struct xenbus_device_id *id);
void (*otherend_changed)(struct xenbus_device *dev, void (*otherend_changed)(struct xenbus_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment