From nobody Tue Oct 7 00:22:44 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 1C30F2F509D; Wed, 16 Jul 2025 12:56:24 +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=1752670585; cv=none; b=ZHRUlZb2ora6o2Ed0w/oUZOC1w1SZJ+FFgOacKXhEQdoqw0BDwj0EM7KIDxyNCqGF532fwTdVK9jiQA2k7fe+9jFm/ctqz7slTpzuMEMuzlRv1fDlZD9SWsnNshzG91Q74ooiXXM9vjpxyYHBWzYNitLrwwP1wCdKiv5nYiqCmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752670585; c=relaxed/simple; bh=rEnaOSHuarWZZrIQyIgSW3Uz0dmurmJG6AMt9lUv210=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LxZRQ87U0xNBHzu/84Fu/hq2HTfD6T/FBXthoLnbglift3TYWUmt+5Oqk784cdJV+0NgPQYGSVFFL7lff3rQZxJKqOjHI6SEr0ox53OsHNHrJ6iMS1UsZDxvbPmDpuemLKbydPU3feXcbnfibYBxkKw06bKQgkN1cFplfHe6fqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fbMtuST/; 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="fbMtuST/" Received: by smtp.kernel.org (Postfix) with ESMTPS id B4BDAC4CEF0; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752670584; bh=rEnaOSHuarWZZrIQyIgSW3Uz0dmurmJG6AMt9lUv210=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fbMtuST/B5jar8uVLrujrU4W90MCyIHCCG6Aodb87pjiYFPbNU9FdUsu0SDPmAEjW iu2BVz3bK46RWipKlWOJDq044bWyczyye5Osy1ylkMfcKLgEyuc4qv3TGbmPoLNbn1 UvsAHubKRSoAl7+Ad4Ew2T54j127f2JdIFzcYi7q0QnD5Wazu+daetlD9Rz5nrKTCt 74omMyJgDGvKXfoMraMKyO1P9vqBG87bPC/ESQ9/Vet+apNzl9nLG/fsuRITU2JgZZ lByUmCtW/JbnGiwF7AYS898jOzgptqJcIFh1oFYiED7mCIn7c5H2QslIGIc9UoPFEO jYoo+Wquno4Tw== 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 A0223C83F1B; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 16 Jul 2025 18:26:20 +0530 Subject: [PATCH 1/6] 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: <20250716-ath-aspm-fix-v1-1-dd3e62c1b692@oss.qualcomm.com> References: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> In-Reply-To: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> To: Jeff Johnson , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, Bjorn Helgaas , ilpo.jarvinen@linux.intel.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, Krishna Chaitanya Chundru , 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=txWReBCozsV6K3h+AVzcC8X3bIUcFoipF2Mk8WMybVc=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBod6F2nYK94za955ZeieEJ9Ez0Y2Av6XhQrppa5 ebXFfv0PFmJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaHehdgAKCRBVnxHm/pHO 9SHlB/90r+TtbKMkBbNeCDEVH/Jrf7o4re2piyrrsGCzh0idctS+oYCCeeT7jgzfq7ggdznpMMU mQr0I4UlVAchEjmViMQIM08lI3ua2e6agBSoTRvDOHv7nV14qK//rdbd6R2qvzrr3/Cp0G2XZAP A8w3Zxfv6fi5ggd68SOJj4IywptCrpisEU1IlZqjOAXzWsjWtKSsitJLWhgunEFfCNWymj0y4qz /Rga/kB3tRfYTfyFYxws1/DimAikv81gVwwh3IUwZqY8a0t5Po8SPP34YhBYIhWkGv0iKT/n+Fw RvxtKMfnFTDvKDABbaNKGVchiHyVSO5beEi5Oh6ETnWzwiR8 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 29fcb0689a918f9cb123691e1680de5a1af2c115..ec63880057942cef9ffbf3f67dc= d87ee3d2df17d 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1453,6 +1453,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; @@ -1465,17 +1466,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) { @@ -1484,19 +1486,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 Tue Oct 7 00:22:44 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 1C2A12F509B; Wed, 16 Jul 2025 12:56:24 +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=1752670585; cv=none; b=I3G2qF6BLdcx08pCb4nFKvD89HTT1BaLPMPQ/uDet0qWAHCzqaK35kAyvk0UmS3j2bWNGWMcsweUUDRZnlcrhUWd67dpXFvbJ7fpHOPjt/m1JiDLio+q/WOtcT4QWer5mgRon7RoCatYjXLwj+5/CgNqsNO2zn7ZMWdnCUajbCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752670585; c=relaxed/simple; bh=U4+/0Kn/irzrlmqtgZxjxMU14G54Aznp8RGU4IoJb5I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DEBH1SXK4UPwxl9ONhj8bVdKSsbzQ93e8uwRI067F7fSm/F6o9exXESgNzP1iac++XUhKhP6niFSTW4PvMAgKI26DYfr9Q0xVft6FXynM2cmQKfG1k7qp+IyFCz1dpgnWIujQy+rsir7ZBV31pcq0lLgUF6mno0CNYgKiMaqt58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V2PClDU2; 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="V2PClDU2" Received: by smtp.kernel.org (Postfix) with ESMTPS id C5B09C4CEF6; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752670584; bh=U4+/0Kn/irzrlmqtgZxjxMU14G54Aznp8RGU4IoJb5I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=V2PClDU2jQbChUUrLMEO13Ovau/25TPy5Qs9+Uu24QtGnbF1CfygyYdQ8C/zkQ8zZ 42Tmr5MwhKGU6IonKo5wWFIVxzpj1a0d0RS0vd1P/1XB6Pjhfc3wT7kq19PaCaYdxz GrmoyU7aXJqg7RLgX7QXVXIXTqXW89QRZr6UPZ3huq987SrV6umuyn7/4rb7OqW4sO egPGuoMp4lVUGbMCogYVxP6r5vNPg9DvCf4xrtLUrqpffSX3CQUsUutPd8aY5MpyZo LpTNGpYIQuzXCUxKdWQ9IbXm2xRIUeSPFUADypCZA5PQD2CDo6PfKH2jODRs461jog ZQS7kyA7r5UKQ== 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 B47C8C83F34; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 16 Jul 2025 18:26:21 +0530 Subject: [PATCH 2/6] 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: <20250716-ath-aspm-fix-v1-2-dd3e62c1b692@oss.qualcomm.com> References: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> In-Reply-To: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> To: Jeff Johnson , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, Bjorn Helgaas , ilpo.jarvinen@linux.intel.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, Krishna Chaitanya Chundru , 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=Hi5J0pIF+iWnkMGXfocryMcFDAOXrwL22J4M8mGbdSU=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBod6F2CULXLp8rTJpaJVU7H5c1oqS0BGUk5g7I+ 9t4OEB1veSJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaHehdgAKCRBVnxHm/pHO 9fArB/9FulOSF4tSr+TT1URdaKWzJq1L7LhC7QODyaVsCQBKBBC1uFuFWVGCpMmJpWKVcC1QV7e E3MHNYuim9To+6GoJLEp1Xa5gftbc7lcqYJ3SFfDMAM4UsRu4eaegzWr6t3IayzMolyP3mn9woe UPzil9ZKDZZHbRZP/XDlj8B22yKN4Qvhldr0cpiziVqDqnb4Yjs6UzN/Oddr+66zOWQLhnmLb01 RTniSwmV1Cz4hql1VvETn4DVr1SI+QdHJfPEF3rWQXp34o6LpRm5LfRrKrei+ARJHZW2ZqwmFZm tqJib9vtul6W0+aSZ8Nu0DRIpe2lx1NHo3FmLmdbe1oGkHuA 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 c789e3f856550bcfa1ce09962ba9c086d117de05..204f87607c0bc1ce31299aa5a57= 63b564ddeda29 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1018,11 +1018,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 8df064b62a2ff3e22dd8507a66783ca6c6a8b777..cf11036dd20cbae5d403739b226= 452ce17c4cb7f 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -765,11 +765,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 ec63880057942cef9ffbf3f67dcd87ee3d2df17d..c56553de953c158cf9e8bf54c6b= 358a9a81a2691 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1474,13 +1474,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); @@ -1494,8 +1501,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. * @@ -1505,6 +1512,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 Tue Oct 7 00:22:44 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 3F4052F50B7; Wed, 16 Jul 2025 12:56:25 +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=1752670585; cv=none; b=sa2ayH7W8eQTX+qBR2NHoQfVMAF48gTXBCgNqNOOsQbGz+MvP6ph26TOUfg5qulBQjJjmIm+ZbkTMlNTHHDnBQb4R6g2Miba9ECkIqFzmcXf5BBCvDLsW4TPQe4GwAJ17ZvCZzC0iAEw1EX1O1X+nPegWc/dwdc/5OsxM/Bd6eU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752670585; c=relaxed/simple; bh=49se/cV6QgtAokglmFcczz9Ifzd3nxCW5Sn2n0Qc8cA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i4TXKC2KoaM0c1XFG/IMa2JUVt62alk0ZR5jvurPwuQWQllM7cTsqL75rUqxjeDUNXDa8NZNlCPRFGNbPrVk/zD3YJKCJ+/njhKp7UtDejPynp7kr/19M7Pj0SSAMriZhd36H9aaP0U4tQ9SJmTDYBpcuxjO61XP7J1JShXqLFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XCZIZVf9; 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="XCZIZVf9" Received: by smtp.kernel.org (Postfix) with ESMTPS id D10E7C4CEFB; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752670584; bh=49se/cV6QgtAokglmFcczz9Ifzd3nxCW5Sn2n0Qc8cA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XCZIZVf9F9mujtGMeE7PtbcRfjU3tQrNiCDSFTczH7hroWYYGmokqZT92ngb+i1q/ v/gj4zheOcphI+6GAjWkUFZHt2l8OaOzHClZI9Uyj4+NDipP2PiIOsC8mw3of7zCyZ jLY7+KTVkTZPYpiDiHoRfCevypNUMudP9kGu41K2DqN3jY9Nd/w2Ah1vMGVPctv4QQ Eykmv7NtmyPVV9GE5rmeVoO3UBQcGg/WpS0eI205XYhBPWUoveJiz/HsCko/CGkiY/ r/a/B4mzF/atrEBsylPH9ZbgX5EkkcjKf4/wKwoDrLYj7el3/UMu6/UTyspnMUIXg0 dMvv9ef/AW8kA== 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 C37F4C83F27; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 16 Jul 2025 18:26:22 +0530 Subject: [PATCH 3/6] 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: <20250716-ath-aspm-fix-v1-3-dd3e62c1b692@oss.qualcomm.com> References: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> In-Reply-To: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> To: Jeff Johnson , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, Bjorn Helgaas , ilpo.jarvinen@linux.intel.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, Krishna Chaitanya Chundru , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2156; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=B9VKKJAdfTeTxxxIgX26hLbY56JMsQhRCw6qWnhJsGw=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBod6F2mMxYhWLaZfeExPfHrvfJGSkYizEHM7CpQ 8Qti9q+oi6JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaHehdgAKCRBVnxHm/pHO 9WPGB/9BzzL32x5gdgQQgBO1xt+px2X1J3TuNhPv4s4j0uknjpnIrinkONw0yAA8jblKNU1MM4J 9GO0/n2fXQk42/YjhSyhLrEXhZvnzVqcEj307CJY721C0rbc5QYClC5tNFRRdqlbyanBAXO3a52 mJ0CbY7KO5Wz8pxKZTFN08Hg/YML4Vhbi/1nYriFINdR+J0LJZqrZGkYjx7cYk7rhUpfHMyvfTr 1chKJsI1XoU/K2Z2KOVLGnPe6XWeuRhyds9pEYB+zXYNHntdF4wHgVXfb7dyk/rKrOKx5tU9qDA wlI+s6LmIGwxhla/AZ4BtKrhp/GBffKLWArRkvZhVKCzBB7z 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 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index c56553de953c158cf9e8bf54c6b358a9a81a2691..4d30e894198c40a168fc0362627= 0b361d5124b67 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1409,6 +1409,19 @@ 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 stat= es. + * Note that if the BIOS didn't grant ASPM control to the OS, this does no= thing + * because we can't touch the LNKCTL register. + * + * 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); @@ -1418,13 +1431,15 @@ 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 stat= es. + * Note that if the BIOS didn't grant ASPM control to the OS, this does no= thing + * because we can't touch the LNKCTL register. + * + * Return: 0 on success, a negative errno otherwise. */ int pci_disable_link_state(struct pci_dev *pdev, int state) { --=20 2.45.2 From nobody Tue Oct 7 00:22:44 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 3F38A2F50B2; Wed, 16 Jul 2025 12:56:25 +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=1752670585; cv=none; b=jNfqFItUgkNWeL+sp/ckv+mmkjWby1Kzw18MXIW3OYopsNSMxq6kmOyEETBAfNho5w+tgFDyfy594ZgfJvdNf92wCZXx3kb+dY1GzAosz8hvCxs1fFeN+OHRLKFHUEcOezcKljYpabACscNns8+u+x5WEmJQR2uwd9UMBeL2Bp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752670585; c=relaxed/simple; bh=drejDiiJ9ts2qV7cCSJTnPZpG9F4HUQgt0gkKgAgc0w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CNuL1QjWYj1C36eDSSt7rzvopzK1pBuI6CieR0D9R4GOjZddyfcLW8LZVfwYxemu0aoSvnaoSV4xSlyObActb3Whoo/9p0rNBXFan+pCozz1VqNfCdMTKF0M6W+hlS0knFInn82Khg0gPewuCuIjG6xx9VVREsoA8XfIDtpkYM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=brNdrIUY; 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="brNdrIUY" Received: by smtp.kernel.org (Postfix) with ESMTPS id DE886C4CEFE; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752670585; bh=drejDiiJ9ts2qV7cCSJTnPZpG9F4HUQgt0gkKgAgc0w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=brNdrIUY+X4Awm0NB//QC3qw0/1MD9yeVtBqL7ckQpaifkfz/7uzxF9praCcq4XgJ mTjv6JdgL8OWttnLzYY+zOJB9uX61ClGwOz+KHvk3qNmQOzLIrdR7g70RJZNBM/dP9 Uv4lc6eSBs+yHraHxMT8iSEOqee32E4Vu6lJWlbhIYQkJ8W+NAeOoet15XEDPCxnJs BPa2fVvDwtQtnHS/eSNTQnyTZmpV8tbRMqkkL2IuVU+SYDDzbGt4bE5M36A4sF3yJn jiGOvn6U+Pbjzep44TPN5vbj6M/KivV98SjvQLXT96/O+ivQbaJsfrt2vd6ZsypRlp AMdTzWHtmIs0w== 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 D37B9C83F36; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 16 Jul 2025 18:26:23 +0530 Subject: [PATCH 4/6] 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: <20250716-ath-aspm-fix-v1-4-dd3e62c1b692@oss.qualcomm.com> References: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> In-Reply-To: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> To: Jeff Johnson , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, Bjorn Helgaas , ilpo.jarvinen@linux.intel.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, Krishna Chaitanya Chundru , Manivannan Sadhasivam , Qiang Yu X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2910; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=jdVSR3U+sLC1HJXWHdq7l808ARhICkBRRxwCHagzKUg=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBod6F2cwm9rNB7o0Qyccmj+bb9tc9WqURscRrjJ xczMJxyGDKJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaHehdgAKCRBVnxHm/pHO 9aIBB/sFwHYIZv2Z+23K7BMxH7dAOJUOh+KJF+XOn59WVguQBiXHDW+Wu059LmkTh6M2pkQ7lnP sUi1MLRs6RqEeW3vZ7MaicYC9T2Phmepp1RI8f5rBTrnDw7XVj4LuHM83XRLu9O84b8im+yuf/u oasg+ew5OQdczcVsu17UOoBWwaqNvhF4rIKvdehLzqmq+0YEy85AFSki3P8EXmtgIxJWbp3jefG 146HJzcyMjfPLMK6XXQbiqG9tpK86c/KWlIN68jGAST2Nrf+NJWP6dXdOLEle0TCo8uiftLC/KU ai21GtQ+035HcqquIdi/9xtFbYPHzeX9NfdEK8Vj9W+lPV62 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/ath.h | 14 ++++++++++++++ drivers/net/wireless/ath/ath12k/pci.c | 10 ++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 34654f710d8a1e63f65a47d4602e2035262a4d9e..ef685123b66bf4f41428fec67c1= 967f242a9ef27 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include =20 /* @@ -336,4 +338,16 @@ static inline const char *ath_bus_type_to_string(enum = ath_bus_type bustype) return ath_bus_type_strings[bustype]; } =20 +static inline int ath_pci_aspm_state(u16 lnkctl) +{ + int state =3D 0; + + if (lnkctl & PCI_EXP_LNKCTL_ASPM_L0S) + state |=3D PCIE_LINK_STATE_L0S; + if (lnkctl & PCI_EXP_LNKCTL_ASPM_L1) + state |=3D PCIE_LINK_STATE_L1; + + return state; +} + #endif /* ATH_H */ diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/a= th/ath12k/pci.c index 489d546390fcdab8f615cc9184006a958d9f140a..a5e11509e3ab8faad6638ff78ce= 6a8a5e9c3cbbd 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -16,6 +16,8 @@ #include "mhi.h" #include "debug.h" =20 +#include "../ath.h" + #define ATH12K_PCI_BAR_NUM 0 #define ATH12K_PCI_DMA_MASK 36 =20 @@ -928,8 +930,7 @@ static void ath12k_pci_aspm_disable(struct ath12k_pci *= ab_pci) u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); =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_L0S | PCIE_LINK_STAT= E_L1); =20 set_bit(ATH12K_PCI_ASPM_RESTORE, &ab_pci->flags); } @@ -958,10 +959,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, ath_pci_aspm_state(ab_pci->link_ctl)= ); } =20 static void ath12k_pci_cancel_workqueue(struct ath12k_base *ab) --=20 2.45.2 From nobody Tue Oct 7 00:22:44 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 470B52F5301; Wed, 16 Jul 2025 12:56:25 +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=1752670585; cv=none; b=N9+gZcWGQ/afaqtH2RqgNETbpx1pmHgOjebm8o/MlTxHFD1iPfYvh3VC2AcbROm3nu6H7qStKxCyCbFL2zcne+NpVTYrx6kPvn+pmKjdAY8WK05S25Z6jvL8CojxEkZcGw08OvZOK6kzv3I1gQOxYaFOBzusc5fnaYj1i833eag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752670585; c=relaxed/simple; bh=N7blyqfQuKX3ng2cz062bliqBtPysSE2ISnQjV9aR9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sc3qTGYOKnlXO2U0mJSsSimxQ6Mgwc+NDa8ZG2KAbVgRVj9Jl/wwEl4bUNg17t4sGMzirSzzDnbyPEisZoU5j5ouetPn4DpU7jIvP5yNOX/G1DFxacXaTNSu8XZzdUsMvtT0cW7naJFMqTIJPDD7EIcgGQ8B9gjMR7G+LAZN82c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IITQe2BA; 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="IITQe2BA" Received: by smtp.kernel.org (Postfix) with ESMTPS id EB6A9C116B1; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752670585; bh=N7blyqfQuKX3ng2cz062bliqBtPysSE2ISnQjV9aR9U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=IITQe2BAL2dS1TnBFMJM6SZDIBfJHfyZCSXbLAD86InIqnrYN5urpZHbI8dS0Mjae G3JFESY/3ep/kaQvE+BZrv8YLgTcKhin3zXT9C0xR8p1s2gqc6DQJYG7kPeq2rwloP VaEf24sKxypHJ9Js5pFw0BNSrLHMgv81plA5wV/dYuPxvx7M4O/w6M+0CDqJPvlMu9 555QxOCbU/xMVayngrDdJs1+cGYmQXoYqHYLQpF7mRlxB8fX0YCwhlO9Zz9Bg9MkaU ASipx0soW7lzwJYwhsK+gtnLaFcQ6RYPze0LWAH6CV6s4rXjKb/HHaeFm0jPtdzTdd 40vDKQfAGhYhg== 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 E1EE1C83F34; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 16 Jul 2025 18:26:24 +0530 Subject: [PATCH 5/6] 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: <20250716-ath-aspm-fix-v1-5-dd3e62c1b692@oss.qualcomm.com> References: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> In-Reply-To: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> To: Jeff Johnson , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, Bjorn Helgaas , ilpo.jarvinen@linux.intel.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, Krishna Chaitanya Chundru , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1863; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=kXpW2mQuCN8+CNqdT+kLur7VSEl5MgZkBtsfbPtL7RY=; b=owEBbAGT/pANAwAKAVWfEeb+kc71AcsmYgBod6F22QPsndaD+8odr4XoI0/ocyp1ircoReHgt YGA0cbP6aCJATIEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaHehdgAKCRBVnxHm/pHO 9Sb9B/i3iAtipHaPFAxLp2zZTxGLgKyKliJu5K7gSsTqxmv7SltOMJyZmnTaGZYLk6v3zQnRcg6 sw2o2uIH9fSmM8+4XO79TkWTmnh6trf1HQAgJs02XVm8x90kChSY3mH+1mglMtfm1Z5wZsMFXMD 6d2HdNNBDBi7DvWJnPlv3kjjhOQa6eBwGh9J0tCBghOy2ZOsg27sEwItnHNfsCEpPNpi4zMluiq 3zhfrwOB3g3t8SfYyX+0Zs1X2Rv2MVfl8EahkwZra0x7yV32Ina7XpSomJ1UGz46Atp4b61+BFT FRYW9/TtiB1XC9iicOaEtvo4z7d87s1a+ypf/M1h6fxvkfE= 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/pci.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/a= th/ath11k/pci.c index 78444f8ea15356f1f4c90a496efd52780499bfb2..cec399765e04104ddcfcee5003c= 209e14c7d4ca0 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -19,6 +19,8 @@ #include "pcic.h" #include "qmi.h" =20 +#include "../ath.h" + #define ATH11K_PCI_BAR_NUM 0 #define ATH11K_PCI_DMA_MASK 36 #define ATH11K_PCI_COHERENT_DMA_MASK 32 @@ -597,8 +599,7 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci *= ab_pci) u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); =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_L0S | PCIE_LINK_STAT= E_L1); =20 set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); } @@ -606,10 +607,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, ath_pci_aspm_state(ab_pci->link_ctl)= ); } =20 #ifdef CONFIG_DEV_COREDUMP --=20 2.45.2 From nobody Tue Oct 7 00:22:44 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 6E2872F531C; Wed, 16 Jul 2025 12:56:25 +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=1752670585; cv=none; b=TacyoWtWlVKbxuZHzVpvqqoCJqYRR2HHsUw+m+Z3X+mJ7z3eqHOJNz4ZVs9QaPO2rx6WRzchcKNQM3XQ0K/mKhWi0IUFP36z4xSFQh+B+rdpw5VtWqoCPxom/uHE56tzZMrpM1reWLX0GJWo6+TOQQJq0clToIDoBZFKpXGtK54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752670585; c=relaxed/simple; bh=d5ezahiJEgmQKnKdHKwl1RCHamaJ0esu7vRT109SEbQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=itWBktj8bx7k6yY/qZ2C34AeuDTDnems10QmJmsVsOTkjw1Tp1h0BKxtfjN/88mDp0IK3y+tU4BKiVHl+h2vHABshAs9US+93yATV17jjorDavjBAhw4GYCriAzParKHYbvK/S3nMaL0re+ELjRv1PKKD7VxEalqJlIZ7bUCa0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zjwn+piG; 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="Zjwn+piG" Received: by smtp.kernel.org (Postfix) with ESMTPS id 08C0CC19421; Wed, 16 Jul 2025 12:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752670585; bh=d5ezahiJEgmQKnKdHKwl1RCHamaJ0esu7vRT109SEbQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Zjwn+piGRW4ptJ/z0z/uECdIuQMEStd2Q07dBMlSQJ3syeuKkk9W1IysDQ/1idTk2 pFcHTVlwQYQZqe9s1pj1axXyV2JP97Z1EhuEjol2fdSniYLHSf0u/SSYcMlOt5Saed n0DYy4c8/qPHEw3eUlDF3qzUMYs9dvaDVGec6vtO/ZGk0AktP3oZTUIx42nMtvJ/XM T7SSbSL6HzDVGF53Ni9x2NILo5T0w1LRoyPaAX9el7x3uEvrWh1S28tl3SG0PYUUUv Q3ibcCFPXXQnjxZ/ak+N2438aCO6wUrwqg4eKFha89W/tBOzEaj5r4S7Xp6jVAGDPH 2nYUVc1/IOK+Q== 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 F1AB0C83F22; Wed, 16 Jul 2025 12:56:24 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 16 Jul 2025 18:26:25 +0530 Subject: [PATCH 6/6] 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: <20250716-ath-aspm-fix-v1-6-dd3e62c1b692@oss.qualcomm.com> References: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> In-Reply-To: <20250716-ath-aspm-fix-v1-0-dd3e62c1b692@oss.qualcomm.com> To: Jeff Johnson , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath12k@lists.infradead.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, Bjorn Helgaas , ilpo.jarvinen@linux.intel.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, Krishna Chaitanya Chundru , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1518; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=Fx4ej/EicH41+mIOpWKF1WcnMWq9PYq0rbjy+/KSq0Q=; b=kA0DAAoBVZ8R5v6RzvUByyZiAGh3oXbIxqk80Tgh+RxdditU6/SfcGzUbtEKyagt0528i4qmg okBMwQAAQoAHRYhBGelQyqBSMvYpFgnl1WfEeb+kc71BQJod6F2AAoJEFWfEeb+kc71+zwH/j9g 77XQ+TyQtXbct+iV57W9c8g3ZQmgOtKIHRMLu+mcrcqHfSxz/V/4OcFnyjatqAbs33eteSiCZ55 LoVeVbo3qOjovyINbJXFwgSGgb7MrPELoEBPbwyZvr7H6mp2v1GP3XUzZsi6NwIHjh1J7BQUqHV aDnAaoWlbmAChlKp0tbmRkWVN2LpMwTe6EfcYqrCmz7nBm1x0QLTpGPJkNYzV/HgleNa8aMEQFV eQP3tLVUolrRr8ZS4IJHlOEVQus5Ub4hqfKpnW3BFAvywjtvLCovpSp6Diwn0zkfZ0WLLS5Xk0R 6jeK1WBsuL8Emy0OHC085U9qIOq5psdkZ9ca4Pc= 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/pci.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/a= th/ath10k/pci.c index 1e6d43285138ece619b9d7dc49f113a439e2085d..b20ab535a850ef1f5fe606bd7e7= a230ebcd894c8 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1965,9 +1965,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, ath_pci_aspm_state(ar_pci->link_ctl)); =20 return 0; } @@ -2824,8 +2822,7 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar, =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); + pci_disable_link_state(ar_pci->pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STAT= E_L1); =20 /* * Bring the target up cleanly. --=20 2.45.2