Skip to content

Commit 4fde895

Browse files
committed
cxl: Add helper to detect top of CXL device topology
Add a helper to replace the open code detection of CXL device hierarchy root, or the host bridge. The helper will be used for delayed downstream port (dport) creation. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Li Ming <ming.li@zohomail.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Robert Richter <rrichter@amd.com> Tested-by: Robert Richter <rrichter@amd.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 8f5ae30 commit 4fde895

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

drivers/cxl/core/port.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
static DEFINE_IDA(cxl_port_ida);
3434
static DEFINE_XARRAY(cxl_root_buses);
3535

36+
/*
37+
* The terminal device in PCI is NULL and @platform_bus
38+
* for platform devices (for cxl_test)
39+
*/
40+
static bool is_cxl_host_bridge(struct device *dev)
41+
{
42+
return (!dev || dev == &platform_bus);
43+
}
44+
3645
int cxl_num_decoders_committed(struct cxl_port *port)
3746
{
3847
lockdep_assert_held(&cxl_rwsem.region);
@@ -1541,7 +1550,7 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd,
15411550
resource_size_t component_reg_phys;
15421551
int rc;
15431552

1544-
if (!dparent) {
1553+
if (is_cxl_host_bridge(dparent)) {
15451554
/*
15461555
* The iteration reached the topology root without finding the
15471556
* CXL-root 'cxl_port' on a previous iteration, fail for now to
@@ -1629,11 +1638,7 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd)
16291638
struct device *uport_dev;
16301639
struct cxl_dport *dport;
16311640

1632-
/*
1633-
* The terminal "grandparent" in PCI is NULL and @platform_bus
1634-
* for platform devices
1635-
*/
1636-
if (!dport_dev || dport_dev == &platform_bus)
1641+
if (is_cxl_host_bridge(dport_dev))
16371642
return 0;
16381643

16391644
uport_dev = dport_dev->parent;

0 commit comments

Comments
 (0)