Commit fe80f1ad authored by Dan Williams's avatar Dan Williams

cxl/port: Keep port->uport valid for the entire life of a port

The upcoming region provisioning implementation has a need to
dereference port->uport during the port unregister flow. Specifically,
endpoint decoders need to be able to lookup their corresponding memdev
via port->uport.

The existing ->dead flag was added for cases where the core was
committed to tearing down the port, but needed to drop locks before
calling device_unregister(). Reuse that flag to indicate to
delete_endpoint() that it has no "release action" work to do as
unregister_port() will handle it.
Reviewed-by: default avatarAlison Schofield <alison.schofield@intel.com>
Reviewed-by: default avatarAdam Manzanares <a.manzanares@samsung.com>
Link: https://lore.kernel.org/r/165603871491.551046.6682199179541194356.stgit@dwillia2-xfhSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 863fdccd
...@@ -370,7 +370,7 @@ static void unregister_port(void *_port) ...@@ -370,7 +370,7 @@ static void unregister_port(void *_port)
lock_dev = &parent->dev; lock_dev = &parent->dev;
device_lock_assert(lock_dev); device_lock_assert(lock_dev);
port->uport = NULL; port->dead = true;
device_unregister(&port->dev); device_unregister(&port->dev);
} }
...@@ -857,7 +857,7 @@ static void delete_endpoint(void *data) ...@@ -857,7 +857,7 @@ static void delete_endpoint(void *data)
parent = &parent_port->dev; parent = &parent_port->dev;
device_lock(parent); device_lock(parent);
if (parent->driver && endpoint->uport) { if (parent->driver && !endpoint->dead) {
devm_release_action(parent, cxl_unlink_uport, endpoint); devm_release_action(parent, cxl_unlink_uport, endpoint);
devm_release_action(parent, unregister_port, endpoint); devm_release_action(parent, unregister_port, endpoint);
} }
......
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