remix logo

Hacker Remix

FreeBSD Suspend/Resume

138 points by vermaden 1 week ago | 64 comments

ohazi 5 days ago

RIP S3 sleep... Took years to get it to work reliably under Linux, then we had a good decade+ run of it "just working" like this, now back to trying to weed out all the wacky platform quirks and weird hardware/firmware behavior that make the S0ix states be just barely unusable.

Maybe in another five years...

starspangled 5 days ago

Can you explain a bit more? What happened?

Linux used to be able to do S3 sleep well, and now it can't because... new platforms removed S3 for S0ix? Or S3 became even more complicated with mroe platform quirks and weird hardware?

jodoherty 5 days ago

The problem is platforms moved away from S3 sleep. I've heard people claim it was mostly so managed Windows laptops could force updates with the lid shut and the laptop suspended.

Now I have to worry about my laptop randomly overheating itself in my backpack and even catching fire.

danieldk 5 days ago

I've heard people claim it was mostly so managed Windows laptops could force updates with the lid shut and the laptop suspended.

That, but probably also to compete with Mac's Power Nap feature (2012) that updates Mail, Messages, and other applications during sleep (so that when you open up the laptop messaging apps are immediately up to date):

https://www.engadget.com/2012-06-11-apple-introduces-power-n...

Apple managed to do it without setting your laptop on fire. Meanwhile Dell recommends you to switch off a laptop when you put it in your backpack:

https://www.dell.com/support/kbdoc/en-us/000124304/notebook-....

0x457 4 days ago

Hold on, Apple used the same intel chips as everyone else when Power Nap was introduced. In fact, it was implemented via S0ix state. It's just almost no one except Apple figured how to utilize it correctly.

Now i'm wondering if it's Apple fault that S3 got removed.

goosedragons 4 days ago

Nah. Apple's Intel implementation at least was equally crap. I've had my 2018 MBP cook itself in my bag a couple times.

actionfromafar 5 days ago

Perfect "we have PowerNap at home" moment for Dell and friends. Well played, Apple.

4ad 5 days ago

My Macbook Pro lasts about two days on battery while doing work (in clamshell mode, with the screen off). My Thinkpad drains its battery in less time than that in sleep. The removal of S3 is a travesty.

pxeboot 5 days ago

I believe it came about during the "Windows must run on tablets" era. They needed a way for WiFi to stay on during sleep so things like notifications would continue to work. It also enabled media players to continue playing audio in sleep mode, similar to iOS and Android.

dbtc 5 days ago

Would be great to have a bios switch for it then.

treffer 5 days ago

I tried a few times as some BIOS have a hidden or disabled setting but I never got past a plain crash. Device and CPU vendor support for classic S3 is shrinking. E.g. on framework laptops the Intel CPU(!) does not officially support S3 sleep.

So I can understand that there is no option for it if all you can get is out of spec behavior and crashes.

Also note that it is incompatible with some secure boot and system integrity settings.

gertop 5 days ago

Thinkpads do. It's poorly named but they let you choose Windows (S0x) or Linux (S3) sleep.

4ad 5 days ago

No, not on modern Thinkpads.

0x457 4 days ago

Every XPS and Thinkpad that I owned, had a bios setting to "enable linux compatibility" which was enabling S3 state.

vladvasiliu 5 days ago

> It also enabled media players to continue playing audio in sleep mode

Is that actually a thing? On my Windows machine media stops playing when I put it to sleep. The machine is clearly not completely off, though, judging by the fan spinning like crazy from time to time.

Also, the whole "keep checking for e-mails" and whatever is clearly broken, since after waking up Outlook needs a while to come back to life and show new messages.

sim7c00 5 days ago

weirds me out since acpi etc. is uaed to control power qnd such states why would devices even need to do such things to support some OS.. the OS should be able to manage states, its the controller and hw should listen... in this case, windows could simply not put the devices to sleep?

i know it didnt end up with this logic but it melts my brain as to why... is it cheaper to implement the hw without support for deep sleep?

most specifications have it included (pcie, nvme, ahci etc. etc.) so you'd expect most devices working via pc platform would implement these things :(

cant wait to push my OS onto real hardware and burn my fucking house down

v1ne 5 days ago

FreeBSD and Suspend/Resume… About 10 years ago, I switched from FreeBSD to Linux because I couldn't get suspend/resume to work reliably (i.e. suspend/resume cycle succeeds and it doesn't drain my laptop battery in between) on FreeBSD on my Thinkpad. And this was only Suspend to RAM. Suspend to Disk is really nice to have, especially if coupled with hybrid standby, as on macOS and Windows by default.

