Enable suspend/resume on Pi 5 - #7514
Conversation
|
Can you describe your use case? |
|
This is just for testing how the drivers handle suspend/resume. The firmware does not support suspend yet. It currently stops the arm and then starts it again after one second. The first commit should only be merged if the firmware supports suspend. The other commits should do nothing if suspend is not enabled so they could be merged before suspend works. |
|
The commits look plausible to me. Claude had some comments (that may not be an issue):
|
|
I've updated the watchdog driver with the extra check. The wireless driver prevents runtime PM while it is bound I've added a temporary fix for NVMe drives. It works by overriding |
|
The firmware is now getting into the kernel after wakeup from S3 (lots to do!). I think our TFA was assuming that GIC distributor was preserved in S3, it isn't. It's not in the AON power island Mailboxes writes weren't making it to VPU after wakeup from S3, here's my very lightly tested patch for this on top of your patchset |
|
Firmware for kernel debug here - pieeprom-2026-08-17 (probably quite broken) Should look something like this, WiFi + NETDEV timeouts |
|
WiFi no longer hangs for me with the pinctrl changes - tested with rebased s2ram pieeprom-2026-08-17-v3.bin that includes other firmware clock changes. |
42dae28 to
e2fe239
Compare
|
Using the regulator driver for PCIE_PWR_EN means that it will also be left unpowered when not in use. |
a6f3b97 to
35fcd28
Compare
f01824f to
a8e9787
Compare
| items: | ||
| enum: [1, 4, 8, 16, 32, 64, 128, 256] | ||
|
|
||
| snps,power-off-in-suspend: |
There was a problem hiding this comment.
This needs a better name - USB suspend is the name given to a runtime power management choice, but collides with the concept of system suspend (which may or may not power off the system). The SNPS driver instantiates an xhci platform driver, so we don't get the luxury of pretending that PCI power states apply.
I'd suggest s2ram as this maps to the state in admin-guide/pm/sleep-states.rst
| u = bcm2712_iommu_get_page(mmu, &mmu->top_table); | ||
| if (!u) | ||
| return -ENOMEM; | ||
| if (mmu->top_table) { |
There was a problem hiding this comment.
Yes, it looks plausible.
When called from probe() the structure is kzalloc'd so it will allocate memory for top-level tables and default/trap page. When called from resume() it will merely re-program their addresses into H/W registers.
(Tangentially, there is some pre-existing conflation of "physical address" (where the tables are in SDRAM) and "dma_addr_t" (how the IOMMU can reach them) but we already assume they are identical and there is a WARN_ON about it; virt_to_phys is fine here.)
There was a problem hiding this comment.
I see Claude has made an almost identical comment!
|
Claude review: Review: #7514 — "Enable suspend/resume on Pi 5"Base Overall: the shape of the series is right and most of the driver work is 1. Regression risk for users who do not use suspendGood news first: every
So the shared drivers this series touches — What is left unconditional, ranked by risk: 1a.
|
0f0f657 to
e71c9a3
Compare
| * Configure the addresses of the top-level table (offset because | ||
| * the aperture does not start from zero), and of the default page. | ||
| * For simplicity, both these regions are whole Linux pages. | ||
| */ |
There was a problem hiding this comment.
It's easier to understand now, but the comment above is now only partly relevant here (perhaps also the comment on line 723).
This function is small enough that it could perhaps be rolled into bcm2712_iommu_probe? OTOH that function is quite large already. Hmm.
e71c9a3 to
0dc1d11
Compare
|
I've moved bcm2712_iommu_hw_init to be called in probe so now the top level and default page are allocated in their own function which just does that. |
1cf2806 to
c924d6d
Compare
Add support for suspend to RAM on bcm2712. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Stop the watchdog during suspend to that it does not reset while suspended Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Add a device tree property so that wifi is powered off correctly during suspend. The wifi is powered off by the firmware during system suspend. The wifi driver does not allow runtime suspension so this will only affect system suspend. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
This makes the NVMe driver reset drives during suspend/resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Disable the iommu on suspend and reinitialise it on resume. Move allocating top_table and default_page into another function so that they do not run again on resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Force a runtime suspend during system suspend. This prevents occasional warnings about packet RAM being off. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Use the drm_mode_config_helper_ functions on suspend and resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Reinitialise the hardware on resume. Split vc4_hvs_upload_linear_kernel into two functions. On resume, the kernels have already been allocated. Move writing to the hardware into another function and call that on resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Use the suspend/resume methods for hibernation. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
In S3 deep-sleep, the entire VPU, ARM, GIC infrastructure is powered off. Re-initialise the mailbox hardware on resume otherwise, the VPU won't see mailbox requests. Signed-off-by: Tim Gover <tim.gover@raspberrypi.com>
Enable the watchdog for device power management. Use a short timeout before warning. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Save the pin mux and pad during suspend and restore it during resume. Multiple pins are stored in each register. Store the entire register for each pin. The values will not change between storing and restoring the individual pins. This uses a few extra bytes but simplifies the code. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Re-enable interrupts in start_rx. This fixes the serial console ignoring input after a system suspend with no_console_suspend set. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
The registers get reset during suspend. Restore them on resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
There are 32 individual event bits of which 4 correspond to mailbox channels. Limit the IRQ handler to signalling mailbox events on actual mailboxes, to prevent all-1s completions (such as when the link is down) or RP1 firmware bugs from causing null pointer dereferences. Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
Rerun the sdhci initialisation on resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
On suspend, check if there is a current job being processed. Suspending takes longer than a pisp job so assume it will be done and cancel suspending if it is not. On resume, restore hardware registers. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Use the modeset helper functions and disable the clock in suspend. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
On a Raspberry Pi 5, the bluetooth is powered off in system suspend. Add a property for this behaviour. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Implement the power-off-in-suspend property so that bluetooth is handled correctly after suspend. It is powered off so reprobe the device again on resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Add a device tree property so that bluetooth is handled correctly after suspend. It is powered off so the device is registered again on resume. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
This adds a regulator for pcie1 using a pin on the RP1. It needs a hack to order pcie2 before pcie1 so that the regulator is found by the pcie-brcmstb driver. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
…other alarm This clears the pending alarm when resuming from system suspend and when setting another alarm. Previously, If the rtc was used to wake from suspend more than one time in a row, It would fail. If the alarm is set and the system is suspended, resumed and suspended before the alarm occurs, the alarm will still wake the system. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
This prevents the camera from sometimes freezing when using rpicam-hello -t 0 Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Use the modeset helper functions and poweroff the DAC in suspend. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Add a device tree property to indicate that the xHCI controller will be reset over suspend. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
Use the snps,power-off-in-s2ram property to set power_lost in xhci-plat Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
The RP1 will reset the USB controllers over suspend. Add snps,power-off-in-suspend to its device tree. Signed-off-by: Peter Bailey <peter.bailey@raspberrypi.com>
c924d6d to
8e9ba62
Compare
This enables suspend/resume support for Pi 5.
The watchdog should be stopped when suspending.
The wireless can be turned off with
cap-power-off-card. It could be left on withkeep-power-in-suspendbut that does not have any benefits currently.NVME drives currently do not work. The NVME driver puts the drive in a low power state and expects the link to be left on. The PCIe driver then turns off the link. This stops the NVME driver waking up the drive. Adding NVME_QUIRK_SIMPLE_SUSPEND to a drive fixes it.