PCI: dwc: ep: Add a generic dw_pcie_ep_linkdown() API to handle Link Down event
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Tue, 30 Apr 2024 06:13:49 +0000 (11:43 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 9 Jul 2024 23:20:18 +0000 (18:20 -0500)
commit867ab111b2420ca97e9156ad1e186d2face5c62c
treeafb0636e686de33a297fd04baea3fbe72ee0e542
parente1a4ec1a9520bf048a7ee09f7f7a82b1d44750ac
PCI: dwc: ep: Add a generic dw_pcie_ep_linkdown() API to handle Link Down event

Per PCIe r6.0, sec 5.2, a Link Down event can happen under any of the
following circumstances:

  1. Fundamental/Hot reset
  2. Link disable transmission by upstream component
  3. Moving from L2/L3 to L0

In those cases, Link Down causes some non-sticky DWC registers to lose the
state (like REBAR, etc.), so drivers need to reinitialize them to function
properly once the link comes back again.

This is not a problem for drivers supporting PERST# IRQ, since they can
reinitialize the registers in the PERST# IRQ callback. But for the drivers
not supporting PERST#, there is no way they can reinitialize the registers
other than relying on Link Down IRQ received when the link goes down. So
add a DWC generic API dw_pcie_ep_linkdown() that reinitializes the
non-sticky registers and also notifies the EPF drivers about link going
down.

This API can also be used by the drivers supporting PERST# to handle the
scenario (2) mentioned above.

NOTE: For the sake of code organization, move the dw_pcie_ep_linkup()
definition just above dw_pcie_ep_linkdown().

Link: https://lore.kernel.org/linux-pci/20240430-pci-epf-rework-v4-8-22832d0d456f@linaro.org
Tested-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org>
[bhelgaas: update spec citation]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
drivers/pci/controller/dwc/pcie-designware-ep.c
drivers/pci/controller/dwc/pcie-designware.h