Message ID | 20230713124505.94866-4-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | PCI: Improve PCIe Capability RMW concurrency control | expand |
On Thu, Jul 13, 2023 at 03:44:57PM +0300, Ilpo Järvinen wrote: > As hotplug is not the only driver touching LNKCTL, use the RMW > capability accessor which handles concurrent changes correctly. ... > + pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, > + PCI_EXP_LNKCTL_LD, > + !enable ? PCI_EXP_LNKCTL_LD : 0); enable ? 0 : PCI_EXP_LNKCTL_LD); easier to read and get.
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 8711325605f0..e9ec77d8d44a 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -332,17 +332,11 @@ int pciehp_check_link_status(struct controller *ctrl) static int __pciehp_link_set(struct controller *ctrl, bool enable) { struct pci_dev *pdev = ctrl_dev(ctrl); - u16 lnk_ctrl; - pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &lnk_ctrl); + pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_LD, + !enable ? PCI_EXP_LNKCTL_LD : 0); - if (enable) - lnk_ctrl &= ~PCI_EXP_LNKCTL_LD; - else - lnk_ctrl |= PCI_EXP_LNKCTL_LD; - - pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, lnk_ctrl); - ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl); return 0; }