Skip to content

PCI: dwc: Avoid full EP cleanup on PERST#

Manikanta Maddireddy linux-pci linux-tegra lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 2 repliesIn review
  2. v23 patches 0 repliesSuperseded
  3. v13 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- Rebase onto the current PCI main-based patch stack.
- No code changes to patches 1-3 compared with v2.
- Add patch 4 to require PCI_ENDPOINT for the pci_epc_linkdown() call and fix the CONFIG_PCI_ENDPOINT=n build failure reported by the kernel test robot.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4PCI: dwc: Reuse Endpoint resources after fundamental resetdrivers/pci/controller/dwc/pcie-designware-ep.c drivers/pci/controller/dwc/pcie-designware.h+108 -420 replies
2/4PCI: tegra194: Avoid full Endpoint reinit on PERST#drivers/pci/controller/dwc/pcie-tegra194.c+0 -10 replies
3/4PCI: tegra194: Notify Endpoint functions on PERST# assertdrivers/pci/controller/dwc/pcie-tegra194.c+3 -00 replies
4/4PCI: tegra194: Add PCI_ENDPOINT dependencydrivers/pci/controller/dwc/Kconfig+1 -02 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/4] PCI: dwc: Avoid full EP cleanup on PERST#

This series avoids repeating full DWC Endpoint software resource cleanup and initialization on every PERST# cycle while still restoring reset-lost hardware state on the following PERST# deassertion.

The current Tegra194/234 Endpoint flow runs the full DWC EP cleanup/init sequence for each PERST# cycle. The allocation bitmaps, outbound-address array and per-function descriptors already have allocation guards and can be reused. Repeated full cleanup/init also removes and recreates debugfs entries and unregisters and reprobes eDMA where present; eDMA detection allocates managed linked-list memory retained until device detach.

Patch 1 folds initial setup and reset recovery into the existing dw_pcie_ep_init_registers() API. It tracks successful resource setup and uses a private helper to restore reset-lost registers on subsequent calls. After hardware resets the iATU, cached outbound mapping state is reset so stale bookkeeping does not hide available windows. This does not disable or unmap live hardware windows.

Patch 2 removes the full DWC EP cleanup from Tegra PERST# deassertion, allowing the existing initialization API to retain software resources and restore registers. Patch 3 notifies EPFs of link down before powering off the controller on PERST# assertion, allowing their callbacks to quiesce work. It calls pci_epc_linkdown() directly to avoid the DWC linkdown helper's DBI register reinitialization after REFCLK may have disappeared. EPF callbacks can still access MMIO; the notification is not a guarantee of register-free execution.

Patch 4 requires PCI_ENDPOINT for the Tegra194 PCIe driver because the PERST# assertion handler now directly calls pci_epc_linkdown(), which has no stub when endpoint support is disabled. This fixes the build failure reported by the kernel test robot.

Hardware-dependent EPF deinitialization remains in the PERST# deassert path where REFCLK is available and core reset has been deasserted.

This series is rebased onto the current PCI main-based patch stack, after the DWC register-field cleanup and Tegra Endpoint/Root Port corner-case fixes. The base commit is recorded below.

Changes in v3:
- Rebase onto the current PCI main-based patch stack.
- No code changes to patches 1-3 compared with v2.
- Add patch 4 to require PCI_ENDPOINT for the pci_epc_linkdown() call and fix the CONFIG_PCI_ENDPOINT=n build failure reported by the kernel test robot.

Changes in v2:
- Rename the outbound helper to dw_pcie_ep_reset_outbound_state() and clarify that it invalidates software state after hardware reset rather than disabling live iATU mappings.
- Fold init/reinit selection into dw_pcie_ep_init_registers(). Remove the separate init-or-reinit API and keep register restoration private.
- Document the reset and quiescence prerequisites and retain full initialization after dw_pcie_ep_cleanup() clears the resource-state flag.
- Clarify which resources are retained and avoid implying that the existing guarded allocations were repeated on every reset.
- Keep Tegra's existing initialization call; only remove per-reset cleanup.
- Narrow the linkdown notification's safety claim and remove unrelated pointer cleanup and teardown discussion from patch 3.
- Reword the resource-lifetime explanations in patches 1 and 2.

Validation reported with v2 (patches 1-3 are unchanged):
- ARM64 compilation of the DWC EP, host, core and Tegra objects passed.
- Per-patch checkpatch and whitespace checks passed.
- Verified Endpoint reset sequence multiple times.
- Verified ./pci_endpoint_test tests after Endpoint reset sequence.

v2: https://lore.kernel.org/linux-pci/[email protected]/

v1: https://lore.kernel.org/linux-pci/[email protected]/

Manikanta Maddireddy (4):
PCI: dwc: Reuse Endpoint resources after fundamental reset
PCI: tegra194: Avoid full Endpoint reinit on PERST#
PCI: tegra194: Notify Endpoint functions on PERST# assert
PCI: tegra194: Add PCI_ENDPOINT dependency

 drivers/pci/controller/dwc/Kconfig            |   1 +
 .../pci/controller/dwc/pcie-designware-ep.c   | 149 +++++++++++++-----
 drivers/pci/controller/dwc/pcie-designware.h  |   1 +
 drivers/pci/controller/dwc/pcie-tegra194.c    |   4 +-
 4 files changed, 112 insertions(+), 43 deletions(-)

base-commit: 0012b353452613344db3292f17c69ea512344949

Signature · 1 line
2.34.1