linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan+linaro@kernel.org>
To: Bjorn Andersson <andersson@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>
Cc: "Konrad Dybcio" <konrad.dybcio@linaro.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Johan Hovold" <johan+linaro@kernel.org>
Subject: [RFC 08/10] PCI: qcom: Add support for disabling ASPM L0s in devicetree
Date: Mon, 12 Feb 2024 17:50:41 +0100	[thread overview]
Message-ID: <20240212165043.26961-9-johan+linaro@kernel.org> (raw)
In-Reply-To: <20240212165043.26961-1-johan+linaro@kernel.org>

A recent commit started enabling ASPM unconditionally when the hardware
claims to support it. This triggers Correctable Errors for some PCIe
devices on machines like the Lenovo ThinkPad X13s, which could indicate
an incomplete driver ASPM implementation or that the hardware does in
fact not support L0s.

Add support for disabling ASPM L0s in the devicetree when it is not
supported on a particular machine and controller.

Note that only the 1.9.0 ops enable ASPM currently.

Fixes: a9a023c05697 ("PCI: qcom: Add support for disabling ASPM L0s in devicetree")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/pci/controller/dwc/pcie-qcom.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index 2455decc574a..071741b81644 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -273,6 +273,25 @@ static int qcom_pcie_start_link(struct dw_pcie *pci)
 	return 0;
 }
 
+static void qcom_pcie_clear_aspm_l0s(struct dw_pcie *pci)
+{
+	u16 offset;
+	u32 val;
+
+	if (!of_property_read_bool(pci->dev->of_node, "aspm-no-l0s"))
+		return;
+
+	offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
+
+	dw_pcie_dbi_ro_wr_en(pci);
+
+	val = readl(pci->dbi_base + offset + PCI_EXP_LNKCAP);
+	val &= ~PCI_EXP_LNKCAP_ASPM_L0S;
+	writel(val, pci->dbi_base + offset + PCI_EXP_LNKCAP);
+
+	dw_pcie_dbi_ro_wr_dis(pci);
+}
+
 static void qcom_pcie_clear_hpc(struct dw_pcie *pci)
 {
 	u16 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
@@ -962,6 +981,7 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)
 
 static int qcom_pcie_post_init_2_7_0(struct qcom_pcie *pcie)
 {
+	qcom_pcie_clear_aspm_l0s(pcie->pci);
 	qcom_pcie_clear_hpc(pcie->pci);
 
 	return 0;
-- 
2.43.0


  parent reply	other threads:[~2024-02-12 16:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 16:50 [PATCH 00/10] arm64: dts: qcom: sc8280xp: enable GICv3 ITS for PCIe Johan Hovold
2024-02-12 16:50 ` [PATCH 01/10] dt-bindings: PCI: qcom: Allow 'required-opps' Johan Hovold
2024-02-14 11:57   ` Krzysztof Kozlowski
2024-02-14 11:57   ` Krzysztof Kozlowski
2024-02-12 16:50 ` [PATCH 02/10] dt-bindings: PCI: qcom: Do not require 'msi-map-mask' Johan Hovold
2024-02-14 12:01   ` Krzysztof Kozlowski
2024-02-14 12:54     ` Johan Hovold
2024-02-14 13:38       ` Krzysztof Kozlowski
2024-02-16 16:54         ` Manivannan Sadhasivam
2024-02-20  7:41           ` Johan Hovold
2024-02-20  8:42             ` Johan Hovold
2024-02-21  5:26             ` Manivannan Sadhasivam
2024-02-21 10:30               ` Johan Hovold
2024-02-22  3:53                 ` Manivannan Sadhasivam
2024-02-12 16:50 ` [PATCH 03/10] arm64: dts: qcom: sc8280xp: add missing PCIe minimum OPP Johan Hovold
2024-02-12 16:50 ` [PATCH 04/10] arm64: dts: qcom: sc8280xp-crd: limit pcie4 link speed Johan Hovold
2024-02-15 20:47   ` Konrad Dybcio
2024-02-16  7:12     ` Johan Hovold
2024-02-16 12:04       ` Johan Hovold
2024-02-12 16:50 ` [PATCH 05/10] arm64: dts: qcom: sc8280xp-x13s: " Johan Hovold
2024-02-12 16:50 ` [PATCH 06/10] arm64: dts: qcom: sc8280xp: enable GICv3 ITS for PCIe Johan Hovold
2024-02-15 20:50   ` Konrad Dybcio
2024-02-12 16:50 ` [RFC 07/10] dt-bindings: PCI: qcom: Allow 'aspm-no-l0s' Johan Hovold
2024-02-12 16:50 ` Johan Hovold [this message]
2024-02-12 19:34   ` [RFC 08/10] PCI: qcom: Add support for disabling ASPM L0s in devicetree Bjorn Helgaas
2024-02-12 20:21     ` Johan Hovold
2024-02-12 16:50 ` [RFC 09/10] arm64: dts: qcom: sc8280xp-crd: disable ASPM L0s for NVMe Johan Hovold
2024-02-12 16:50 ` [PATCH 10/10] arm64: dts: qcom: sc8280xp-x13s: disable ASPM L0s for Wi-Fi Johan Hovold
2024-02-14  6:35 ` [PATCH 00/10] arm64: dts: qcom: sc8280xp: enable GICv3 ITS for PCIe Manivannan Sadhasivam
2024-02-14 11:09   ` Johan Hovold
2024-02-16 14:54     ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240212165043.26961-9-johan+linaro@kernel.org \
    --to=johan+linaro@kernel.org \
    --cc=andersson@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kw@linux.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).