PCI: tegra194: Clean up the exit path for Endpoint mode

Clean up the exit path during .remove() and .shutdown() calls when in
Endpoint mode.

Link: https://lore.kernel.org/r/20220721142052.25971-14-vidyas@nvidia.com
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Vidya Sagar 2022-07-21 19:50:49 +05:30 committed by Bjorn Helgaas
parent 4fb8e46c1b
commit bb617cbd81

View File

@ -2145,12 +2145,18 @@ static int tegra_pcie_dw_remove(struct platform_device *pdev)
{ {
struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev); struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev);
if (!pcie->link_state) if (pcie->mode == DW_PCIE_RC_TYPE) {
return 0; if (!pcie->link_state)
return 0;
debugfs_remove_recursive(pcie->debugfs);
tegra_pcie_deinit_controller(pcie);
pm_runtime_put_sync(pcie->dev);
} else {
disable_irq(pcie->pex_rst_irq);
pex_ep_event_pex_rst_assert(pcie);
}
debugfs_remove_recursive(pcie->debugfs);
tegra_pcie_deinit_controller(pcie);
pm_runtime_put_sync(pcie->dev);
pm_runtime_disable(pcie->dev); pm_runtime_disable(pcie->dev);
tegra_bpmp_put(pcie->bpmp); tegra_bpmp_put(pcie->bpmp);
if (pcie->pex_refclk_sel_gpiod) if (pcie->pex_refclk_sel_gpiod)
@ -2164,6 +2170,11 @@ static int tegra_pcie_dw_suspend_late(struct device *dev)
struct tegra_pcie_dw *pcie = dev_get_drvdata(dev); struct tegra_pcie_dw *pcie = dev_get_drvdata(dev);
u32 val; u32 val;
if (pcie->mode == DW_PCIE_EP_TYPE) {
dev_err(dev, "Failed to Suspend as Tegra PCIe is in EP mode\n");
return -EPERM;
}
if (!pcie->link_state) if (!pcie->link_state)
return 0; return 0;
@ -2251,18 +2262,24 @@ static void tegra_pcie_dw_shutdown(struct platform_device *pdev)
{ {
struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev); struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev);
if (!pcie->link_state) if (pcie->mode == DW_PCIE_RC_TYPE) {
return; if (!pcie->link_state)
return;
debugfs_remove_recursive(pcie->debugfs); debugfs_remove_recursive(pcie->debugfs);
tegra_pcie_downstream_dev_to_D0(pcie); tegra_pcie_downstream_dev_to_D0(pcie);
disable_irq(pcie->pci.pp.irq); disable_irq(pcie->pci.pp.irq);
if (IS_ENABLED(CONFIG_PCI_MSI)) if (IS_ENABLED(CONFIG_PCI_MSI))
disable_irq(pcie->pci.pp.msi_irq); disable_irq(pcie->pci.pp.msi_irq);
tegra_pcie_dw_pme_turnoff(pcie); tegra_pcie_dw_pme_turnoff(pcie);
tegra_pcie_unconfig_controller(pcie); tegra_pcie_unconfig_controller(pcie);
pm_runtime_put_sync(pcie->dev);
} else {
disable_irq(pcie->pex_rst_irq);
pex_ep_event_pex_rst_assert(pcie);
}
} }
static const struct tegra_pcie_dw_of_data tegra_pcie_dw_rc_of_data = { static const struct tegra_pcie_dw_of_data tegra_pcie_dw_rc_of_data = {