[PATCH] PCI: rockchip-host: Support hibernation with endpoints in D0

Anand Moon linux.amoon at gmail.com
Tue Dec 1 07:48:39 PST 2026


Hi Igor.

On Thu, 19 Nov 2026 at 13:33, Anand Moon <linux.amoon at gmail.com> wrote:
>
> Hi Igor,
>
> On Thu, 19 Nov 2026 at 11:54, Igor Velkov <iav at iav.lv> wrote:
> >
> > On Thu, 19 Nov 2026, Anand Moon wrote:
> > > It looks like we aren't disabling all the PCIe regulators (0.9V, 1.8V,
> > > 3.3V, and 12V)
> > > during suspend and re-enabling them during resume.
> > > Shouldn't we power down all of them on suspend and bring them back up on resume?
> >
> > This patch keeps the rails as they are: suspend_noirq() already turns
> > off only vpcie0v9, and the other rails stay on from probe to remove.
> > The 3.3 V and 12 V rails power the endpoint; cutting them in suspend
> > loses the state that the PCI core and the endpoint driver expect to
> > keep in D3hot. Doing that would be a separate change.
> >
> Makes sense. Thanks
> I will check the disable and enable regulators to help with this issue
> and will update you.
> > --
Since we tear down the clocks and PHY on suspend, we should also assert PERST#
before cutting endpoint power and clocks, and disable all PCIe
regulators to keep
their enable reference counts balanced across suspend/resume.

Could you give this patch a try? My RK3399 dev board is currently broken,
so I can't test it myself.

$ git diff drivers/pci/controller/pcie-rockchip-host.c
diff --git a/drivers/pci/controller/pcie-rockchip-host.c
b/drivers/pci/controller/pcie-rockchip-host.c
index 5b071bdc4f90..ef5626c145d6 100644
--- a/drivers/pci/controller/pcie-rockchip-host.c
+++ b/drivers/pci/controller/pcie-rockchip-host.c
@@ -841,6 +841,16 @@ static int rockchip_pcie_wait_l2(struct
rockchip_pcie *rockchip)
        return 0;
 }

+static void rockchip_pcie_put_vpcie(struct rockchip_pcie *rockchip)
+{
+       regulator_disable(rockchip->vpcie0v9);
+       regulator_disable(rockchip->vpcie1v8);
+       if (!IS_ERR(rockchip->vpcie3v3))
+               regulator_disable(rockchip->vpcie3v3);
+       if (!IS_ERR(rockchip->vpcie12v))
+               regulator_disable(rockchip->vpcie12v);
+}
+
 static int rockchip_pcie_suspend_noirq(struct device *dev)
 {
        struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
@@ -857,13 +867,17 @@ static int rockchip_pcie_suspend_noirq(struct device *dev)
                return ret;
        }

+       /* Assert PERST# before cutting endpoint power and clocks */
+       gpiod_set_value_cansleep(rockchip->ep_gpio, 0);
+
        rockchip_pcie_deinit_phys(rockchip);

        rockchip_pcie_disable_clocks(rockchip);

-       regulator_disable(rockchip->vpcie0v9);
+       /* Disable ALL PCIe regulators (0.9V, 1.8V, 3.3V, 12V) */
+       rockchip_pcie_put_vpcie(rockchip);

-       return ret;
+       return 0;
 }

 static int rockchip_pcie_resume_noirq(struct device *dev)
@@ -871,16 +885,18 @@ static int rockchip_pcie_resume_noirq(struct device *dev)
        struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
        int err;

-       err = regulator_enable(rockchip->vpcie0v9);
+       /* Re-enable ALL PCIe regulators first (12V -> 3.3V -> 1.8V -> 0.9V) */
+       err = rockchip_pcie_set_vpcie(rockchip);
        if (err) {
-               dev_err(dev, "fail to enable vpcie0v9 regulator\n");
+               dev_err(dev, "failed to set vpcie regulator\n");
                return err;
        }

        err = rockchip_pcie_enable_clocks(rockchip);
        if (err)
-               goto err_disable_0v9;
+               goto err_disable_vpcie;

+       /* Re-initialize PHY, release PERST#, and train PCIe link */
        err = rockchip_pcie_host_init_port(rockchip);
        if (err)
                goto err_pcie_resume;
@@ -899,8 +915,8 @@ static int rockchip_pcie_resume_noirq(struct device *dev)
        rockchip_pcie_deinit_phys(rockchip);
 err_pcie_resume:
        rockchip_pcie_disable_clocks(rockchip);
-err_disable_0v9:
-       regulator_disable(rockchip->vpcie0v9);
+err_disable_vpcie:
+       rockchip_pcie_put_vpcie(rockchip);
        return err;
 }

> > Igor Velkov <iav at iav.lv>
>
> Thanks
> -Anand

Thanks
-Anand-



More information about the Linux-rockchip mailing list