Skip to content

Commit 2d2b3fe

Browse files
djbwdavejiang
authored andcommitted
cxl/port: Unify endpoint and switch port lookup
In support of generic CXL protocol error handling across various 'struct cxl_port' types, update find_cxl_port_by_uport() to retrieve endpoint CXL port companions from endpoint PCIe device instances. The end result is that upstream switch ports and endpoint ports can share error handling and eventually delete the misplaced cxl_error_handlers from the cxl_pci class driver. Reviewed-by: Terry Bowman <terry.bowman@amd.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Tested-by: Terry Bowman <terry.bowman@amd.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Link: https://patch.msgid.link/20260131000403.2135324-10-dan.j.williams@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent dab7162 commit 2d2b3fe

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/cxl/core/port.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,10 +1590,20 @@ static int match_port_by_uport(struct device *dev, const void *data)
15901590
return 0;
15911591

15921592
port = to_cxl_port(dev);
1593+
/* Endpoint ports are hosted by memdevs */
1594+
if (is_cxl_memdev(port->uport_dev))
1595+
return uport_dev == port->uport_dev->parent;
15931596
return uport_dev == port->uport_dev;
15941597
}
15951598

1596-
/*
1599+
/**
1600+
* find_cxl_port_by_uport - Find a CXL port device companion
1601+
* @uport_dev: Device that acts as a switch or endpoint in the CXL hierarchy
1602+
*
1603+
* In the case of endpoint ports recall that port->uport_dev points to a 'struct
1604+
* cxl_memdev' device. So, the @uport_dev argument is the parent device of the
1605+
* 'struct cxl_memdev' in that case.
1606+
*
15971607
* Function takes a device reference on the port device. Caller should do a
15981608
* put_device() when done.
15991609
*/

0 commit comments

Comments
 (0)