=== Suspend/Resume Improvement

Links: +
link:https://obiw.ac/s0ix/[Blog] URL: link:https://obiw.ac/s0ix/[] +
link:https://youtu.be/mBxj_EkAzV0[FOSDEM talk on S0ix] URL: https://youtu.be/mBxj_EkAzV0[] +
link:https://github.com/obiwac/freebsd-s0ix[Working Repository] URL: link:https://github.com/obiwac/freebsd-s0ix[] +
link:https://reviews.freebsd.org/D48721[Tip of the S0ix + AMD SMU stack] URL: https://reviews.freebsd.org/D48721[] +
link:https://reviews.freebsd.org/D49453[USB4 suspend stack] URL: https://reviews.freebsd.org/D49453[]

Contact: obiwac <obiwac@FreeBSD.org>

Suspend-to-idle and support for S0ix sleep is in the process of being added to FreeBSD.

This will allow modern Intel and AMD laptops (e.g. AMD and newer Intel Framework laptops), some of which do not support ACPI S3 sleep, to enter low power states to increase battery life.

Suspending and resuming is working on the Framework 13 AMD Ryzen 7040 series, though the deepest S0ix state (S0i3), necessary for significant power savings, cannot yet be entered on AMD systems.
The major blocker for this at the moment is being able to suspend all the USB4 routers correctly, without which the power management firmware will refuse to enter S0i3.
USB4 suspend support in FreeBSD is necessary as the BIOS wakes them up and runs a pre-OS connection manager for USB4 to work before an OS loads with its own connection manager, so they start off in an awake state.

Work has been picked up from the initial USB4 driver Scott Long started writing, but it is not yet at a stage where the routers are being fully suspended.

An amdsmu driver was written to read last suspend statistics and sleep-state residency counters (which were unavailable in the ACPI _LPI objects).
The SMU is a small coprocessor on AMD CPUs which runs the power management firmware and is ultimately what decides to enter S0i3 or not.
These statistics can tell us if the system entered S0i3 during the last suspend, how much time it took to enter, and which proportion of suspended time was spent in S0i3.

Sponsor: The FreeBSD Foundation
