Skip to content

Commit 570d771

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI: dwc: ep: Introduce dw_pcie_ep_cleanup() API for drivers supporting PERST#
For DWC glue drivers supporting PERST# (currently Qcom and Tegra194), some of the DWC resources like eDMA should be cleaned up during the PERST# assert time. So let's introduce a dw_pcie_ep_cleanup() API that could be called by these drivers to cleanup the DWC specific resources. Currently, it just removes eDMA. Closes: https://lore.kernel.org/linux-pci/ZWYmX8Y%2F7Q9WMxES@x1-carbon Link: https://lore.kernel.org/linux-pci/[email protected] Reported-by: Niklas Cassel <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent c8682a3 commit 570d771

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,22 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
619619
return 0;
620620
}
621621

622+
/**
623+
* dw_pcie_ep_cleanup - Cleanup DWC EP resources after fundamental reset
624+
* @ep: DWC EP device
625+
*
626+
* Cleans up the DWC EP specific resources like eDMA etc... after fundamental
627+
* reset like PERST#. Note that this API is only applicable for drivers
628+
* supporting PERST# or any other methods of fundamental reset.
629+
*/
630+
void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
631+
{
632+
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
633+
634+
dw_pcie_edma_remove(pci);
635+
}
636+
EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup);
637+
622638
/**
623639
* dw_pcie_ep_deinit - Deinitialize the endpoint device
624640
* @ep: DWC EP device
@@ -628,10 +644,9 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
628644
*/
629645
void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
630646
{
631-
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
632647
struct pci_epc *epc = ep->epc;
633648

634-
dw_pcie_edma_remove(pci);
649+
dw_pcie_ep_cleanup(ep);
635650

636651
pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem,
637652
epc->mem->window.page_size);

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep);
672672
int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep);
673673
void dw_pcie_ep_init_notify(struct dw_pcie_ep *ep);
674674
void dw_pcie_ep_deinit(struct dw_pcie_ep *ep);
675+
void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep);
675676
int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no);
676677
int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
677678
u8 interrupt_num);
@@ -705,6 +706,10 @@ static inline void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
705706
{
706707
}
707708

709+
static inline void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
710+
{
711+
}
712+
708713
static inline int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no)
709714
{
710715
return 0;

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ static void qcom_pcie_perst_assert(struct dw_pcie *pci)
507507
return;
508508
}
509509

510+
dw_pcie_ep_cleanup(&pci->ep);
510511
qcom_pcie_disable_resources(pcie_ep);
511512
pcie_ep->link_status = QCOM_PCIE_EP_LINK_DISABLED;
512513
}

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,8 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)
17151715
if (ret)
17161716
dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret);
17171717

1718+
dw_pcie_ep_cleanup(&pcie->pci.ep);
1719+
17181720
reset_control_assert(pcie->core_rst);
17191721

17201722
tegra_pcie_disable_phy(pcie);

0 commit comments

Comments
 (0)