Re: [PATCH v2 1/2] cxl/port: Hold port host lock while dport adding.
From: Li Ming
Date: Sun Feb 08 2026 - 07:21:29 EST
在 2026/2/8 01:28, dan.j.williams@xxxxxxxxx 写道:
Li Ming wrote:[...]
+static struct device *to_port_host(struct cxl_port *port)
+{
+ struct cxl_port *parent = parent_port_of(port);
+
+ /*
+ * The host of CXL root port and the first level of ports is
+ * the platform firmware device, the host of all other ports
+ * is their parent port.
+ */
+ if (!parent)
+ return port->uport_dev;
This helper looks good and this case is theoretically correct, but I
assume that find_or_add_dport() never hits this case, right?
How about move the introduction of this helper to its own lead-in patch
and use it to replace the open coded version of this pattern in
unregister_port(), __devm_cxl_add_dport(), and endpoint_host().
BTW, after taking a look into __devm_cxl_add_dport(), this helper is not suitable for this case,
the host in __devm_cxl_add_dport() means the new dport's host, it is the device of the cxl port which
the cxl port belongs(or the uport_dev of the cxl port if the port is cxl root).
So I will update unregister_port() and endpoint_host(), and check if there are other
places needed to be cleanup.
Ming