Skip to contentSkip to conversation

PCI/sg2042: Avoid L0s and L1 on Sophgo 2042 PCIe Root Ports

PATCH In review Inochi Amaoto 2 participants 3 messages Jan 9 – Jan 15

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/sg2042: Avoid L0s and L1 on Sophgo 2042 PCIe Root Ports

Since commit f3ac2ff14834 ("PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms") force enable ASPM on all device tree platform, the SG2042 root port breaks as it advertises L0s and L1 capabilities without supporting it.

Override the L0s and L1 Support advertised in Link Capabilities in the LINKCTL register of SG2042 Root Ports, so it doesn't try to enable those states.

Fixes 4e27aca4881a ("riscv: sophgo: dts: add PCIe controllers for SG2042")

---
Change from original patch:
1. use driver to mask the ASPM advertisement

Separate from the folloing patch
- https://lore.kernel.org/all/[email protected]

---
 drivers/pci/controller/cadence/pcie-sg2042.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/pci/controller/cadence/pcie-sg2042.c +11 -0
index 0c50c74d03ee..9c42e05d3c46 100644
@@ -32,6 +32,15 @@ static struct pci_ops sg2042_pcie_child_ops = {
 	.write		= pci_generic_config_write,
 };
 
+static void sg2042_pcie_disable_l0s_l1(struct cdns_pcie *pcie)
+{
+	u32 val;
+
+	val = cdns_pcie_rp_readw(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCTL);
+	val &= ~PCI_EXP_LNKCTL_ASPMC;
+	cdns_pcie_rp_writew(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCTL, val);
+}
+
 static int sg2042_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -68,6 +77,8 @@ static int sg2042_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	sg2042_pcie_disable_l0s_l1(pcie);
+
 	return 0;
 }
 

--
2.52.0

#1 lore raw
Quoted 9 lines · Inochi Amaoto

Since commit f3ac2ff14834 ("PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms") force enable ASPM on all device tree platform, the SG2042 root port breaks as it advertises L0s and L1 capabilities without supporting it.

Override the L0s and L1 Support advertised in Link Capabilities in the LINKCTL register of SG2042 Root Ports, so it doesn't try to enable those states.

You need to disable L0s and L1 capabilities in LNKCAP. LNKCTL change is volatile, since both PCI core and userspace can override it as long as the capabilities are supported.

- Mani

Quoted 45 lines
Fixes 4e27aca4881a ("riscv: sophgo: dts: add PCIe controllers for SG2042")

---
Change from original patch:
1. use driver to mask the ASPM advertisement

Separate from the folloing patch
- https://lore.kernel.org/all/[email protected]

---
 drivers/pci/controller/cadence/pcie-sg2042.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/pci/controller/cadence/pcie-sg2042.c +11 -1
index 0c50c74d03ee..9c42e05d3c46 100644
@@ -32,6 +32,15 @@ static struct pci_ops sg2042_pcie_child_ops = {
 	.write		= pci_generic_config_write,
 };
 
+static void sg2042_pcie_disable_l0s_l1(struct cdns_pcie *pcie)
+{
+	u32 val;
+
+	val = cdns_pcie_rp_readw(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCTL);
+	val &= ~PCI_EXP_LNKCTL_ASPMC;
+	cdns_pcie_rp_writew(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCTL, val);
+}
+
 static int sg2042_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -68,6 +77,8 @@ static int sg2042_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	sg2042_pcie_disable_l0s_l1(pcie);
+
 	return 0;
 }
 
--

2.52.0

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#2 lore raw
Quoted 11 lines · Manivannan Sadhasivam
Quoted 9 lines · Inochi Amaoto

Since commit f3ac2ff14834 ("PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms") force enable ASPM on all device tree platform, the SG2042 root port breaks as it advertises L0s and L1 capabilities without supporting it.

Override the L0s and L1 Support advertised in Link Capabilities in the LINKCTL register of SG2042 Root Ports, so it doesn't try to enable those states.

Quoted 6 lines

You need to disable L0s and L1 capabilities in LNKCAP. LNKCTL change is volatile, since both PCI core and userspace can override it as long as the capabilities are supported.

- Mani

Good to know, I will switch to the LNKCAP.

Regards,
Inochi

Quoted 48 lines
Quoted 45 lines
Fixes 4e27aca4881a ("riscv: sophgo: dts: add PCIe controllers for SG2042")

---
Change from original patch:
1. use driver to mask the ASPM advertisement

Separate from the folloing patch
- https://lore.kernel.org/all/[email protected]

---
 drivers/pci/controller/cadence/pcie-sg2042.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/pci/controller/cadence/pcie-sg2042.c +11 -1
index 0c50c74d03ee..9c42e05d3c46 100644
@@ -32,6 +32,15 @@ static struct pci_ops sg2042_pcie_child_ops = {
 	.write		= pci_generic_config_write,
 };
 
+static void sg2042_pcie_disable_l0s_l1(struct cdns_pcie *pcie)
+{
+	u32 val;
+
+	val = cdns_pcie_rp_readw(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCTL);
+	val &= ~PCI_EXP_LNKCTL_ASPMC;
+	cdns_pcie_rp_writew(pcie, CDNS_PCIE_RP_CAP_OFFSET + PCI_EXP_LNKCTL, val);
+}
+
 static int sg2042_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -68,6 +77,8 @@ static int sg2042_pcie_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	sg2042_pcie_disable_l0s_l1(pcie);
+
 	return 0;
 }
 
--

2.52.0

Signature · 1 line
மணிவண்ணன் சதாசிவம்