From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C4871EFF9B; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; cv=none; b=u0tdjV1IQ/PJc+akc56/YtQGW5Tfs/CScHThN21/KHvidZHAds9Z/71EwoSCk2dtNep51czMZOId0XdLRkKJBd8odwlhERcTji5j8rtEQbNkAfwTGAYU6fgsFsFFEjSE9WrDlXEAa+eqWLqbWldhFgRNPXnQukRHaNKpSdcXxN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; c=relaxed/simple; bh=u+j1MWZrVDMnA0nN2hd703dpVLMQhCSZUL4OYJmX1Iw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EWq0Tt9ffDsz5yUJxC9qZ8PppQBEo/oyHHTjjOej5S+2cbMcLS9kTg4ZvnNtKoqy2hXULZSoo+S26VcEnNs+awKSe/ueoRrQmwiwfmhpSqZltdQSQLOq7BrlgxMS9osyHJF7lVg6oC7uglT1StZ96S5WAv6o4WDMYoaEhT9TwTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JDKkY/D5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JDKkY/D5" Received: by smtp.kernel.org (Postfix) with ESMTPS id 26246C113D0; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=u+j1MWZrVDMnA0nN2hd703dpVLMQhCSZUL4OYJmX1Iw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JDKkY/D5iZoD0kVKUsBTL0e8MYxmuawMMJvAeqNP7YhOQN3wTellFdvhGjMRrI5l5 VN9F09nL7C9t6pODn1tZS5Xc+qAHuVl+iRRnFSXIzuDPLB2CmaawMvpyinbWXQIG9g VMpCFUNfMMishrwV2EF4W4YkL5Jm8C3JJxhcUmSlHvqUo9FFR1n8f/Niqo2fMwAxgZ uAd4GNql8Jhn1Z6THTI2FCQcvtFlMWwSAX1Opawak3KxvDPCkUqdnbMZCuu7wOYFg7 zbbwSGjqDuWGs+7hzMk7pCMaNNsBB1hbpTGIHGD4HvYAQk6JzUbSxH/nuNgtjRqiV7 dR/o39cctmCjw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1481FCA0FE7; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:36 +0530 Subject: [PATCH v2 1/8] PCI/ASPM: Always disable ASPM when driver requests it Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-1-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4409; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=XteWgzQLE4FB1d7fUUtWPfDxXr3Zn7uGZ3PNAO/OJ1o=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEOInbYm5tl5KOPLP0FAuBz7q4CEGOPyc+H8 JnnTv9G2EeJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDgAKCRBVnxHm/pHO 9ZWBB/4v7fVw7cQpZhIlei/tgmZsW671sNE/em0HNodv96mg1pNd6NIEv76mCwcqsQW9WXZzu1P A1Rfn/XV4mJI7DIrfGI80bYvM8hFz5iWdD93TpVpfS9KKTf9BveX3sBJ7CBy7dCdqDqWtMBtxd9 RGoFOQB5Zr5yNNBnUfZ1kP4F3Q2lAvzzOaOqUiTwf1Rb66K3OJidg5WrDX2XVgAxXlbh+s3dqgx rKa605QyAAvQHUpIZTxVYoqBxXpFE1Y0B5sW2TdcGODrN9aR4kT1GoBkuj5pgOyT6bZnXvj9Q09 iUHx/0rrCwBlMdlO4njgBUYwkx4sySg5EXZNY6rLq3wPz9UT X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Ilpo J=C3=A4rvinen PCI core/ASPM service driver allows controlling ASPM state through pci_disable_link_state() API. It was decided earlier (see the Link below), to not allow ASPM changes when OS does not have control over it but only log a warning about the problem 'commit 2add0ec14c25 ("PCI/ASPM: Warn when driver asks to disable ASPM, but we can't do it")'. A number of drivers have added workarounds to force ASPM off with own writes into the Link Control Register (some even with comments explaining why PCI core does not disable it under some circumstances). According to the comments, some drivers require ASPM to be off for reliable operation. Having custom ASPM handling in drivers is problematic because the state kept in the ASPM service driver is not updated by the changes made outside the link state management API. As the first step to address this issue, make pci_disable_link_state() to unconditionally disable ASPM so the motivation for drivers to come up with custom ASPM handling code is eliminated. To fully take advantage of the ASPM handling core provides, the drivers that need to quirk ASPM have to be altered depend on PCIEASPM and the custom ASPM code is removed. This is to be done separately. As PCIEASPM is already behind EXPERT, it should be no problem to limit disabling it for configurations that do not require touching ASPM. Make pci_disable_link_state() function comment to comply kerneldoc formatting while changing the description. Link: https://lore.kernel.org/all/CANUX_P3F5YhbZX3WGU-j1AGpbXb_T9Bis2ErhvKk= FMtDvzatVQ@mail.gmail.com/ Link: https://lore.kernel.org/all/20230511131441.45704-1-ilpo.jarvinen@linu= x.intel.com/ Signed-off-by: Ilpo J=C3=A4rvinen [mani: commit message fixup] Signed-off-by: Manivannan Sadhasivam --- drivers/pci/pcie/aspm.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 919a05b9764791c3cc469c9ada62ba5b2c405118..be9bd272057c3472f3e31dc9568= 340b19d52012a 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1381,16 +1381,23 @@ static int __pci_disable_link_state(struct pci_dev = *pdev, int state, bool locked return -EINVAL; /* * A driver requested that ASPM be disabled on this device, but - * if we don't have permission to manage ASPM (e.g., on ACPI + * if we might not have permission to manage ASPM (e.g., on ACPI * systems we have to observe the FADT ACPI_FADT_NO_ASPM bit and - * the _OSC method), we can't honor that request. Windows has - * a similar mechanism using "PciASPMOptOut", which is also - * ignored in this situation. + * the _OSC method), previously we chose to not honor disable + * request in that case. Windows has a similar mechanism using + * "PciASPMOptOut", which is also ignored in this situation. + * + * Not honoring the requests to disable ASPM, however, led to + * drivers forcing ASPM off on their own. As such changes of ASPM + * state are not tracked by this service driver, the state kept here + * became out of sync. + * + * Therefore, honor ASPM disable requests even when OS does not have + * ASPM control. Plain disable for ASPM is assumed to be slightly + * safer than fully managing it. */ - if (aspm_disabled) { - pci_warn(pdev, "can't disable ASPM; OS doesn't have ASPM control\n"); - return -EPERM; - } + if (aspm_disabled) + pci_warn(pdev, "OS doesn't have ASPM control, disabling ASPM anyway\n"); =20 if (!locked) down_read(&pci_bus_sem); @@ -1417,13 +1424,13 @@ int pci_disable_link_state_locked(struct pci_dev *p= dev, int state) EXPORT_SYMBOL(pci_disable_link_state_locked); =20 /** - * pci_disable_link_state - Disable device's link state, so the link will - * never enter specific states. Note that if the BIOS didn't grant ASPM - * control to the OS, this does nothing because we can't touch the LNKCTL - * register. Returns 0 or a negative errno. - * + * pci_disable_link_state - Disable device's link state * @pdev: PCI device * @state: ASPM link state to disable + * + * Disable device's link state so the link will never enter specific state= s. + * + * Return: 0 or a negative errno */ int pci_disable_link_state(struct pci_dev *pdev, int state) { --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93648303CB2; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; cv=none; b=CyEkENJc2gUAS804p9A1X0YoDk5lbRvJuqHFF7zY4FHfP+KkOs0e3wZ+ykzXYePFDKnxhvv41xWacTTNywPGsued9iutL7HT5vhpl/ZQ8OH9iAQowTU+V918lXpzAIjxPswCwJucJMJ7CCfQqNnb4cUUse5zhpTSzjEebhDrw+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; c=relaxed/simple; bh=ZvlrhCwbVGHwCszHJQ3ZLQ8iRWvKvHB5cHlEHKo+skg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a208tEq0My+wLaB1C5SHfcHkYQWOJNmGvwklMqQX+bTuSmdituNZVpiIkkZJ/+IdQdhxqQ3Y2lL3nPW11dlhntsUjEcBEfkdcji73m/fbVcMW6bffkyChegR8s2nOraspxWDkBWpZdlbcKdGY/qRx6lWh8IipIsmiv1i+Zi7E9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SI4d5GlT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SI4d5GlT" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3734DC4CEF1; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=ZvlrhCwbVGHwCszHJQ3ZLQ8iRWvKvHB5cHlEHKo+skg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SI4d5GlTfUmUduk6M3iXd6lBcDw4xX3b6BB7cMez1lj1aJ651eKSOyt21rEj4Iu+2 BdLpWZu0k083HqMKobSfxXBLUAkNcSVJ9VPY4Qoy6jAybr+IKrrlkOC5L0Ik1KnNf7 wxujP0hXqAoHGoEXO4OTKl3Zc5HpKl65az32oobXSsKEv3w5APwxqP3466KtJ+v0fn ZYaIih0Cbwtq6Lg3v6/swE2VZWsW+0ZYxx4aMnHrebwi6ezSxFi2eVtywbeGoYvYbw XVHsUlBaSWrehrnIj7Wt8/6pzsxZAzzCT5GexV5eGDY5QMolZPTMQZ3+PHHo7IPWWx NEvXDgv6TcJJA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26322CA0EFA; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:37 +0530 Subject: [PATCH v2 2/8] PCI/ASPM: Fix the behavior of pci_enable_link_state*() APIs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-2-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4956; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=ZbX/P/Tjf8pjL7HPByaCkE9n8aYYv5gDRWCzS63i5A4=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEOxJ6aeOqgKi7d2p8e9E6vSn9QgBCPg7H7l AlQQ0hzDaiJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDgAKCRBVnxHm/pHO 9drpB/0XOkzdkNiuiw9s73/6BgGYyTjbWx1OWr9LvaBjBd3ShgAqfHQaoj3hN1DZihUNBW2HXOn tkoQqt2NTgsPPoZ/QNHanSCE30ox/iW/ZWPmC6PPJHcg5kQBw1Iwu4PLVsnNWjBmNbxGTK/oEbM Bj/XCvyaVteO1torMSTAyehBeNLhpvmD8Mn5nM4QF0nFuWIYD9Cfr7w5WJ0Lkhr8D8IehD1lAG2 FonxTNhKNwLS61BZPUUAePAuN0lMqRJFSoiOptS6BwCgyuZbZl4/wyq+hPO8z3nEFFOc2HR4rzm pe+yzOBTli2HXIkl3O8qe26rdBDVsVr3ppSoX9xV0WyYhXAn X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam pci_enable_link_state() and pci_enable_link_state_locked() APIs are supposed to be symmectric with pci_disable_link_state() and pci_disable_link_state_locked() APIs. But unfortunately, they are not symmetric. This behavior was mentioned in the kernel-doc of these APIs: " Clear and set the default device link state..." and "Also note that this does not enable states disabled by pci_disable_link_state()" These APIs won't enable all the states specified by the 'state' parameter, but only enable the ones not previously disabled by the pci_disable_link_state*() APIs. But this behavior doesn't align with the naming of these APIs, as they give the impression that these APIs will enable all the specified states. To resolve this ambiguity, allow these APIs to enable the specified states, regardeless of whether they were previously disabled or not. This is accomplished by clearing the previously disabled states from the 'link::aspm_disable' parameter in __pci_enable_link_state() helper. Also, reword the kernel-doc to reflect this behavior. The current callers of pci_enable_link_state_locked() APIs (vmd and pcie-qcom) did not disable the ASPM states before calling this API. So it is evident that they do not depend on the previous behavior of this API and intend to enable all the specified states. And the other API, pci_enable_link_state() doesn't have a caller for now, but will be used by the 'atheros' WLAN drivers in the subsequent commits. Suggested-by: Ilpo J=C3=A4rvinen Co-developed-by: Krishna Chaitanya Chundru Signed-off-by: Krishna Chaitanya Chundru Signed-off-by: Manivannan Sadhasivam --- drivers/pci/pcie/aspm.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index be9bd272057c3472f3e31dc9568340b19d52012a..fac46113a90c7fac6c97125e6a7= e385045780005 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1459,6 +1459,7 @@ static int __pci_enable_link_state(struct pci_dev *pd= ev, int state, bool locked) down_read(&pci_bus_sem); mutex_lock(&aspm_lock); link->aspm_default =3D pci_calc_aspm_enable_mask(state); + link->aspm_disable &=3D ~state; pcie_config_aspm_link(link, policy_to_aspm_state(link)); =20 link->clkpm_default =3D (state & PCIE_LINK_STATE_CLKPM) ? 1 : 0; @@ -1471,17 +1472,18 @@ static int __pci_enable_link_state(struct pci_dev *= pdev, int state, bool locked) } =20 /** - * pci_enable_link_state - Clear and set the default device link state so = that - * the link may be allowed to enter the specified states. Note that if the - * BIOS didn't grant ASPM control to the OS, this does nothing because we = can't - * touch the LNKCTL register. Also note that this does not enable states - * disabled by pci_disable_link_state(). Return 0 or a negative errno. + * pci_enable_link_state - Enable device's link state + * @pdev: PCI device + * @state: Mask of ASPM link states to enable + * + * Enable device's link state, so the link will enter the specified states. + * Note that if the BIOS didn't grant ASPM control to the OS, this does + * nothing because we can't touch the LNKCTL register. * * Note: Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, = per * PCIe r6.0, sec 5.5.4. * - * @pdev: PCI device - * @state: Mask of ASPM link states to enable + * Return: 0 on success, a negative errno otherwise. */ int pci_enable_link_state(struct pci_dev *pdev, int state) { @@ -1490,19 +1492,20 @@ int pci_enable_link_state(struct pci_dev *pdev, int= state) EXPORT_SYMBOL(pci_enable_link_state); =20 /** - * pci_enable_link_state_locked - Clear and set the default device link st= ate - * so that the link may be allowed to enter the specified states. Note tha= t if - * the BIOS didn't grant ASPM control to the OS, this does nothing because= we - * can't touch the LNKCTL register. Also note that this does not enable st= ates - * disabled by pci_disable_link_state(). Return 0 or a negative errno. + * pci_enable_link_state_locked - Enable device's link state + * @pdev: PCI device + * @state: Mask of ASPM link states to enable + * + * Enable device's link state, so the link will enter the specified states. + * Note that if the BIOS didn't grant ASPM control to the OS, this does + * nothing because we can't touch the LNKCTL register. * * Note: Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, = per * PCIe r6.0, sec 5.5.4. * - * @pdev: PCI device - * @state: Mask of ASPM link states to enable - * * Context: Caller holds pci_bus_sem read lock. + * + * Return: 0 on success, a negative errno otherwise. */ int pci_enable_link_state_locked(struct pci_dev *pdev, int state) { --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 935D03019D2; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; cv=none; b=NU3Bs7KyTX4/fNstDlBamJY2m4hUfvyanR7LtkADd7pvryKWrK5d9IvY6FtJhgmAQ1Ww6wZz3ydswyMduJ7noO/m+U+80FgDcETB2qn4jbMYSpOM9ZfVigfiwvB35fbnrVL+ZBqQSHXxHiwOJJE6GK0gh7RuEcm+UzcV+H4kzwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; c=relaxed/simple; bh=XIKXkwSdpDFgryuO8AscrjzoCScXTyqY2YV5IZIW2eE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RlNZZilskGW7eS4kWv0ORV4wF2ouIEuWvXhNUIuIr/z6XuOCosvRGu7krrA8uCNGGUfMc+K/hkNUkXZ6W7hX6nqFt9hVyqCdFkCBsZUXMY/es5vIKE9J6lzxyMO0wTftEYFZfiVa+odSg+sMGUskq7XrL/AcJeum5pC5BRv7l4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qU3VIkwi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qU3VIkwi" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4151AC19421; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=XIKXkwSdpDFgryuO8AscrjzoCScXTyqY2YV5IZIW2eE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qU3VIkwi9ipzyXAef3IHjOfSkA6fgbg36bhmnZ6ctYJqEONhyVMlhjRj1OLRCXmCl We2AO005UwaSCw0ORnwxjnbO8eC5sKEb/l/jW0cDm6fbEz63phFgsNGsAOE78nVNFS vLOGt8CWmYmxw1yqX5deRc4MORmZsVwRKk8Z8Ur33ptY2rsnhswCd2hYkhcaWXGmNA Tec/KlStxskkAA94AYXo0hgSjDeX+zBclWxT2JqqxfvfyQIXB73wlZgcDwdEnLYr8y N+0z7XVD1Nn1dqtESANyeE7fbm0TNwZUXleBhnkoktx5zpp11Hk5uV0SBTrNYx9hKs WTbBRmbqidnGQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37F01CA0FED; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:38 +0530 Subject: [PATCH v2 3/8] PCI/ASPM: Transition the device to D0 (if required) inside pci_enable_link_state_locked() API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-3-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4214; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=Qjbd70IC+ShOK3ZDf4DRoBiUH5NS5aHCnprLq7DQ7iM=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEPLbdqO2EWRQxfmgtisJzzWpgiy2ZIIPyDr wXo38kcIkeJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDwAKCRBVnxHm/pHO 9Y3zB/9zEs5uWjC3Xrp3WhZFy5crlFwe49xFUi+A+EJpbRJDiMhgTxouJpKvRY/cZvY8DxcuyWq Q6VKk/Q1UWHC054LHzynKwqasTaviVYQgMqMwjJ4C06i9hMSyr/L2Hywarv9Nni8mhUD372eY4O Ry0svyzfWZJplUYBwqnbbhvSYfeX3oN++0ibNInhZ9fFX4dLGMvQUfAj1+EoX7Zk11ND+Z44c7q /34v40Br95YeTKp/FOIwVK8dayq7uZiqEKwRc3AcrXGobv4humuJVCA8HaXe79RalBT9kairD6/ KQbjIRML/SnxYy9jMFN3tTtwmRh5tpXkjm+u8YXE6E7wjWXP X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Both of the current callers of the pci_enable_link_state_locked() API transition the device to D0 before calling. This aligns with the PCIe spec r6.0, sec 5.5.4: "If setting either or both of the enable bits for PCI-PM L1 PM Substates, both ports must be configured as described in this section while in D0." But it looks redundant to let the callers transition the device to D0. So move the logic inside the API and perform D0 transition only if the PCI-PM L1 Substates are getting enabled. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-qcom.c | 5 ----- drivers/pci/controller/vmd.c | 5 ----- drivers/pci/pcie/aspm.c | 22 ++++++++++++++++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controlle= r/dwc/pcie-qcom.c index 294babe1816e4d0c2b2343fe22d89af72afcd6cd..af705d71f72b2b7c3004cbb69cb= d779c637bb22b 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1042,11 +1042,6 @@ static int qcom_pcie_post_init_2_7_0(struct qcom_pci= e *pcie) =20 static int qcom_pcie_enable_aspm(struct pci_dev *pdev, void *userdata) { - /* - * Downstream devices need to be in D0 state before enabling PCI PM - * substates. - */ - pci_set_power_state_locked(pdev, PCI_D0); pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); =20 return 0; diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index b679c7f28f51c13468b60f1e6481a26d5967d4eb..85cfd8cbc6f7ed2730f4f8e5357= d9b90d8906ad3 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -768,11 +768,6 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, v= oid *userdata) pci_info(pdev, "VMD: Default LTR value set by driver\n"); =20 out_state_change: - /* - * Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, per - * PCIe r6.0, sec 5.5.4. - */ - pci_set_power_state_locked(pdev, PCI_D0); pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); return 0; } diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index fac46113a90c7fac6c97125e6a7e385045780005..1243715bc054f859af175143a7f= faef0971f097a 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1480,13 +1480,20 @@ static int __pci_enable_link_state(struct pci_dev *= pdev, int state, bool locked) * Note that if the BIOS didn't grant ASPM control to the OS, this does * nothing because we can't touch the LNKCTL register. * - * Note: Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, = per - * PCIe r6.0, sec 5.5.4. + * Note: The device will be transitioned to D0 state if the PCI-PM L1 Subs= tates + * are getting enabled. * * Return: 0 on success, a negative errno otherwise. */ int pci_enable_link_state(struct pci_dev *pdev, int state) { + /* + * Ensure the device is in D0 before enabling PCI-PM L1 PM Substates, per + * PCIe r6.0, sec 5.5.4. + */ + if (FIELD_GET(PCIE_LINK_STATE_L1_SS_PCIPM, state)) + pci_set_power_state(pdev, PCI_D0); + return __pci_enable_link_state(pdev, state, false); } EXPORT_SYMBOL(pci_enable_link_state); @@ -1500,8 +1507,8 @@ EXPORT_SYMBOL(pci_enable_link_state); * Note that if the BIOS didn't grant ASPM control to the OS, this does * nothing because we can't touch the LNKCTL register. * - * Note: Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, = per - * PCIe r6.0, sec 5.5.4. + * Note: The device will be transitioned to D0 state if the PCI-PM L1 Subs= tates + * are getting enabled. * * Context: Caller holds pci_bus_sem read lock. * @@ -1511,6 +1518,13 @@ int pci_enable_link_state_locked(struct pci_dev *pde= v, int state) { lockdep_assert_held_read(&pci_bus_sem); =20 + /* + * Ensure the device is in D0 before enabling PCI-PM L1 PM Substates, per + * PCIe r6.0, sec 5.5.4. + */ + if (FIELD_GET(PCIE_LINK_STATE_L1_SS_PCIPM, state)) + pci_set_power_state(pdev, PCI_D0); + return __pci_enable_link_state(pdev, state, true); } EXPORT_SYMBOL(pci_enable_link_state_locked); --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 936BA304BBD; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; cv=none; b=ugkT81zo1yuf1q8vYPHpwmm4xWl2QAiUEeu9ISsM0IlM//9uzyK5UHnAri+o3+5Cs6L4q+nE47dzQwpzsJRVkvZ2kViE2sw3bHC7peKqmVbRjd0Z9jdWL2B2EgXDJlH2EyHTr12+RjNdk3mpfPEX9481ckYIeNY8pNigvnw9/mA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; c=relaxed/simple; bh=/VL/puEcwU9JE6/bvQ6RKj2xqu8KqDM0xfb43tkQD9I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O35VSojKfohnDxY+cp3RcFYiR7UPr0rSkygtXAS3aJX5+GidRzGhEUizROYZ+hPZ7otPXs5cajO9/XX7TZ+vvtnRConxeCEbQcmkacv7FtqRNghdIf0AxjoUmlBThhqibSfs+CFZMiPIBSeqlyXXxzkFx9fQm6T8+DNSL2WRsxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lZ5BPOJQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lZ5BPOJQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 506D3C19422; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=/VL/puEcwU9JE6/bvQ6RKj2xqu8KqDM0xfb43tkQD9I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lZ5BPOJQc4SY0eMAd0OTFWvBRepMDTEO+CWEtcEhXckc98ik6kHU1q/wokjGnbQN/ rILsujRc8cREJcoS08NbJ3zMeFKXyq0AtHAmE7cUo7upemiZkxIbCP+GKKXVcZ7Xxh XIXt8Z50W5bumJUKM/kj/jZD1xPyNfwiRjjLg4ZA3WqDG60TebCZYMI2Q/wffQxwTC Lc1nDtkTb1/2GzW+XuwumDFe5NL22u8Eni+R6HuWcIjd5rrtPuHabZfw9hskriibYa aS02jW58X8jhxchWsUEiEtct5LH/GiMa0dEMVmgIUT2xpuwWUvTGbNP9fv9+Z5vsWM mkKVyaSPko6mA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47984CA0FE8; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:39 +0530 Subject: [PATCH v2 4/8] PCI/ASPM: Improve the kernel-doc for pci_disable_link_state*() APIs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-4-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1098; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=Tfz/vnVvMAdBE04yo1wOWEyY0vLu4AnSJ/u3erLU3u0=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEPSRZmDz2JU+1YrKPan8RUFHp8+J+c+0yFz pCiZnYzQ+KJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDwAKCRBVnxHm/pHO 9Q0zB/90j6LoYGJLsGfXcFdL1JD6pFL/6/W6X/cf9fNO+v2sWTL78ffGUtwe7stNZfUljUo1neF FDjmXwhJzoYiJWjDhYxrusOSLBNu7xgvLUtOP79yXhHK8PuJPz8xO2tnjGmWYIaSoCyrcWy3Nrn paqoC+BEneBcCDTBQC7IaNbIkhDpj0X7+Nr9eCr9tFIm0pbg0ZPTApS2sX1C2YCcVUJYc9KsjD/ 80y9wlwfTHK5RTkEOap1Cc37/BChZcfosDtlMkFdeKxu/sBU1Oq+yuiyfij6hNXKjh6PZvtlkzw EcEWa4XsUO6a1YePFDMJnD3+aa2Mb9+elsGN7+ZCei0IViEA X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam Add kernel-doc for pci_disable_link_state_locked() API and fix the kernel-doc for pci_disable_link_state() API. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/pcie/aspm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 1243715bc054f859af175143a7ffaef0971f097a..3c8101023e80d3c0550136f7297= 82c0e0a3e28cf 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1415,6 +1415,17 @@ static int __pci_disable_link_state(struct pci_dev *= pdev, int state, bool locked return 0; } =20 +/** + * pci_disable_link_state_locked - Disable device's link state + * @pdev: PCI device + * @state: ASPM link state to disable + * + * Disable device's link state so the link will never enter specific state= s. + * + * Context: Caller holds pci_bus_sem read lock. + * + * Return: 0 on success, a negative errno otherwise. + */ int pci_disable_link_state_locked(struct pci_dev *pdev, int state) { lockdep_assert_held_read(&pci_bus_sem); --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C599C308F0F; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; cv=none; b=mGGDRyw4gPE7VoKJJ4u+hhCLY9WQlYpSuLX8ErsDC0NBgHl3589fg8erDzVkQfj+faG+9GD4Qnt6NTOes04w4mUiwoF33tUSyhY7242wss0thd+5CRuapEbvSVRqcYAn0Tk/aIX8Mm6vFEXjbselwEV6nRorl7fhMuNKiDaY9cM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; c=relaxed/simple; bh=W2VzOd4LaPPqd03f5mZn4e//pyUDYNDJInaL1ivlSb4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GlP7sVFdxpGX3cGaXMNJcrjZvrtJzvSu6GK0+IyeEVGC2t1kCBzvWT3TgjT6tjVeAXH2P2LtyTRC8u1KzIfKxxqv5x0rcngSTSdBlWC5L35JC1HSdfIC5n0i2FNW1CzoDsG8cwTU6x0C/8r3pk6WS8Rx71tyhYwoqMS7Yt/S3sg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oWvuaw4f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oWvuaw4f" Received: by smtp.kernel.org (Postfix) with ESMTPS id 65332C4AF1A; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=W2VzOd4LaPPqd03f5mZn4e//pyUDYNDJInaL1ivlSb4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=oWvuaw4fY34Fat0zJPLQ7kPHaaOYJgM4O8T3jfYUYUnWgXkCt+zUcyNKGLHfpQFvF YG7iJRa9WRiOm+gC/vpjA0ViELfa9lWuTluGvQYfYB1g0K68p123JM1MFeBXBYmwJl 4cNpEoj0cG0s33COjUZYyctZDye1Q5MymUpE2D+sKkqMKUydBDDoia906G98jJ2aVk RDfleTU7oQE30h0Yzyx6/htVdwrJQU+R+6ddbutX2+7fSa+nk2vc9Ef6Bh2F3yjU3R xCgXZO+sgy/aBi5MDYA5K6o54uQSQuL4/Rg6jGM3If8WfhStHwU99+j5w2XAhvaS4f gw0l+uOKDpXqQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 552F7CA0FE7; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:40 +0530 Subject: [PATCH v2 5/8] PCI/ASPM: Return enabled ASPM states from pcie_aspm_enabled() API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-5-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2836; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=jMfN6qwvopwk5oh/k0Cf9IL8m25slb1JveeGwVNhrME=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEPiwhWp+/PSd/iBSrmb3dl5Tv2stjEC5I9s hxFRCLyDCmJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDwAKCRBVnxHm/pHO 9U8+B/0c1VbCfjh2R58dS1EgS8LhCsvsrwAoexW6nBilgkDlYrlhBMoBaLI9cifrzAIzOEwcpwp NcFXH/cJcNB4HE8+VOkeAosGiDRPAmkzhw0lCs0Zlke9MbptGXuiPFDUt3GmgUZFkni+1PmQiZ6 t6ufSeZOuHr+lb4VOpYPvZuElkBpX9XkBPc2DkTZqNa2qxW6FlpPDQju2PvMuVCv7T7pt2oMDuZ cZ90VmyDcXelHokd348TRdPfCo7jMmed/A1/r531KO5UTv8PLsuSq9Qvt5HkrI2hNPVe0r0BCKj ycJ81OSii5p8Cs+xcBp48q2Q8kYaaB30f/wEOr4w8XM10UxL X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam pcie_aspm_enabled() returns 'pcie_link_state::aspm_enabled' parameter which contains the enabled states. But the API currently returns the 'bool' type which is used by the callers to decide if ASPM is enabled or not. To allow the future callers to also make use of the enabled ASPM states, return the actual type of 'pcie_link_state::aspm_enabled' parameter, 'u32'. Existing callers can still treat the return value as a 'bool' as the C11 standard guarantees the behavior (this API relied on the same behavior before as well). Signed-off-by: Manivannan Sadhasivam --- drivers/pci/pcie/aspm.c | 6 ++++-- include/linux/pci.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 3c8101023e80d3c0550136f729782c0e0a3e28cf..fed44b7cb46e9f34c9ef6d5fa6a= 7b009976cbfdc 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1582,15 +1582,17 @@ module_param_call(policy, pcie_aspm_set_policy, pci= e_aspm_get_policy, NULL, 0644); =20 /** - * pcie_aspm_enabled - Check if PCIe ASPM has been enabled for a device. + * pcie_aspm_enabled - Get the enabled PCIe ASPM states for a device. * @pdev: Target device. * * Relies on the upstream bridge's link_state being valid. The link_state * is deallocated only when the last child of the bridge (i.e., @pdev or a * sibling) is removed, and the caller should be holding a reference to * @pdev, so this should be safe. + * + * Return: Enabled PCIe ASPM states. 0 if ASPM is disabled. */ -bool pcie_aspm_enabled(struct pci_dev *pdev) +u32 pcie_aspm_enabled(struct pci_dev *pdev) { struct pcie_link_state *link =3D pcie_aspm_get_link(pdev); =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index 59876de13860dbe50ee6c207cd57e54f51a11079..6f3c5d6a9a959abefbb69e1165a= ec704da507313 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1851,7 +1851,7 @@ int pci_enable_link_state(struct pci_dev *pdev, int s= tate); int pci_enable_link_state_locked(struct pci_dev *pdev, int state); void pcie_no_aspm(void); bool pcie_aspm_support_enabled(void); -bool pcie_aspm_enabled(struct pci_dev *pdev); +u32 pcie_aspm_enabled(struct pci_dev *pdev); #else static inline int pci_disable_link_state(struct pci_dev *pdev, int state) { return 0; } @@ -1863,7 +1863,7 @@ static inline int pci_enable_link_state_locked(struct= pci_dev *pdev, int state) { return 0; } static inline void pcie_no_aspm(void) { } static inline bool pcie_aspm_support_enabled(void) { return false; } -static inline bool pcie_aspm_enabled(struct pci_dev *pdev) { return false;= } +static inline u32 pcie_aspm_enabled(struct pci_dev *pdev) { return false; } #endif =20 #ifdef CONFIG_HOTPLUG_PCI --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5568308F0E; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; cv=none; b=F2bQN6lC4+DLC8l+ToxfGgNjOVr6kcb6ZCfPB+BypR4gi3IzT0KntRCSfpY6m1CqWhiemKz4kS+/pwBxWYnKX31sDJ1IdulYJKjykdk47FgRPwGbEzVRf9uZuBw3pPYYvIfNy0pEqe6DzsPQwsCFkYd8HjzwleiP9xcgh+tNUV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143890; c=relaxed/simple; bh=5r5CGSyABcYjNsRbD59pnqOF5sW34Z3EZ4rn8nXrc0M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gL+4GaawMn+3N/EDQjRI+QqVmikUUHxrS6K8xcBnKhYy72eRwtX/AlzxeVxywXLvWagrGbAR2dtMDn644bw1Zcc4Gzd41ljqKKgz1GbsvIzEJ+UTq4J+r0oOVFFRVWFkpwdUyZSLBGTGhBKI2369LwaWNhIJy8VII0xJdj+GXJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oskTPZo+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oskTPZo+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6DC7AC4AF48; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=5r5CGSyABcYjNsRbD59pnqOF5sW34Z3EZ4rn8nXrc0M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=oskTPZo+0jBNzrlwS7d+fv+SFAZqEBVpXnhKW0MEsDtXy1abOHC/DnfNHJVc+Cbr5 ZI3mWKFwx2redjvPNhYAejwdAiqx90Mll6Me3bArP+NhQ65plSDDtgQ77SGy5djLK7 xRlFnfJH3AQwKv5y364WGRYmt+ESN2mCoLqYyWApzHW7jF1YIxzO5c5GiY9ddHcIcP KLsNJTPPj3Z/+REQrDzybOPEGwgxOqGQcdIPZRGNEDrUxJAcvRokSON5EcmBGk3Dyv XPETiEQ6OR2fZmZ3Jd3TlHcmvPA7S3Rfc8lIxAyaRgtD2+bTgTYvDdE79xOog0lRed ly90yyROwFP3A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63F2BCA0FED; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:41 +0530 Subject: [PATCH v2 6/8] wifi: ath12k: Use pci_{enable/disable}_link_state() APIs to enable/disable ASPM states Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-6-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam , Qiang Yu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3464; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=YGFWkIzjyhJ7NOe0rjueqTF+ezI7rthYPLb8nbyWY/g=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEPxDoq8Rt3E/gfDSPMFBM6a+hNKg0+2PyCy S0mmGxqoDaJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDwAKCRBVnxHm/pHO 9aizB/9QbdeHisz8JMQZeOvxBOeQqcnLLDlPLGiXOCPkjvsCidqfJpKcjMxM/OvG4l0wcTKibU6 EqsrITqfxgI9G3Gb9W4eJJuDqkzs3AU2QyoupUYB2+pdYlEfH1U+Gb/5JUmZnMb89RDCqJn69qx tAL/BS8Ci5vxcBHQBfx3jpl6+iHzRa9Ok7zj1UfaLdBx8VCSVmTZ4n4cFpAtnTz4jQ38A4NzSRD hydPz+jv0OHoqIYwj9euNkRc2LD0At/ePKUtZB9JucYAEv2mbmzVzzRkqJrXl9fPldon+TB6bA7 0MFdxNivxmcOEH6Louvsx58LBStikkIimvSd+Y+fwaTT5u6i X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam 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_SIL= ICONZ-3 Reported-by: Qiang Yu Signed-off-by: Manivannan Sadhasivam --- 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..789276e1e9c289de7afdbcaf72b= e6410b6ea7385 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/a= th/ath12k/pci.c index c729d5526c753d2b7b7542b6f2a145e71b335a43..29236da231e51ac402e40dd124b= b474b3102e6c8 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) =20 static void ath12k_pci_aspm_disable(struct ath12k_pci *ab_pci) { - struct ath12k_base *ab =3D 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 =3D pcie_aspm_enabled(ab_pci->pdev); =20 - /* 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); =20 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); } =20 static void ath12k_pci_cancel_workqueue(struct ath12k_base *ab) diff --git a/drivers/net/wireless/ath/ath12k/pci.h b/drivers/net/wireless/a= th/ath12k/pci.h index d1ec8aad7f6c3b6f5cbdf8ce57a4106733686521..f3e4e59323036e6251d422b7a2d= 1997811cc3f98 100644 --- a/drivers/net/wireless/ath/ath12k/pci.h +++ b/drivers/net/wireless/ath/ath12k/pci.h @@ -114,7 +114,9 @@ struct ath12k_pci { =20 /* 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; --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E083F3090D2; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143891; cv=none; b=RA0+RqdL/vuT3+1L3Ve5YhX3+Lrf20JiUtpIzLavVsYKDm4bGov+CfQckV0W2qsy30qC3HkEHyOa1/Yq1viAEMrR9CPj53CEDfLxB3j0ayumuyfq9v6Nv0SsinXUm8LQGhZxxR9HXEHs8G/Xo6nfXz3xVOIAUnhC08KldIES6xM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143891; c=relaxed/simple; bh=Wx6W28IBSOPVhur4cAm2KHQeeo345xNGoIygZEGlbK0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mdm79++Zs+FwyaUWGz8DwHzxkgxJ1xa3ZyrOmwX7Id7w/5/sq5jPkYo8XuXxp/L5tV3aUz9nv+Ye655oA4RQfEcGgZYoXDe4rrEedse/oCG73LAtxIui3fh3XRPdTOubc+k/KNhWJ6TM8nVsizVu/nLcj+OWuSwz0fBU8FNPqMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d7jH5bVR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d7jH5bVR" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7C3CFC2BCB3; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=Wx6W28IBSOPVhur4cAm2KHQeeo345xNGoIygZEGlbK0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=d7jH5bVREQJNjPJlorubTT9aOqlxybbHLTU7gQ4Mi2P4aDwkI5MCCetjwC4wbnHXZ 2MJJW1p5PuV6msGH07n34d7IubdR5gu7y8l3p3LlbmoJsw7iY8FpBOF8Gdn6GEqcbW ogGQsHmWxAUrTcw9nsOXcTyJTYPIrpKK5NQzZv6UqjK5/VDToSkoCcPKlEBRCSleYc zognQ8HDpyI4CSwkWwuyR3Jzbnk3h4I+vbMH9ZzCJUHIDApmBCD3HoLMOyquOKynLG GyDhausLLXhR3x3IqKnvWuixY34KyqQAJfjKMGSrwFmX63FvR8/bDVk+xBGvGN7/ww thRLl+kP/qIcg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71E43CA0EED; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:42 +0530 Subject: [PATCH v2 7/8] wifi: ath11k: Use pci_{enable/disable}_link_state() APIs to enable/disable ASPM states Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-7-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3144; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=K8FTwvItCiUnOOZrxrN2h/nq2BvbT+Wy0KtDYhVyhrY=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEPYMGTaSp8NMZfMxZegLgw/ywSID5AZ1Ba+ gsX7ZfIHlSJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDwAKCRBVnxHm/pHO 9UQuB/9rHiAkPXNCloNwt2ZMvvMg2V+yPJgaGgkUtvckx77vEpqrmTqabjua6TM5frI4eUkTZT4 mjQ6L+/s1x51XvU3xRwVXz7LpJzD+6ZPzllkd6bSKTWzHYs2ud/muci1b7D189UPBPHOubDyMJR qRGH7dS6UY9wsodC+1pYXlVtRazVcWN7v8VA6dFzjUTeETBEeuFHdLgTDaP6p8DbuT1Vo1ROaHp nyBCSyoBDKmotIFDmIhAF+2sIazt4Yb+uQs1g8dpBC5nccYDDPmBEI04zyo+qUYHByPpzRzNll2 bePWYZk7FWt403okq5s9prQ8oPpKOoWSFwSiW+XwYorkfvs6 X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam 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. Signed-off-by: Manivannan Sadhasivam --- drivers/net/wireless/ath/ath11k/Kconfig | 2 +- drivers/net/wireless/ath/ath11k/pci.c | 19 +++---------------- drivers/net/wireless/ath/ath11k/pci.h | 3 ++- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/Kconfig b/drivers/net/wireless= /ath/ath11k/Kconfig index 659ef134ef168f5e5ad9a532ccd485d20d8701d5..9e19823fbd1a8d48517dcf1c2e6= 44686f7e0ff57 100644 --- a/drivers/net/wireless/ath/ath11k/Kconfig +++ b/drivers/net/wireless/ath/ath11k/Kconfig @@ -20,7 +20,7 @@ config ATH11K_AHB =20 config ATH11K_PCI tristate "Atheros ath11k PCI support" - depends on ATH11K && PCI + depends on ATH11K && PCI && PCIEASPM select MHI_BUS select QRTR select QRTR_MHI diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/a= th/ath11k/pci.c index d8655badd96d0f4b6946f8af927d878aaa3147ad..94bf5973d146754173d076eebd3= 6580b820dc894 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -586,19 +586,9 @@ static void ath11k_pci_free_region(struct ath11k_pci *= ab_pci) =20 static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) { - struct ath11k_base *ab =3D ab_pci->ab; - - pcie_capability_read_word(ab_pci->pdev, PCI_EXP_LNKCTL, - &ab_pci->link_ctl); - - ath11k_dbg(ab, ATH11K_DBG_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 =3D pcie_aspm_enabled(ab_pci->pdev); =20 - /* 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); =20 set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); } @@ -606,10 +596,7 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci = *ab_pci) static void ath11k_pci_aspm_restore(struct ath11k_pci *ab_pci) { if (test_and_clear_bit(ATH11K_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); } =20 #ifdef CONFIG_DEV_COREDUMP diff --git a/drivers/net/wireless/ath/ath11k/pci.h b/drivers/net/wireless/a= th/ath11k/pci.h index c33c7865145cc666394135e7fd8e10dd4462e5df..fe58ce814aeff1d71b5d6e44ccf= d9d5b3cd9d48d 100644 --- a/drivers/net/wireless/ath/ath11k/pci.h +++ b/drivers/net/wireless/ath/ath11k/pci.h @@ -72,7 +72,8 @@ struct ath11k_pci { =20 /* enum ath11k_pci_flags */ unsigned long flags; - u16 link_ctl; + /* Cached PCIe ASPM states */ + u32 aspm_states; u64 dma_mask; }; =20 --=20 2.45.2 From nobody Fri Oct 3 20:25:47 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEE753090D0; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143891; cv=none; b=dyJRWQdbLGNcYKRqE902VR/W9V7Z5RSm46+Sz/HaYOa2kS7FOzPY17u6B0FbBQtYfZsOJCLahv67KQAaUh1tXtTmN3tpY18kK1JnAk08urd1KQ+VVVD4rZ2srW6QGpyMbJ88h6zwfIZEXXqFHDDtOloVOt/3ozbfURFm4ymM7D0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756143891; c=relaxed/simple; bh=wR8n9PC4Wpobpkagw3KloQik+7kZ3Q16exFMhXd1Als=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hthep2cI7q3uzHuB+MbyjalqoJdIuHBxb2Bk3AU0naUPxCw9YhZVNQlUXluZYXrEEKgpYuV4FD88H6nNJXtuohwBppiSAtVR7zHjV45xLX+vER+fBbyxmYTLPVYNbE/4fKr15xZBQKmbNwRFYKfjCG1Mayeo3lxDOME8V3FSBBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GBcEzqOl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GBcEzqOl" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8D119C2BCB8; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756143890; bh=wR8n9PC4Wpobpkagw3KloQik+7kZ3Q16exFMhXd1Als=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GBcEzqOlJx243XSWJy++JUANDmKo6xXJZnOSU6qMOENYCQaBONFoPdt5a8csOQA9b FauW5o+R2ZcIWpfjlLkn+s58iPLonKAmPczIezwYVSvmu9nB/NIbE9DzLv5xenklcj F3MVZA0vIPll3SXdcjr37Jl40GMrcgo9+P+1nXv/g5k4OVIpVeHTX1dPh92G84R8r5 Y4N5vCsW8lwyIKuMowLSy6XNsRNPERHa51a66bFFVFMbUQTOmkmSnwI1AIev7LzUUe qWWx3PXWbSj6gdoXSR/M6cBewaMT3eHJDqt0dueMtGa//0cCsuOw7CJ4KM9wGYR/Jw KVcXNwrBZXR1w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 803FFCA0FE7; Mon, 25 Aug 2025 17:44:50 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Mon, 25 Aug 2025 23:14:43 +0530 Subject: [PATCH v2 8/8] wifi: ath10k: Use pci_{enable/disable}_link_state() APIs to enable/disable ASPM states Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250825-ath-aspm-fix-v2-8-61b2f2db7d89@oss.qualcomm.com> References: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> In-Reply-To: <20250825-ath-aspm-fix-v2-0-61b2f2db7d89@oss.qualcomm.com> To: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Nirmal Patel , Jonathan Derrick , Jeff Johnson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2981; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=uyS1xPT5jai72N0zPRdwC7Qm7l2NSu7PXBp1orIlTxc=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBorKEPRWN+gOX5AI/H8Qt+I/bU07xvKvOqN3b// wAwlMaWZYSJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaKyhDwAKCRBVnxHm/pHO 9ZvaB/0aBwu3PdJ2Emz8jlL9GAiOxXptrtjecGqLk6v30XEdaVaojuE7OgGSLZEJCUioo/Pr8Rr AhPxQZ8wVvR4Gs3aLlaHHK0yXOlR773NdbR4fjzmmMd2voUct61ZoOf1bMjUV1bfYmsJRAokE4y kLcYOFSsm6gkZgXU+LO+qBUM/F70H1K3cbIRW0jsFKFudESOATJ4xLyL+uTmiUHM4Z2qN/WNaD/ 8dX2TNfTic37YyIHb7q5c0IOzK16nEdKKuI49YQ89jMSGmyoO/6WVNpz6dQ9OniobDFv+qmc1EM lZK49YL/I5S1vBsg/SqO8l8h9ecsqMjPBCqr99TB9C5NnoB5 X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam 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. Signed-off-by: Manivannan Sadhasivam --- drivers/net/wireless/ath/ath10k/Kconfig | 2 +- drivers/net/wireless/ath/ath10k/pci.c | 11 ++++------- drivers/net/wireless/ath/ath10k/pci.h | 5 ++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless= /ath/ath10k/Kconfig index 876aed76583318724e4dab0b537d5c93c77460c6..02f9a78e252b124666edcc2395f= da01d779803f1 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -17,7 +17,7 @@ config ATH10K_CE =20 config ATH10K_PCI tristate "Atheros ath10k PCI support" - depends on ATH10K && PCI + depends on ATH10K && PCI && PCIEASPM help This module adds support for PCIE bus =20 diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/a= th/ath10k/pci.c index 97b49bf4ad80916dd139acd5f5744922317191aa..c11266cf31370abf1218ba08ac3= 44598aa655cff 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1966,9 +1966,7 @@ static int ath10k_pci_hif_start(struct ath10k *ar) ath10k_pci_irq_enable(ar); ath10k_pci_rx_post(ar); =20 - pcie_capability_clear_and_set_word(ar_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - ar_pci->link_ctl & PCI_EXP_LNKCTL_ASPMC); + pci_enable_link_state(ar_pci->pdev, ar_pci->aspm_states); =20 return 0; } @@ -2823,10 +2821,9 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar, =20 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n"); =20 - pcie_capability_read_word(ar_pci->pdev, PCI_EXP_LNKCTL, - &ar_pci->link_ctl); - pcie_capability_clear_word(ar_pci->pdev, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC); + ar_pci->aspm_states =3D pcie_aspm_enabled(ar_pci->pdev); + + pci_disable_link_state(ar_pci->pdev, PCIE_LINK_STATE_ALL); =20 /* * Bring the target up cleanly. diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/a= th/ath10k/pci.h index 4c3f536f2ea1a95a78a0703d1f82d37d52f4b6d4..5f3e5739276f0bb1a14292bb596= b4b5fa34e0acc 100644 --- a/drivers/net/wireless/ath/ath10k/pci.h +++ b/drivers/net/wireless/ath/ath10k/pci.h @@ -128,10 +128,9 @@ struct ath10k_pci { struct timer_list rx_post_retry; =20 /* Due to HW quirks it is recommended to disable ASPM during device - * bootup. To do that the original PCI-E Link Control is stored before - * device bootup is executed and re-programmed later. + * bootup. To do that the ASPM states are saved and re-programmed later. */ - u16 link_ctl; + u32 aspm_states; =20 /* Protects ps_awake and ps_wake_refcount */ spinlock_t ps_lock; --=20 2.45.2