From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
It is not recommended to enable/disable the ASPM states on the back of the
PCI core directly using the LNKCTL register. It will break the PCI core's
knowledge about the device ASPM states. So use the APIs exposed by the PCI
core to enable/disable ASPM states.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Reported-by: Qiang Yu <qiang.yu@oss.qualcomm.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/Kconfig | 2 +-
drivers/net/wireless/ath/ath12k/pci.c | 19 +++----------------
drivers/net/wireless/ath/ath12k/pci.h | 4 +++-
3 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/Kconfig b/drivers/net/wireless/ath/ath12k/Kconfig
index 1ea1af1b8f6c5425c38663977f1d60fe3acb5437..789276e1e9c289de7afdbcaf72be6410b6ea7385 100644
--- a/drivers/net/wireless/ath/ath12k/Kconfig
+++ b/drivers/net/wireless/ath/ath12k/Kconfig
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause-Clear
config ATH12K
tristate "Qualcomm Technologies Wi-Fi 7 support (ath12k)"
- depends on MAC80211 && HAS_DMA && PCI
+ depends on MAC80211 && HAS_DMA && PCI && PCIEASPM
select CRYPTO_MICHAEL_MIC
select QCOM_QMI_HELPERS
select MHI_BUS
diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c
index c729d5526c753d2b7b7542b6f2a145e71b335a43..29236da231e51ac402e40dd124bb474b3102e6c8 100644
--- a/drivers/net/wireless/ath/ath12k/pci.c
+++ b/drivers/net/wireless/ath/ath12k/pci.c
@@ -917,19 +917,9 @@ static void ath12k_pci_free_region(struct ath12k_pci *ab_pci)
static void ath12k_pci_aspm_disable(struct ath12k_pci *ab_pci)
{
- struct ath12k_base *ab = ab_pci->ab;
-
- pcie_capability_read_word(ab_pci->pdev, PCI_EXP_LNKCTL,
- &ab_pci->link_ctl);
-
- ath12k_dbg(ab, ATH12K_DBG_PCI, "pci link_ctl 0x%04x L0s %d L1 %d\n",
- ab_pci->link_ctl,
- u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L0S),
- u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1));
+ ab_pci->aspm_states = pcie_aspm_enabled(ab_pci->pdev);
- /* disable L0s and L1 */
- pcie_capability_clear_word(ab_pci->pdev, PCI_EXP_LNKCTL,
- PCI_EXP_LNKCTL_ASPMC);
+ pci_disable_link_state(ab_pci->pdev, PCIE_LINK_STATE_ALL);
set_bit(ATH12K_PCI_ASPM_RESTORE, &ab_pci->flags);
}
@@ -958,10 +948,7 @@ static void ath12k_pci_aspm_restore(struct ath12k_pci *ab_pci)
{
if (ab_pci->ab->hw_params->supports_aspm &&
test_and_clear_bit(ATH12K_PCI_ASPM_RESTORE, &ab_pci->flags))
- pcie_capability_clear_and_set_word(ab_pci->pdev, PCI_EXP_LNKCTL,
- PCI_EXP_LNKCTL_ASPMC,
- ab_pci->link_ctl &
- PCI_EXP_LNKCTL_ASPMC);
+ pci_enable_link_state(ab_pci->pdev, ab_pci->aspm_states);
}
static void ath12k_pci_cancel_workqueue(struct ath12k_base *ab)
diff --git a/drivers/net/wireless/ath/ath12k/pci.h b/drivers/net/wireless/ath/ath12k/pci.h
index d1ec8aad7f6c3b6f5cbdf8ce57a4106733686521..f3e4e59323036e6251d422b7a2d1997811cc3f98 100644
--- a/drivers/net/wireless/ath/ath12k/pci.h
+++ b/drivers/net/wireless/ath/ath12k/pci.h
@@ -114,7 +114,9 @@ struct ath12k_pci {
/* enum ath12k_pci_flags */
unsigned long flags;
- u16 link_ctl;
+
+ /* Cached PCIe ASPM states */
+ u32 aspm_states;
unsigned long irq_flags;
const struct ath12k_pci_ops *pci_ops;
u32 qmi_instance;
--
2.45.2
On 8/25/2025 10:44 AM, Manivannan Sadhasivam via B4 Relay wrote: > --- a/drivers/net/wireless/ath/ath12k/Kconfig > +++ b/drivers/net/wireless/ath/ath12k/Kconfig > @@ -1,7 +1,7 @@ > # SPDX-License-Identifier: BSD-3-Clause-Clear > config ATH12K > tristate "Qualcomm Technologies Wi-Fi 7 support (ath12k)" > - depends on MAC80211 && HAS_DMA && PCI > + depends on MAC80211 && HAS_DMA && PCI && PCIEASPM As you point out in patch 1/8, PCIEASPM is protected by EXPERT. Won't this prevent the driver from being built (or even showing up in menuconfig) if EXPERT is not enabled? Should we consider having a separate CONFIG item that is used to protect just the PCI ASPM interfaces? And then we could split out the ath12k_pci_aspm functions into a separate file that is conditionally built based upon that config item? Or am I too paranoid since everyone enables EXPERT? /jeff
On Tue, 26 Aug 2025, Jeff Johnson wrote: > On 8/25/2025 10:44 AM, Manivannan Sadhasivam via B4 Relay wrote: > > --- a/drivers/net/wireless/ath/ath12k/Kconfig > > +++ b/drivers/net/wireless/ath/ath12k/Kconfig > > @@ -1,7 +1,7 @@ > > # SPDX-License-Identifier: BSD-3-Clause-Clear > > config ATH12K > > tristate "Qualcomm Technologies Wi-Fi 7 support (ath12k)" > > - depends on MAC80211 && HAS_DMA && PCI > > + depends on MAC80211 && HAS_DMA && PCI && PCIEASPM > > As you point out in patch 1/8, PCIEASPM is protected by EXPERT. > > Won't this prevent the driver from being built (or even showing up in > menuconfig) if EXPERT is not enabled? It doesn't work that way, PCIEASPM defaults to y: $ sed -i -e 's|CONFIG_PCIEASPM=y|CONFIG_PCIEASPM=n|g' .config && make oldconfig && grep -e 'CONFIG_EXPERT ' -e 'CONFIG_PCIEASPM=' .config # # configuration written to .config # # CONFIG_EXPERT is not set CONFIG_PCIEASPM=y > Should we consider having a separate CONFIG item that is used to protect just > the PCI ASPM interfaces? And then we could split out the ath12k_pci_aspm > functions into a separate file that is conditionally built based upon that > config item? > > Or am I too paranoid since everyone enables EXPERT? One just cannot control PCIEASPM value if EXPERT is not set. ASPM is expected to be enabled, or "experts" get to keep the pieces. -- i.
On 8/26/2025 9:00 AM, Ilpo Järvinen wrote: > On Tue, 26 Aug 2025, Jeff Johnson wrote: > >> On 8/25/2025 10:44 AM, Manivannan Sadhasivam via B4 Relay wrote: >>> --- a/drivers/net/wireless/ath/ath12k/Kconfig >>> +++ b/drivers/net/wireless/ath/ath12k/Kconfig >>> @@ -1,7 +1,7 @@ >>> # SPDX-License-Identifier: BSD-3-Clause-Clear >>> config ATH12K >>> tristate "Qualcomm Technologies Wi-Fi 7 support (ath12k)" >>> - depends on MAC80211 && HAS_DMA && PCI >>> + depends on MAC80211 && HAS_DMA && PCI && PCIEASPM >> >> As you point out in patch 1/8, PCIEASPM is protected by EXPERT. >> >> Won't this prevent the driver from being built (or even showing up in >> menuconfig) if EXPERT is not enabled? > > It doesn't work that way, PCIEASPM defaults to y: > > $ sed -i -e 's|CONFIG_PCIEASPM=y|CONFIG_PCIEASPM=n|g' .config && make oldconfig && grep -e 'CONFIG_EXPERT ' -e 'CONFIG_PCIEASPM=' .config > # > # configuration written to .config > # > # CONFIG_EXPERT is not set > CONFIG_PCIEASPM=y > >> Should we consider having a separate CONFIG item that is used to protect just >> the PCI ASPM interfaces? And then we could split out the ath12k_pci_aspm >> functions into a separate file that is conditionally built based upon that >> config item? >> >> Or am I too paranoid since everyone enables EXPERT? > > One just cannot control PCIEASPM value if EXPERT is not set. ASPM is > expected to be enabled, or "experts" get to keep the pieces. > Thanks for the clarification. I now have no issues with the ath driver patches. /jeff
© 2016 - 2025 Red Hat, Inc.