Commit 592780b8 authored by Dave Jiang's avatar Dave Jiang

cxl: Fix retrieving of access_coordinates in PCIe path

Current loop in cxl_endpoint_get_perf_coordinates() incorrectly assumes
the Root Port (RP) dport is the one with generic port access_coordinate.
However those coordinates are one level up in the Host Bridge (HB).
Current code causes the computation code to pick up 0s as the coordinates
and cause minimal bandwidth to result in 0.

Add check to skip RP when combining coordinates.

Fixes: 14a6960b ("cxl: Add helper function that calculate performance data for downstream ports")
Reported-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/20240403154844.3403859-3-dave.jiang@intel.comSigned-off-by: default avatarDave Jiang <dave.jiang@intel.com>
parent 648dae58
...@@ -2165,6 +2165,11 @@ int cxl_hb_get_perf_coordinates(struct cxl_port *port, ...@@ -2165,6 +2165,11 @@ int cxl_hb_get_perf_coordinates(struct cxl_port *port,
return 0; return 0;
} }
static bool parent_port_is_cxl_root(struct cxl_port *port)
{
return is_cxl_root(to_cxl_port(port->dev.parent));
}
/** /**
* cxl_endpoint_get_perf_coordinates - Retrieve performance numbers stored in dports * cxl_endpoint_get_perf_coordinates - Retrieve performance numbers stored in dports
* of CXL path * of CXL path
...@@ -2184,27 +2189,31 @@ int cxl_endpoint_get_perf_coordinates(struct cxl_port *port, ...@@ -2184,27 +2189,31 @@ int cxl_endpoint_get_perf_coordinates(struct cxl_port *port,
struct cxl_dport *dport; struct cxl_dport *dport;
struct pci_dev *pdev; struct pci_dev *pdev;
unsigned int bw; unsigned int bw;
bool is_cxl_root;
if (!is_cxl_endpoint(port)) if (!is_cxl_endpoint(port))
return -EINVAL; return -EINVAL;
dport = iter->parent_dport;
/* /*
* Exit the loop when the parent port of the current port is cxl root. * Exit the loop when the parent port of the current iter port is cxl
* The iterative loop starts at the endpoint and gathers the * root. The iterative loop starts at the endpoint and gathers the
* latency of the CXL link from the current iter to the next downstream * latency of the CXL link from the current device/port to the connected
* port each iteration. If the parent is cxl root then there is * downstream port each iteration.
* nothing to gather.
*/ */
while (!is_cxl_root(to_cxl_port(iter->dev.parent))) { do {
cxl_coordinates_combine(&c, &c, &dport->sw_coord); dport = iter->parent_dport;
iter = to_cxl_port(iter->dev.parent);
is_cxl_root = parent_port_is_cxl_root(iter);
/*
* There's no valid access_coordinate for a root port since RPs do not
* have CDAT and therefore needs to be skipped.
*/
if (!is_cxl_root)
cxl_coordinates_combine(&c, &c, &dport->sw_coord);
c.write_latency += dport->link_latency; c.write_latency += dport->link_latency;
c.read_latency += dport->link_latency; c.read_latency += dport->link_latency;
} while (!is_cxl_root);
iter = to_cxl_port(iter->dev.parent);
dport = iter->parent_dport;
}
/* Get the calculated PCI paths bandwidth */ /* Get the calculated PCI paths bandwidth */
pdev = to_pci_dev(port->uport_dev->parent); pdev = to_pci_dev(port->uport_dev->parent);
......
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