On Mon, 06 Feb 2023 13:51:19 -0700 Dave Jiang <dave.jiang@xxxxxxxxx> wrote: > CXL Memory Device SW Guide rev1.0 2.11.2 provides instruction on how to > caluclate latency and bandwidth for CXL memory device. Calculate minimum Spell check your descriptions (I often forget to do this as well! ) > bandwidth and total latency for the path from the CXL device to the root > port. The calculates values are stored in the cached DSMAS entries attached > to the cxl_port of the CXL device. > > For example for a device that is directly attached to a host bus: > Total Latency = Device Latency (from CDAT) + Dev to Host Bus (HB) Link > Latency > Min Bandwidth = Link Bandwidth between Host Bus and CXL device > > For a device that has a switch in between host bus and CXL device: > Total Latency = Device (CDAT) Latency + Dev to Switch Link Latency + > Switch (CDAT) Latency + Switch to HB Link Latency For QTG purposes, are we also supposed to take into account HB to system interconnect type latency (or maybe nearest CPU?). That is likely to be non trivial. > Min Bandwidth = min(dev to switch bandwidth, switch to HB bandwidth) > Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> Stray sign off. > > The internal latency for a switch can be retrieved from the CDAT of the > switch PCI device. However, since there's no easy way to retrieve that > right now on Linux, a guesstimated constant is used per switch to simplify > the driver code. I'd like to see that gap closed asap. I think it is fairly obvious how to do it, so shouldn't be too hard, just needs a dance to get the DOE for a switch port using Lukas' updated handling of DOE mailboxes. > > Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> > --- > drivers/cxl/core/port.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ > drivers/cxl/cxl.h | 9 +++++++ > drivers/cxl/port.c | 42 +++++++++++++++++++++++++++++++++ > 3 files changed, 111 insertions(+) > > diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c > index 2b27319cfd42..aa260361ba7d 100644 > --- a/drivers/cxl/core/port.c > +++ b/drivers/cxl/core/port.c > @@ -1899,6 +1899,66 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd) > } > EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL); > > +int cxl_port_get_downstream_qos(struct cxl_port *port, long *bw, long *lat) > +{ > + long total_lat = 0, latency; Similar to before, not good for readability to hide asignments in a list all on one line.