diff mbox series

[17/17] wifi: ath10k: Use pcie_lnkctl_clear_and_set() for changing LNKCTL

Message ID 20230511131441.45704-18-ilpo.jarvinen@linux.intel.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show
Series None | expand

Commit Message

Ilpo Järvinen May 11, 2023, 1:14 p.m. UTC
Don't assume that only the driver would be accessing LNKCTL. ASPM
policy changes can trigger write to LNKCTL outside of driver's control.

Use pcie_lnkctl_clear_and_set() which does proper locking to avoid
losing concurrent updates to the register value. Convert one of the
writes to only touch PCI_EXP_LNKCTL_ASPMC field which the driver itself
has been changing, leave the other fields untouched.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/net/wireless/ath/ath10k/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index a7f44f6335fb..d18dfb495194 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1963,8 +1963,8 @@  static int ath10k_pci_hif_start(struct ath10k *ar)
 	ath10k_pci_irq_enable(ar);
 	ath10k_pci_rx_post(ar);
 
-	pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL,
-				   ar_pci->link_ctl);
+	pcie_lnkctl_clear_and_set(ar_pci->pdev, 0,
+				  ar_pci->link_ctl & PCI_EXP_LNKCTL_ASPMC);
 
 	return 0;
 }
@@ -2821,8 +2821,8 @@  static int ath10k_pci_hif_power_up(struct ath10k *ar,
 
 	pcie_capability_read_word(ar_pci->pdev, PCI_EXP_LNKCTL,
 				  &ar_pci->link_ctl);
-	pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL,
-				   ar_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC);
+	pcie_lnkctl_clear_and_set(ar_pci->pdev,
+				  ar_pci->link_ctl & PCI_EXP_LNKCTL_ASPMC, 0);
 
 	/*
 	 * Bring the target up cleanly.