diff options
| author | Koichiro Den <den@valinux.co.jp> | 2026-10-09 13:54:51 +0900 |
|---|---|---|
| committer | Dave Jiang <dave.jiang@intel.com> | 2026-10-09 14:10:35 -0700 |
| commit | db4503d4575cdd2fad7e8a13a8a8ffcbc86d152d (patch) | |
| tree | 591000390ff2fea0ca57e4a6c5ecf8fc8c49b1b8 /include/linux | |
| parent | 16440d6e4bf1175cda83438d9f9a8ae84bfcf0ee (diff) | |
| download | linux-next-db4503d4575cdd2fad7e8a13a8a8ffcbc86d152d.tar.gz linux-next-db4503d4575cdd2fad7e8a13a8a8ffcbc86d152d.zip | |
cxl: Account for link width in latency calculation
cxl_pci_get_latency() derives bandwidth from the per-lane speed returned
by pcie_link_speed_mbps(), ignoring the negotiated link width. This
overestimates the FlitLatency contribution for multi-lane links.
Sections 2.11.3 and 2.11.4 of the Intel CXL Memory Device Software Guide
describe the link bandwidth as the product of the negotiated speed and
width.
Replace pcie_link_speed_mbps() with pcie_link_bandwidth_mbps() and
migrate both CXL callers (the only users of the API). The new helper
obtains speed and width from a single Link Status read. The CXL
bandwidth calculation no longer needs a separate width read and
multiplication.
While at it, make error handling more robust by converting PCI config
read errors to negative errno values and checking for zero bandwidth
before calculating latency.
Fixes: 4d07a05397c8 ("cxl: Calculate and store PCI link latency for the downstream ports")
Cc: stable@vger.kernel.org
Signed-off-by: Koichiro Den <den@valinux.co.jp>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> # pci/pci.c
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20261009045452.1107921-3-den@valinux.co.jp
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/pci.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index d31a8d107b1e..bbfb0b98ff46 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1477,7 +1477,7 @@ int pcie_set_mps(struct pci_dev *dev, int mps); u32 pcie_bandwidth_available(struct pci_dev *dev, struct pci_dev **limiting_dev, enum pci_bus_speed *speed, enum pcie_link_width *width); -int pcie_link_speed_mbps(struct pci_dev *pdev); +int pcie_link_bandwidth_mbps(struct pci_dev *pdev); void pcie_print_link_status(struct pci_dev *dev); int pcie_reset_flr(struct pci_dev *dev, bool probe); int pcie_flr(struct pci_dev *dev); |
