Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions drivers/pci/controller/pcie-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ static const struct hw_info t6050_pciec_hw = {
.no_port_reset = true,
.msimap_by_vector = true,
.mps_timers = true,
.s2idle_hold_domain = true,
};

static const struct of_device_id apple_pcie_of_match[];
Expand Down Expand Up @@ -6634,6 +6635,23 @@ static int apple_pcie_hold_domains(struct apple_pcie *pcie)
return ret;
}

/*
* Pre-suspend policy shared with apple_pcie_prepare(): everything known before
* endpoints suspend, leaving only the domain hold and live link check to noirq.
*/
static bool apple_pcie_can_keep_link(const struct apple_pcie *pcie)
{
if (!READ_ONCE(s2idle_keep_link) || !pm_suspend_no_platform())
return false;
if (!(pcie->kernel_init || pcie->tunnel_cold_init))
return false;
if (pcie->bus_stopped || pcie->resume_failed)
return false;
if (!pcie->power_retained && !pcie->hw->s2idle_hold_domain)
return false;
return true;
}

/*
* In suspend-to-idle ACIO and the router links stay powered, so an up
* tunnel can simply be left running. The functions below keep their state
Expand All @@ -6646,15 +6664,9 @@ static bool apple_pcie_keep_link(struct apple_pcie *pcie)
{
int ret;

if (!READ_ONCE(s2idle_keep_link) || !pm_suspend_no_platform())
return false;
if (!(pcie->kernel_init || pcie->tunnel_cold_init))
return false;
if (pcie->bus_stopped || pcie->resume_failed)
if (!apple_pcie_can_keep_link(pcie))
return false;
if (!pcie->power_retained) {
if (!pcie->hw->s2idle_hold_domain)
return false;
ret = apple_pcie_hold_domains(pcie);
if (ret) {
dev_dbg(pcie->dev, "PCIe-C power domain not held (%d): link not kept\n",
Expand Down Expand Up @@ -6804,7 +6816,7 @@ static int apple_pcie_suspend_noirq(struct device *dev)
if (pcie->cio_prepared)
return apple_pcie_cio_suspend(pcie);
/* The reversed DART link is safe only with retained clocks or native PM. */
if (pcie->cio_dart && (!pm_suspend_no_platform() || !s2idle_keep_link))
if (pcie->cio_dart && !apple_pcie_can_keep_link(pcie))
return -EBUSY;
if (pcie->neo_sleep_armed) {
struct apple_pcie_port *port;
Expand Down Expand Up @@ -7467,7 +7479,7 @@ static int apple_pcie_prepare(struct device *dev)
*/
if (pcie && pcie->cio_dart && !pcie->cio_prepared &&
pm_suspend_target_state != PM_SUSPEND_ON &&
(!pm_suspend_no_platform() || !s2idle_keep_link)) {
!apple_pcie_can_keep_link(pcie)) {
dev_warn(dev, "no CIO sleep transaction from the NHI; refusing sleep\n");
return -EBUSY;
}
Expand Down
Loading
Loading