Skip to content

Commit fb0171a

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Make link retraining use RMW accessors for changing LNKCTL
Don't assume that the device is fully under the control of PCI core. Use RMW capability accessors in link retraining which do proper locking to avoid losing concurrent updates to the register values. Suggested-by: Lukas Wunner <lukas@wunner.de> Fixes: 4ec7379 ("PCI: Work around Pericom PCIe-to-PCI bridge Retrain Link erratum") Fixes: 7d715a6 ("PCI: add PCI Express ASPM support") Link: https://lore.kernel.org/r/20230717120503.15276-3-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
1 parent 5e70d0a commit fb0171a

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

drivers/pci/pci.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,6 @@ static int pcie_wait_for_link_status(struct pci_dev *pdev,
49274927
int pcie_retrain_link(struct pci_dev *pdev, bool use_lt)
49284928
{
49294929
int rc;
4930-
u16 lnkctl;
49314930

49324931
/*
49334932
* Ensure the updated LNKCTL parameters are used during link
@@ -4939,17 +4938,14 @@ int pcie_retrain_link(struct pci_dev *pdev, bool use_lt)
49394938
if (rc)
49404939
return rc;
49414940

4942-
pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnkctl);
4943-
lnkctl |= PCI_EXP_LNKCTL_RL;
4944-
pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnkctl);
4941+
pcie_capability_set_word(pdev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_RL);
49454942
if (pdev->clear_retrain_link) {
49464943
/*
49474944
* Due to an erratum in some devices the Retrain Link bit
49484945
* needs to be cleared again manually to allow the link
49494946
* training to succeed.
49504947
*/
4951-
lnkctl &= ~PCI_EXP_LNKCTL_RL;
4952-
pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnkctl);
4948+
pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_RL);
49534949
}
49544950

49554951
return pcie_wait_for_link_status(pdev, use_lt, !use_lt);

0 commit comments

Comments
 (0)