I really appreciate that people still maintain FreeBSD on the desktop, though.

ori_b 5 days ago

I recently bought a new laptop because I could only resume to work on OpenBSD, but not Linux. Suspend worked great under Linux, but without resume, the experience was sub-par.

It's unfortunate that I needed Linux to get some of my work done.

margana 5 days ago

Odd that you would say "only Suspend to RAM", because that is far more difficult to reliably implement in terms of hardware compatibility than Suspend to Disk.

nine_k 5 days ago

AFAICT "Suspend to RAM" is basically stopping the CPU, powering down the peripherals, and keeping the DRAM unchanged and refreshed. It should be the easier option since very little state needs to be saved explicitly, the OS and apps should just receive a signal that they were interrupted, so some peripherals have to be re-initialized, and things like network and USB connections need to be re-established.

What am I missing?

Joker_vD 5 days ago

> powering down the peripherals

> some peripherals have to be re-initialized

AIUI, these things actually way more hard than it sounds because hardware developers live in their own world, apparently. There's been articles here on HN from mjg59's blog (who's one of the guys maintaining all this power management stuff in the Linux kernel) like this one [0] about how some hardware simply chooses to do things that make this "re-initialization" impossible to do reliably.

[0] https://news.ycombinator.com/item?id=38095276

gertop 5 days ago

The main difference is that in S3 many (internal) peripherals are put to sleep but not entirely unpowered. So when the system is resumed, it's not an entirely clean slate like it would be from a fresh power up from hibernation. Unfortunately sometimes pulling down the reset line doesn't always do as thorough job as a power cycle.

com2kid 5 days ago

Windows used to work about this well back in the XP days, possibly Windows 7 as well. Plenty of times I hit the "sleep" button that Logitech put right next to the esc key (....) and resumed the system to find everything working as expected.

Not sure if the embedded video is suspend to RAM or disk. Also not sure why there wasn't a PW prompt upon resume, but I'm not a BSD person, just someone who is paranoid about PW prompts.

vermaden 5 days ago

> Not sure if the embedded video is suspend to RAM or disk.

Its Suspend to Disk (S3).

> Also not sure why there wasn't a PW prompt upon resume, but I'm not a BSD person, just someone who is paranoid about PW prompts.

The purpose of this videos were to show only the suspend/resume process of FreeBSD system.

In my daily life I have two shortcuts related to this:

- [SUPER] + [L] - locks the system and leaves it running - and it requires to enter password

- [SUPER] + [CTRL] + [ALT] + [L] - locks the system AND PUTS IT INTO S3 SLEEP - and it requires to enter password if you wake it up

Hope that helps.

Regards,

vermaden

cperciva 5 days ago

Its Suspend to Disk (S3)

S3 is suspend to RAM. Suspend to disk is S4.

vermaden 5 days ago

You are right - its Suspend to RAM - I wanted to reply fast ... which did not ended well.

0x457 5 days ago

Because there is usually a graceful period before forcing to authenticate.

Also, if it's Xorg lockscreen, then it's probably not very secure to begin with.

maybeben 5 days ago

feel lucky. s3 suspend quit working on my thinkpad in -CURRENT some months ago after having worked for like a decade. i didn't notice until i pulled a molten hot slab of locked up laptop out of my bag

bboygravity 5 days ago

The only laptop I ever had in my entire life where sleep works is my current XPS 17 running win10.

I want to update my hardware to a Lenovo. Not looking forward to new "sleep won't work no matter what you try" adventures.

That sht is like printers: should always work, never does.

trelane 5 days ago

Weird. I haven't had a problem with my System76 laptops.

vladvasiliu 5 days ago

I think it's highly dependent on the particular hardware.

I have two HP EliteBook G8s, one AMD one Intel. Both work perfectly with Linux, although they don't support S3, only the "modern" standby.

The AMD one randomly craps out if suspended in Windows. No idea what it does, but it gets extremely hot and doesn't respond to anything but a hard reset. Sometimes it reboots on its own. Maybe because it gets too hot? No idea.

The Intel one also sometimes gets fairly warm for no reason (I keep it up to date, so it can't be random updates - also happens in my bag, so while unplugged). But sleep now mostly works fine. For the first year or so it would sometimes wake up with a garbled screen.

Those are both your regular basic enterprise laptops, no dedicated GPUs or anything fancy.

trelane 16 hours ago

The thing is that modern hardware is super complicated and you have to have a good vendor that specifically targets the OS you want.