Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v1] PCI: dwc: Add force_l2 flag for platforms requiring L2 entry without D3cold
@ 2026-07-06  2:47 hongxing.zhu
  2026-07-06  2:56 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: hongxing.zhu @ 2026-07-06  2:47 UTC (permalink / raw)
  To: frank.li, jingoohan1, l.stach, lpieralisi, kwilczynski, mani,
	robh, bhelgaas, s.hauer, kernel, festevam
  Cc: linux-pci, linux-arm-kernel, imx, linux-kernel, Richard Zhu

From: Richard Zhu <hongxing.zhu@nxp.com>

Some platforms like i.MX have their PCIe RC controllers powered off
during system suspend, requiring full re-initialization on resume.
These platforms need to enter L2 state to properly notify endpoints
before power loss, even when D3cold is not supported.

Add a force_l2 flag to allow platform drivers to request L2 entry
during suspend regardless of D3cold capability, and enable it for
i.MX PCIe controllers.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
 drivers/pci/controller/dwc/pci-imx6.c             | 5 +++++
 drivers/pci/controller/dwc/pcie-designware-host.c | 8 ++++++--
 drivers/pci/controller/dwc/pcie-designware.h      | 5 +++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index f55a68f60eea9..ea0b4eb03c1d0 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1966,6 +1966,11 @@ static int imx_pcie_probe(struct platform_device *pdev)
 		 */
 		imx_pcie_add_lut_by_rid(imx_pcie, 0);
 	} else {
+		/*
+		 * i.MX RC is powered off during suspend, force L2 entry to
+		 * ensure proper endpoint notification before power loss.
+		 */
+		pci->pp.force_l2 = true;
 		if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_SKIP_L23_READY))
 			pci->pp.skip_l23_ready = true;
 		if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_KEEP_MSI_CAP))
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 06722259d2e37..e3f022d2d453a 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -1222,14 +1222,18 @@ static int dw_pcie_pme_turn_off(struct dw_pcie *pci)
 
 int dw_pcie_suspend_noirq(struct dw_pcie *pci)
 {
-	bool pme_capable = false;
+	bool d3cold, pme_capable = false;
 	int ret = 0;
 	u32 val;
 
 	if (!dw_pcie_link_up(pci))
 		goto stop_link;
 
-	if (!pci_host_common_d3cold_possible(pci->pp.bridge, &pme_capable))
+	d3cold = pci_host_common_d3cold_possible(pci->pp.bridge, &pme_capable);
+	/*
+	 * Enter L2 if D3cold is possible or platform requires forced L2 entry
+	 */
+	if (!d3cold && !pci->pp.force_l2)
 		return 0;
 
 	if (pci->pp.ops->pme_turn_off) {
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index de4b245b1758c..5e88459e0cfa0 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -471,6 +471,11 @@ struct dw_pcie_rp {
 	bool			native_ecam;
 	bool                    skip_l23_ready;
 	bool			skip_pwrctrl_off;
+	/*
+	 * Force L2 entry even if D3cold not possible (e.g., when RC loses
+	 * power).
+	 */
+	bool                    force_l2;
 };
 
 struct dw_pcie_ep_ops {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-06  2:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  2:47 [PATCH v1] PCI: dwc: Add force_l2 flag for platforms requiring L2 entry without D3cold hongxing.zhu
2026-07-06  2:56 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox