]> www.infradead.org Git - users/jedix/linux-maple.git/commit
PCI: Update Link Speed after retraining
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 14 May 2025 13:28:21 +0000 (16:28 +0300)
committerKrzysztof Wilczyński <kwilczynski@kernel.org>
Thu, 15 May 2025 16:28:44 +0000 (16:28 +0000)
commit6ade6e81f898f7f533207b23849ac8cc0ea8c755
tree4b465435a99828e070e4161576af5b0c16b9d2a4
parent2389d8dc38fee18176c49e9c4804f5ecc55807fa
PCI: Update Link Speed after retraining

PCIe Link Retraining can alter Link Speed. pcie_retrain_link() that
performs the Link Training is called from bwctrl and ASPM driver.

While bwctrl listens for Link Bandwidth Management Status (LBMS) to
pick up changes in Link Speed, there is a race between
pcie_reset_lbms() clearing LBMS after the Link Training and
pcie_bwnotif_irq() reading the Link Status register. If LBMS is already
cleared when the irq handler reads the register, the interrupt handler
will return early with IRQ_NONE and won't update the Link Speed.

When Link Speed update originates from bwctrl,
pcie_bwctrl_change_speed() ensures Link Speed is updated after the
retraining. ASPM driver, however, calls pcie_retrain_link() but does
not update the Link Speed after retraining which can result in stale
Link Speed. Also, it is possible to have ASPM support with
CONFIG_PCIEPORTBUS=n in which case bwctrl will not be built in (and
thus won't update the Link Speed at all).

To ensure Link Speed is not left stale after Link Training, move the
call to pcie_update_link_speed() from pcie_bwctrl_change_speed() into
pcie_retrain_link().

Suggested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Link: https://lore.kernel.org/linux-pci/aBCjpfyYmlkJ12AZ@wunner.de
Link: https://lore.kernel.org/r/20250514132821.15705-1-ilpo.jarvinen@linux.intel.com
drivers/pci/pci.c
drivers/pci/pcie/bwctrl.c