Skip to content

Commit 5f75f96

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: pciehp: Use RMW accessors for changing LNKCTL
As hotplug is not the only driver touching LNKCTL, use the RMW capability accessor which handles concurrent changes correctly. Suggested-by: Lukas Wunner <lukas@wunner.de> Fixes: 7f82299 ("PCI: pciehp: Add Disable/enable link functions") Link: https://lore.kernel.org/r/20230717120503.15276-4-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 fb0171a commit 5f75f96

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,11 @@ int pciehp_check_link_status(struct controller *ctrl)
332332
static int __pciehp_link_set(struct controller *ctrl, bool enable)
333333
{
334334
struct pci_dev *pdev = ctrl_dev(ctrl);
335-
u16 lnk_ctrl;
336335

337-
pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnk_ctrl);
336+
pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL,
337+
PCI_EXP_LNKCTL_LD,
338+
enable ? 0 : PCI_EXP_LNKCTL_LD);
338339

339-
if (enable)
340-
lnk_ctrl &= ~PCI_EXP_LNKCTL_LD;
341-
else
342-
lnk_ctrl |= PCI_EXP_LNKCTL_LD;
343-
344-
pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl);
345-
ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl);
346340
return 0;
347341
}
348342

0 commit comments

Comments
 (0)