* [PATCH] PCI: rockchip-host: Support hibernation with endpoints in D0
@ 2026-11-19 1:12 Igor Velkov via B4 Relay
2026-11-19 1:33 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Igor Velkov via B4 Relay @ 2026-11-19 1:12 UTC (permalink / raw)
To: Shawn Lin, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, Heiko Stuebner, linux-rockchip, linux-arm-kernel,
linux-kernel, Rob Herring, Igor Velkov
From: Igor Velkov <iav@iav.lv>
The driver runs its suspend callback on every system sleep transition,
including hibernation freeze and the quiesce step of the kernel that
loads the image. The PCI core leaves the endpoints in D0 there, the
link does not enter L2 after PME_Turn_Off, and hibernation aborts:
rockchip-pcie f8000000.pcie: PCIe link enter L2 timeout!
rockchip-pcie f8000000.pcie: PM: failed to freeze noirq: error -110
Keep the link up across freeze and thaw. On restore, power the port
down and bring it up as on resume, because the kernel that loaded the
image may have left it in any state. The port may already be down if
poweroff_noirq ran, so track that state.
Signed-off-by: Igor Velkov <iav@iav.lv>
---
Tested on v7.4-rc3 with this patch, ROCK Pi 4A with a WD SN770 NVMe:
5 of 5 hibernation cycles restored, the NVMe readable after each.
---
drivers/pci/controller/pcie-rockchip-host.c | 33 +++++++++++++++++++++++++++--
drivers/pci/controller/pcie-rockchip.h | 1 +
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c
index 1e1556e436b8..df4b9b3ec031 100644
--- a/drivers/pci/controller/pcie-rockchip-host.c
+++ b/drivers/pci/controller/pcie-rockchip-host.c
@@ -863,6 +863,8 @@ static int rockchip_pcie_suspend_noirq(struct device *dev)
regulator_disable(rockchip->vpcie0v9);
+ rockchip->powered_down = true;
+
return ret;
}
@@ -893,6 +895,8 @@ static int rockchip_pcie_resume_noirq(struct device *dev)
rockchip_pcie_update_txcredit_mui(rockchip);
rockchip_pcie_enable_interrupts(rockchip);
+ rockchip->powered_down = false;
+
return 0;
err_err_deinit_port:
@@ -904,6 +908,25 @@ static int rockchip_pcie_resume_noirq(struct device *dev)
return err;
}
+static int rockchip_pcie_restore_noirq(struct device *dev)
+{
+ struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
+
+ /*
+ * The boot kernel may have left the port in any state, while the image
+ * holds the enable counts of a running port. Power it down so that
+ * resume brings it up from scratch.
+ */
+ if (!rockchip->powered_down) {
+ rockchip_pcie_deinit_phys(rockchip);
+ rockchip_pcie_disable_clocks(rockchip);
+ regulator_disable(rockchip->vpcie0v9);
+ rockchip->powered_down = true;
+ }
+
+ return rockchip_pcie_resume_noirq(dev);
+}
+
static int rockchip_pcie_probe(struct platform_device *pdev)
{
struct rockchip_pcie *rockchip;
@@ -1011,9 +1034,15 @@ static void rockchip_pcie_remove(struct platform_device *pdev)
regulator_disable(rockchip->vpcie0v9);
}
+/*
+ * Freeze leaves the endpoints in D0 and the link does not reach L2 then,
+ * so keep the link up across freeze and thaw; restore re-inits the port.
+ */
static const struct dev_pm_ops rockchip_pcie_pm_ops = {
- NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_pcie_suspend_noirq,
- rockchip_pcie_resume_noirq)
+ .suspend_noirq = pm_sleep_ptr(rockchip_pcie_suspend_noirq),
+ .resume_noirq = pm_sleep_ptr(rockchip_pcie_resume_noirq),
+ .poweroff_noirq = pm_sleep_ptr(rockchip_pcie_suspend_noirq),
+ .restore_noirq = pm_sleep_ptr(rockchip_pcie_restore_noirq),
};
static const struct of_device_id rockchip_pcie_of_match[] = {
diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h
index b5da15601b58..51877678d3df 100644
--- a/drivers/pci/controller/pcie-rockchip.h
+++ b/drivers/pci/controller/pcie-rockchip.h
@@ -324,6 +324,7 @@ struct rockchip_pcie {
void __iomem *msg_region;
phys_addr_t msg_bus_addr;
bool is_rc;
+ bool powered_down;
struct resource *mem_res;
};
---
base-commit: 35f800669ce835aa77364a2ab5b61be19b778d3c
change-id: 20261119-b4-rockchip-pcie-hib-004e1adc4042
Best regards,
--
Igor Velkov <iav@iav.lv>
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 1:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 1:12 [PATCH] PCI: rockchip-host: Support hibernation with endpoints in D0 Igor Velkov via B4 Relay
2026-11-19 1:33 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox