[PATCH 3/3] PCI: tegra194: Notify Endpoint functions on PERST# assert

From: Manikanta Maddireddy

Date: Wed Sep 23 2026 - 03:35:52 EST


Tegra Endpoint mode powers the controller down when the host asserts
PERST#. EPF drivers must be told about link down before that happens,
otherwise remove while PERST# is asserted can free EPC resources while
EPF work is still active.

Use pci_epc_linkdown() directly in the PERST# assert path. It is a
software-only EPF notification and avoids dw_pcie_ep_linkdown(), which
reinitializes non-sticky DWC registers and touches DBI while the host
REFCLK may be disappearing.

Keep pci_epc_deinit_notify() in the PERST# deassert path, after core
reset is deasserted, because EPF deinit callbacks can clear BARs and
therefore need register access. If remove runs while the controller is
already powered down, pex_ep_event_pex_rst_assert() returns because
ep_state is disabled; that is safe because the link-down notification
was sent at the earlier PERST# assert.

The final dw_pcie_ep_deinit() does not require Tegra register access
today: Tegra uses its own MSI-X address-match window instead of the
DWC MSI iATU, and the supported DTs do not register a DWC eDMA device.

Signed-off-by: Manikanta Maddireddy <mmaddireddy@xxxxxxxxxx>
---
drivers/pci/controller/dwc/pcie-tegra194.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index dd3f4c30ba52..3e9d46850a78 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -1724,6 +1724,7 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)

static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)
{
+ struct dw_pcie_ep *ep = &pcie->pci.ep;
u32 val;
int ret;

@@ -1745,6 +1746,8 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)
if (ret)
dev_info(pcie->dev, "LTSSM state: 0x%x detect timeout: %d\n", val, ret);

+ pci_epc_linkdown(ep->epc);
+
/*
* Deassert LTSSM state to stop the state toggling between
* Polling and Detect.
@@ -1913,7 +1916,7 @@ static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie)
}

/* Perform cleanup that requires refclk and core reset deasserted */
- pci_epc_deinit_notify(pcie->pci.ep.epc);
+ pci_epc_deinit_notify(ep->epc);

val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
val &= ~PORT_LOGIC_SPEED_CHANGE;
--
2.34.1