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

Anand Moon linux.amoon at gmail.com
Wed Nov 18 22:04:40 PST 2026


Hi Igor,


On Thu, 19 Nov 2026 at 06:42, Igor Velkov via B4 Relay
<devnull+iav.iav.lv at kernel.org> wrote:
>
> From: Igor Velkov <iav at 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.
>
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?

Thanks
-Anand

> Signed-off-by: Igor Velkov <iav at 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 at iav.lv>
>
>
>
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip



More information about the Linux-rockchip mailing list