News for hackers. Stuff that matters.
Re:Why does Linux have so much trouble sleeping and waking? by steviedotboston on Friday December 11, 2020 @09:29AM (#25386161)
Drivers. The way laptops sleep and wake is pretty unique to each type of computer, and many manufacturers don't care about Linux support so kernel developers are left to figure it out on their own.

I haven't used Linux on a desktop/laptop in a decade so it's sad to hear that things are still the same.

Re:Why does Linux have so much trouble sleeping and waking? by Datenstrom on Friday December 11, 2020 @09:45AM (#25386327)
> manufacturers don't care about Linux support

This is why I have been using System76 personally for the last 5 years, since I first found out about them when given one by an employer. The first linux box I have had that didn't have little problems like that.

Disclaimer: not affiliated in any way, just a happy customer for work and play.

Re:Why does Linux have so much trouble sleeping and waking? by nextos on Friday December 11, 2020 @11:48AM (#25387754)
Most machines with decent drivers also have flawless sleep. This includes NUCs, many Thinkpads, etc.

In general, Linux runs really well if you filter hardware a bit ahead of purchase. For example, an all Intel machine with Intel wireless card will rarely give any trouble.

Re:Why does Linux have so much trouble sleeping and waking? by jusssi on Friday December 11, 2020 @02:05PM (#25389378)
Ubuntu just couple a weeks ago pushed a kernel update to 20.04 LTS that 100% broke resuming from suspend on my 2020 Thinkpad (Intel graphics driver hang, no surprise there). I had to switch to edge kernel to get it back working.

Edit: yes, it's a model you can buy with Ubuntu pre-installed.

Re:Why does Linux have so much trouble sleeping and waking? by BHSPitMonkey on Friday December 11, 2020 @03:38PM (#25390662)
In the past 5 years, I've used ThinkPads for work (a T-series, X1 5G, and X1 6G); All of them mysteriously like to wake themselves out of sleep for no clear reason while closed and not connected to any external devices/power.

(If someone knows which log file will tell me the exact reason behind a mystery wakeup after it happens, please share!)

Re:Why does Linux have so much trouble sleeping and waking? by exikyut on Friday December 11, 2020 @03:54PM (#25390857)
Enabling verbose ACPI debug messages might do it:

https://www.kernel.org/doc/Documentation/acpi/debug.txt

I'm not exactly sure what options you'd need to enable/disable to just catch useful info.

Hopefully you don't need to enable everything, which may produce enough (realtime) logspam to make journald use a noticeable amount of CPU.

Re:Why does Linux have so much trouble sleeping and waking? by IronBacon on Friday December 11, 2020 @04:48PM (#25391589)
Maybe Intel Smart Connect?
Re:Why does Linux have so much trouble sleeping and waking? by wutbrodo on Friday December 11, 2020 @01:43PM (#25389104)
The child comment is dead for some reason so I can't reply, but he's right: it's important to note that filtering can be difficult, bexause even laptops that nominally support Linux (or ship with it!) can have terrible support. The Dell XPS developer editions (I bought two, one for work and one for home) are the worst Linux compatibility experience I've ever had. Amazing hardware, but shame on me for believing the line that Dell had turned over a new leaf and was competent now.
Re:Why does Linux have so much trouble sleeping and waking? by jessaustin on Friday December 11, 2020 @03:35PM (#25390622)
I bought one with Ubuntu installed, and have had a few small problems. I.e., power remaining is slightly optimistic: it shut down this morning with 3% showing. Also it seems to have more trouble connecting to paired bluetooth devices than my phone has. I like it well enough to live with these issues. Is there something awful coming soon?
Re:Why does Linux have so much trouble sleeping and waking? by danielscrubs on Monday December 14, 2020 @05:21AM (#25415378)
I’m not an electrical engineer but batteries don’t give perfect output constantly so your three percent might have been correct. It’s an hard problem and if you want it to be “it should always be able to go to zero” then they will just increase the margin of when to shut down and people will wonder where their battery life went.
Re:Why does Linux have so much trouble sleeping and waking? by wutbrodo on Friday December 11, 2020 @04:44PM (#25391508)
I mentioned this in my other comment but should have mentioned it here too: I got these in 2015/16, so I can't comment on what the line is like now. My main point was that shipping with Linux is no guarantee that they'll work well, as ludicrous as that sounds.
Re:Why does Linux have so much trouble sleeping and waking? by Kimitri on Friday December 11, 2020 @01:57PM (#25389287)
Yes. I just got myself a cheapo ThinkPad E15 to use as a backup computer if Apple somehow screws up my old MacBook Pro. Installed OpenSUSE Tumbleweed on the ThinkPad and everything seems to be working quite well (or at least predictably).

That being said, after each reboot I do need to put the machine to sleep using the power button once. After that the sleep/wake works perfectly just by closing/opening the lid. It's a minor inconvenience and I'm actually kind of loving the thing!

Re:Why does Linux have so much trouble sleeping and waking? by yyyk on Saturday December 12, 2020 @02:31PM (#25400820)
One of my Intel NUC models needs a BIOS update to not soft-brick* itself after sleeping from Linux. Even today restarting from sleep needs a particular 'dance' which if not followed will need a restart to use the computer again. Everything else works though.

* bricks, but can be restarted if one opens the case and resets the BIOS.

Re:Why does Linux have so much trouble sleeping and waking? by BlueTemplar on Friday December 11, 2020 @02:43PM (#25389936)
I have a Surface Pro 3 with Ubuntu and not only sleep is not working, when turning the screen on again the WiFi stops working...
Re:Why does Linux have so much trouble sleeping and waking? by buzzdenver on Friday December 11, 2020 @12:49PM (#25388497)
Writing this on a System 76 laptop running the latest PopOS and I wish I had the same experience. Sleep/wake works if I explicitly put my machine into sleep, but not if I just close the screen.
Re:Why does Linux have so much trouble sleeping and waking? by andrewshadura on Friday December 11, 2020 @01:00PM (#25388614)
It's just a matter of a user setting. It does not necessarily mean something doesn't work. I, for example, hate automatic suspect on lid close.
Re:Why does Linux have so much trouble sleeping and waking? by mattanimation on Friday December 11, 2020 @11:49AM (#25387762)
yeah System 76 is a solid laptop, granted they do maintain PopOS which is the default OS on their systesm. so they do indeed have more custom hardware support which is why it's such a good marriage.
Re:Why does Linux have so much trouble sleeping and waking? by rufus_foreman on Friday December 11, 2020 @07:56PM (#25393978)
I've got a System 76 laptop, and it's the best laptop I've owned so far out of the Windows, Mac, and Linux laptops I've had. But it still won't wake up from sleeping sometimes, maybe once a month.

Had a Dell XPS before that, it was way worse on the same issue. With MacBooks, I didn't have that issue as much with personal machines, but I mostly used them for travel. I've had pretty bad issues with work MacBooks.

Love my System 76, but there's still work to be done there.

Re:Why does Linux have so much trouble sleeping and waking? by nicholasjarnold on Friday December 11, 2020 @11:22AM (#25387441)
Chiming in to add an anecdotal data point in support of the parent's comment. I too own a System76 laptop which is running their drivers and PopOS (Debian and Ubuntu derivative). Sleep/wake works well.
Re:Why does Linux have so much trouble sleeping and waking? by gcthomas on Friday December 11, 2020 @12:42PM (#25388395)
Any machine covered by Ubuntu certified hardware seems to work very well by default, including my work Dell XPS13. Sleep/wake happens flawlessly.
Re:Why does Linux have so much trouble sleeping and waking? by lliamander on Friday December 11, 2020 @06:51PM (#25393364)
My Dell Precision 5530 for work is kinda meh - by which I mean it works most of the time, but the fact that it doesn't work every time is fairly big deal at this point.

My personal ThinkPad E495 has pretty much flawless driver support.

Granted, I'm running different distros (Ubuntu on the Dell, Solus on the ThinkPad) but the fact that the Dell Precision is certified specifically for Ubuntu is pretty disappointing.

Re:Why does Linux have so much trouble sleeping and waking? by wutbrodo on Friday December 11, 2020 @01:44PM (#25389121)
I had two dell XPSes in 2015/16, one of which shipped with Ubuntu, and they were by far the worst compatibility experience I've ever had with a Linux laptop. I loved the hardware, but my God was the firmware garbage.
Re:Why does Linux have so much trouble sleeping and waking? by Karellen on Friday December 11, 2020 @02:18PM (#25389551)
My last laptop was a System76, and my current is a Purism Librem 15. Also no problems with suspend/resume.
Re:Why does Linux have so much trouble sleeping and waking? by bobince on Friday December 11, 2020 @11:57AM (#25387853)
They don't even necessarily care about Windows support. Upgrade to a new version that doesn't quite work the same with the hacks in their cobbled-together drivers, and you're quickly in the same boat as the Linux users.
Re:Why does Linux have so much trouble sleeping and waking? by epx on Friday December 11, 2020 @01:58PM (#25389297)
Only Macs sleep reasonably correctly, and even they have issues. In my Macbook Air, Wi-Fi is the first victim after "n" cycles so I need to reboot it.
Re:Why does Linux have so much trouble sleeping and waking? by waffletower on Friday December 11, 2020 @03:02PM (#25390209)
Indeed. External display detection often bugs out after sleep in Mac OS.
Re:Why does Linux have so much trouble sleeping and waking? by fortran77 on Friday December 11, 2020 @10:59PM (#25395383)
That's too bad. My Lenovo Yoga with Windows 10 works perfectly. Never a glitch.
Re:Why does Linux have so much trouble sleeping and waking? by SteveNuts on Friday December 11, 2020 @12:12PM (#25388048)
This hasn't been my experience with Windows in the last 5 years. Truth be told it's pretty stable by now and for me, issues like that are rare. Even things like working with external docking stations are pretty seamless nowadays.
Re:Why does Linux have so much trouble sleeping and waking? by munchbunny on Friday December 11, 2020 @01:38PM (#25389042)
I don't think any of our individual experiences will say much on this topic. It clearly works well enough for some and not for others.

My desktop (custom built) refuses to go to sleep when I'm booted into Linux. Straight up just wakes itself immediately.

Over in Windows land I've had this issue on a regular basis with a Thinkpad that keeps waking itself up. I've had this issue occasionally on a Surface Book 2, I suspect due to a finicky monitor attached to the dock. I've had this issue pretty much never on a first gen Surface Book attached to the same dock. Go figure.

Re:Why does Linux have so much trouble sleeping and waking? by shock on Friday December 11, 2020 @02:29PM (#25389706)
> My desktop (custom built) refuses to go to sleep when I'm booted into Linux. Straight up just wakes itself immediately.

It's probably a device that it's waking the computer up. In my case it was a mouse. See https://news.ycombinator.com/item?id=25389048 for a solution.

Re:Why does Linux have so much trouble sleeping and waking? by jcelerier on Friday December 11, 2020 @12:18PM (#25388116)
Beh, my laptop (MSI GS65) has trouble waking up from sleep on windows too. When putting it to sleep on linux it always comes back up, but I have to reboot to get wifi back. On windows wifi comes back, but the ethernet port needs to be disabled & reenabled in the control panel to work. Laptops suck.
Re:Why does Linux have so much trouble sleeping and waking? by jtolly710 on Friday December 11, 2020 @12:38PM (#25388345)
Hey I'm also running a GS65 (First Ubuntu - now PopOs), the Wifi is frustrating, but I found double-tapping (2x [FN+F10]) in quick succession would bring the radios back up.

Have you ever gotten the native HDMI port to work in linux?

Re:Why does Linux have so much trouble sleeping and waking? by jcelerier on Friday December 11, 2020 @12:58PM (#25388592)
> Hey I'm also running a GS65 (First Ubuntu - now PopOs), the Wifi is frustrating, but I found double-tapping (2x [FN+F10]) in quick succession would bring the radios back up.

oh wow, okay I'll definitely try that haha

> Have you ever gotten the native HDMI port to work in linux?

Yes, with the nvidia drivers it works fine

Re:Why does Linux have so much trouble sleeping and waking? by jbverschoor on Friday December 11, 2020 @01:17PM (#25388798)
Laptops don’t suck. My MacBook rarely reboots.. only in case of system updates. Sleep/wake up works perfect
Re:Why does Linux have so much trouble sleeping and waking? by wutbrodo on Friday December 11, 2020 @01:40PM (#25389070)
This is also true of every ThinkPad Linux system I've used over the last fifteen years, as the ThinkPad is as close to first-party Linux hardware as exists. It's also true for the majority of Windows laptops in the MacBook price range, I assume. I'd also assume that Hackintoshes don't work as smoothly as you describe, which feeds right into the parent commenter's complaint.

The parent commenter just has higher standards than you: either that software and hardware are relatively easily decoupled and should be, or that laptop manufacturers should competently implement the standards they claim to, or even just that he's never worked at a company whose product was as poorly-made as almost every laptop's compatibility software.

Re:Why does Linux have so much trouble sleeping and waking? by 1996 on Friday December 11, 2020 @12:44PM (#25388427)
> This hasn't been my experience with Windows in the last 5 years. Truth be told it's pretty stable by now and for me, issues like that are rare.

Good sleep on windows has only returned recently.

After years of great sleep on Windows 7, there have been massive changes following the introduction of ACPI S0.

Case in point: I got a nice laptop for classes like 4 years ago and it did NOT implement either S3 or S4 mode, which caused a MASSIVE problem in Linux. I found out about the issue on mailing list: the bios simply didn't implement at all this part of ACPI, instead of exposing the hooks based on the OS detection. It was to reduce problems in theory, but it brought many more in practice.

Connected standby (S0idle) was very flaky on Windows 10, and very often the laptop would eat the battery overnight instead of going to sleep.

Re:Why does Linux have so much trouble sleeping and waking? by WorldMaker on Friday December 11, 2020 @02:49PM (#25390042)
I don't think a lot of Windows users notice when hardware has things like missing ACPI states because Windows since Vista tends to treat a lot of drivers as potentially "sleep hostile" and does all sorts of crazy tricks to paper over bad driver behavior, including sometimes hard shutting off/rebooting hardware on tough timeout limits (depending on hardware class) and fakes sleep/suspend as best as it can given whatever limits it comes across. The few times I've ever skimmed the ACPI/Power Events event logs in Windows, it's an amazing glimpse into some real wild goings on that rarely seem noticeable from a user level, but clearly indicate that drivers are as much of a mess as ever and Windows does a lot of work to make it look like things are fine, everything is fine, and system is peacefully sleeping (as hardware gets kicked under the table for acting up).

I'm not sure if there are direct lessons there for Linux driver handling as Microsoft has huge test labs that do forward these sorts of event logs to the hardware manufacturers and is in a position to expect at least some of them to do better next time (either next driver update or next hardware refresh).

Re:Why does Linux have so much trouble sleeping and waking? by olyjohn on Friday December 11, 2020 @12:51PM (#25388523)
This is how I feel about Linux on my laptop. Haven't had any sleep or dock issues in a long time. I think that PCs are much better overall about power management than they used to be. I think most of that has to do with the hardware vendors, and less to do with Windows or Linux.

Macs have always nailed it. When I worked at a computer store like 15 years ago, people would bring in their Macs, open up the lid and it would wake instantly after being asleep in someone's bag for 2 weeks and still have a 90% charge. Any Windows PC in that era would have run until it overheated and melted, or ran out of battery, whichever happened first.

Re:Why does Linux have so much trouble sleeping and waking? by cuddlybacon on Friday December 11, 2020 @02:40PM (#25389884)
If I let my Windows desktop go to sleep by being idle, it works perfectly fine.

If I select the sleep option in the start menu it probably won't wake back up and I'll have to unplug it for about 10 minutes to get it to boot again.

Re:Why does Linux have so much trouble sleeping and waking? by cooljacob204 on Friday December 11, 2020 @03:26PM (#25390508)
Every once in a while there will be a week or two where I have issues with my pc not sleeping.

Previous causes have been sound drivers, chrome, steam, joysticks, some unknown that an update fixes.

Re:Why does Linux have so much trouble sleeping and waking? by swiley on Friday December 11, 2020 @04:47PM (#25391569)
I know people where windows update removed their GPU driver leaving them with only VESA graphics.

They had no idea what happened or how to fix it.

Re:Why does Linux have so much trouble sleeping and waking? by vagrantJin on Friday December 11, 2020 @07:01PM (#25393467)
> They don't even necessarily care about Windows support.

I doubt this is true. Windows = computing for a good over 80% of humanity. Not markets, not regions. Humanity.

Re:Why does Linux have so much trouble sleeping and waking? by pwg on Friday December 11, 2020 @09:40AM (#25386285)
This ...

If the OP does some internet research into this topic they will find articles detailing how almost all [1] non-apple laptop makers build to a single target: ms-windows. They also test against a single target: ms-windows. If it works there, they are done. Linux compatibility is not even an afterthought.

And as each makers various models all seem to also have slightly different ways to perform sleep/hibernate and subsequent wakeup, the result is that Linux kernel dev's are playing a continuous game of catch-up. One thing I've found is that upgrading the kernel to a later release sometimes fixes the issues (assuming patches were supplied by someone in the interim to fix them).

[1] Very few makers have any laptops that ship, from the maker, with Linux preinstalled, the few that do (one or two Dell models, the aftermarket "Linux Laptop" vendors, maybe a sliver of others) will more than likely work properly for sleep/wake. The reason why these work better is because the maker should, in theory, test for Linux compatibility and help fix any bugs (or simply build with compatible chipsets from the outset) since they are selling these with "Linux pre-loaded".

Re:Why does Linux have so much trouble sleeping and waking? by danieldk on Friday December 11, 2020 @09:49AM (#25386375)
one or two Dell models, the aftermarket "Linux Laptop" vendors, maybe a sliver of others

Lenovo also certifies ThinkPads for Linux:

https://support.lenovo.com/us/en/solutions/pd031426-linux-fo...

Newer (?) ThinkPads even have a firmware option to switch between the default sleep state and one that is more compatible with Linux.

Re:Why does Linux have so much trouble sleeping and waking? by gsich on Friday December 11, 2020 @04:10PM (#25391032)
Lenovo has Linux fails too. This list is on part a blatant lie.

Example: Lenovo ships some Thinkpads with a Fibocom LTE modem. But only Windows has PCIe drivers, Linux needs to use the USB interface. Not a problem one would think, but if you switch the modem to USB mode, the notebook will not boot. Lenovo still uses a whitelist for allowed devices and they forgot to add the USB mode for the modem.

Thread for further reading: https://forums.lenovo.com/t5/Linux-Discussion/Linux-support-...

https://forums.lenovo.com/t5/Other-Linux-Discussions/Linux-d...

Re:Why does Linux have so much trouble sleeping and waking? by lwhalen on Friday December 11, 2020 @11:44AM (#25387709)
Could you tell me more about this firmware option? As a ThinkPad owner/Linux user, I'd be very interested!
Re:Why does Linux have so much trouble sleeping and waking? by q3k on Friday December 11, 2020 @12:03PM (#25387947)
So, PCs can generally either do S3 sleep, or a new fancy 'S0ix' sleep since Haswell & co, and some similar mechanism on AMD machines.

S0ix is the new standard for W10 and beyond, in which the operating system attempts to itself shut down as many peripherals as possible, downclock the CPU, shut off unnecessary cores - but stay in ACPI S0. Basically just run normally, but try to be as power efficient as possible, following how mobile phones do things. Its big advantage is that it allows for varying levels of background processing (and eg. network connectivity) that just aren't possible with traditional S3. The downside is that it needs great hardware support within the OS and that it's a complex, system-wide effort to implement (like, needs application cooperation). Linux's S0ix support (via s2idle) is quite mediocre right now.

S3 sleep is the same ACPI-driven suspend-to-RAM mode that PCs have been shipping with for decades, in which a complex rube goldberg of DSDT and platform controller pokes ends up making a CPU stop running, having saved its entire state into RAM. The upside of S3 sleep is that it generally works, unless a machine's ACPI DSDT is terribly broken (which still unfortunately happens). The downside is that it's pretty much binary (either you sleep or you don't) and that you can't control what wakes you up. I mean, there's some ACPI mechanisms for it, but they're limited and janky.

New Thinkpad BIOSes can let you choose between either exposing old-school S3 via ACPI for non-W10 systems, or enabling S0ix functionality for W10. The default is generally S0ix/s2idle.

See: https://www.kernel.org/doc/Documentation/power/states.txt

Re:Why does Linux have so much trouble sleeping and waking? by stainforth on Friday December 11, 2020 @12:16PM (#25388095)
What percent power savings are achieved?
Re:Why does Linux have so much trouble sleeping and waking? by giantrobot on Friday December 11, 2020 @01:06PM (#25388681)
IME the S0ix sleep on a fully charged battery could last ones of days. So sleeping for an afternoon or overnight doesn't drain the battery too much. With S3 sleep I've had systems sleep for more than a week with only a little battery loss. It's only keeping RAM refreshed so it's way lower power than even just minor (massively under locked) CPU activity.

That being said I have not owned a laptop in the past decade that I trusted to sleep when running Linux. I've had nothing but problems with things like WiFi not coming back up or the machine randomly waking up in the middle of the night.

Those machines running Windows are much better. But really the only machines I trust to wake and sleep reliably are Macs. I haven't run into major sleep/wake issues on Mac laptops in twenty years of owning them.

Re:Why does Linux have so much trouble sleeping and waking? by q3k on Friday December 11, 2020 @12:24PM (#25388186)
Percent of what? This all depends on the particular hardware. If you want hard data, measure this yourself on your own device.
Re:Why does Linux have so much trouble sleeping and waking? by danieldk on Friday December 11, 2020 @11:59AM (#25387883)
There is a nice blog post that describes this:

https://brauner.github.io/2018/09/08/thinkpad-6en-s3.html

I recently bought a T14, which also has this option.

(It enables S3 sleep.)

Re:Why does Linux have so much trouble sleeping and waking? by lwhalen on Friday December 11, 2020 @12:00PM (#25387902)
Thanks very much!
Re:Why does Linux have so much trouble sleeping and waking? by evolve2k on Friday December 11, 2020 @09:44AM (#25386318)
Which laptops get this right then? Any of them?
Re:Why does Linux have so much trouble sleeping and waking? by Delk on Friday December 11, 2020 @10:01AM (#25386495)
I'd expect e.g. Ubuntu certified devices [1] to handle it. There are certified laptops from at least Dell and Lenovo, and probably the odd model from other manufacturers. While the certification technically only means the hardware is compatible with Ubuntu, and perhaps only as pre-installed by the OEM, in practice that probably means general Linux compatibility. I have trouble seeing any point in making Ubuntu-specific tweaks to an OEM install, as it's easier to just send only the models with compatible components for certification (or to pick compatible components in the first place, which may be feasible at least for premium laptops).

But as a user, you do have to pick your hardware.

My ThinkPad X240 has been suspending and resuming reliably for the majority of the last 6 to 7 years. There was a time when the touchpad didn't work after resume without tweaking (in Fedora), which was annoying and surprising and something that IMO shouldn't have happened. But other than that there have been no issues.

[1] https://certification.ubuntu.com/

Re:Why does Linux have so much trouble sleeping and waking? by dmytton on Friday December 11, 2020 @03:20PM (#25390439)
I have a Star LabTop Mk4 running Manjaro which suspends and resumes without any issues (laptop lid as well as sleep from OS). They build their laptops specifically for Linux and test on a range of major distros.

See https://starlabs.systems/ and https://starlabs.kb.help/compatibility-reports/

Re:Why does Linux have so much trouble sleeping and waking? by pferde on Friday December 11, 2020 @04:13PM (#25391072)
I've used two or three HP Elitebooks in past few years, and suspend/resume, as well as hibernation/resume just worked on them. I never even really thought about it, to be honest, I just used it - mostly just suspend - daily.

Curiously enough, some of my colleagues which have the same laptop model running Windows, complain that their laptops only wake up about 50% of the time, ever since we had a mandatory upgrade to Windows 10.

Re:Why does Linux have so much trouble sleeping and waking? by sigio on Friday December 11, 2020 @09:46AM (#25386341)
Had no issues with my current thinkpad (t480) and previous thinkpads (x240, x220, edge 11)
Re:Why does Linux have so much trouble sleeping and waking? by war1025 on Friday December 11, 2020 @12:34PM (#25388302)
I've always had good luck with Dell's Inspiron line. Have had three of them now that worked perfectly well. I always pick hibernate over sleep though, so I guess I can't say how sleep works on them.
Re:Why does Linux have so much trouble sleeping and waking? by sds357 on Friday December 11, 2020 @01:02PM (#25388641)
My Thinkpad L440 has never properly been able to use sleep or hibernate modes with Ubuntu, I have to shut down completely.
Re:Why does Linux have so much trouble sleeping and waking? by fwsgonzo on Friday December 11, 2020 @09:55AM (#25386441)
I have a Carbon X1 and it works perfectly, including the fingerprint unlock and the touchscreen.
Re:Why does Linux have so much trouble sleeping and waking? by smartbit on Friday December 11, 2020 @01:03PM (#25388644)
what version X1 do you have? And which distribution do you run on it?
Re:Why does Linux have so much trouble sleeping and waking? by fwsgonzo on Tuesday December 15, 2020 @04:05PM (#25435251)
I don't know which one it is. I bought it in autumn 2019 and it has a touch screen. I run bog standard Ubuntu 20.04 LTS on it.
Re:Why does Linux have so much trouble sleeping and waking? by cat199 on Friday December 11, 2020 @09:49AM (#25386374)
anyone that sells a linux on top; failing that its a crapshoot which mostly depends on developer popularity of that model / devices
Re:Why does Linux have so much trouble sleeping and waking? by vetinari on Friday December 11, 2020 @12:23PM (#25388184)
Sleep and hibernate have nothing to do with drivers.

They are done via ACPI. ACPI is implemented by the device vendor, is part of BIOS/UEFI and is notoriously buggy.

Re:Why does Linux have so much trouble sleeping and waking? by dyingkneepad on Friday December 11, 2020 @01:47PM (#25389151)
Driver developer here. The sentences above are just plain wrong.

Drivers have to implement callbacks for suspend. A driver needs to make sure it saves all of its state before the suspend, and then it needs to make sure it restores all of its state after resume. S3 suspend often kills the state of every register that was previously written.

Re:Why does Linux have so much trouble sleeping and waking? by usr1106 on Friday December 11, 2020 @12:59PM (#25388601)
> Sleep and hibernate have nothing to do with drivers.

That sounds like a brave statement to me.

Without knowing many details I believe that drivers can block the system from hibernating when they don't cooperate correctly.

I am absolutely sure during wakeup the driver needs to cooperate correctly. There are numerous cases that some device does no longer work correctly after wakeup. I doubt that ACPI alone can be blamed for all of the issues, even if I don't like the close source nature of ACPI.

Is there any open source approach to ACPI? Not that I'd expect to work better right away. But you know whom to blame. In the worst case yourself for not starting to fix it.

Re:Why does Linux have so much trouble sleeping and waking? by Overdr0ne on Friday December 11, 2020 @12:57PM (#25388584)
No. Linux drivers are supposed to implement runtime_pm callbacks. These are called based on the usage counter of those devices. ACPI is an Intel/microsoft standard for power state definition with spotty compliance. How and when you put those devices into whatever power state, ACPI or not is dictated by those callbacks. Bugs seem to most often occur when you turn off something when it is still being used cuz someone failed to claim it or released it too soon. Also asic bugs in their definitions of their power states.
Re:Why does Linux have so much trouble sleeping and waking? by dyingkneepad on Friday December 11, 2020 @01:44PM (#25389120)
runtime_pm is generally for runtime suspend (Intel calls it s0ix) instead of S3 suspend. You can implement S3 suspend using the same callbacks as your runtime_pm callbacks, but you don't need to.

The runtime_pm framework is for when applications are still running but the device goes to sleep. In S3 suspend first every single user space application freezes, then the drivers go to sleep. S3 is much easier to implement.

Re:Why does Linux have so much trouble sleeping and waking? by Overdr0ne on Friday December 11, 2020 @04:57PM (#25391751)
I think ideally all pm would be controlled by the runtime_pm and qos frameworks. You then don't need to define explicit power states like 'sleep' or 'suspend', you instead simply use what you need for a given performance spec and naturally use a minimum of power. I think that is the ultimate plan
Re:Why does Linux have so much trouble sleeping and waking? by dyingkneepad on Friday December 11, 2020 @06:20PM (#25393006)
It's not that simple. There's a lot of predicting the future when it comes to power management. When you put things to sleep in order to save power you add latency, because waking up the hardware and restoring its state takes a long time. It's all tradeoffs, and "use minimum power" is taking the slider and shifting it all the way to one side.
Re:Why does Linux have so much trouble sleeping and waking? by _notreallyme_ on Friday December 11, 2020 @01:12PM (#25388746)
Well, there is a driver for ACPI. I have the vague souvenir of Linus Torvalds calling BIOS/UEFI dev "monkeys on crack" or something along the line...
Re:Why does Linux have so much trouble sleeping and waking? by raverbashing on Friday December 11, 2020 @01:14PM (#25388768)
Yes but on top of that Linus had a very "stern taking to" kernel developers who would fix it for one model but break it for others, so has made sure developers wouldn't break each others code
Re:Why does Linux have so much trouble sleeping and waking? by kodah on Friday December 11, 2020 @01:18PM (#25388818)
> Sleep and hibernate have nothing to do with drivers.

I think this is halfway accurate. Drivers are part of the problem and firmware is the other. Other folks in this thread have gone on to explain it better than I can, so I'll just point you to them.

That said, I think things like the new firmware update manager that connects device creators to the Linux ecosystem so they can provide smooth and regular updates to users are pivotal to solving these kinds of problems.

I've had less problems on PopOS due to this. Firmware updates have at times completely eradicated the more usual problems I experienced with Linux, which in an uneducated guess, probably boiled down to interoperability.

Re:Why does Linux have so much trouble sleeping and waking? by kinleyd on Friday December 11, 2020 @01:29PM (#25388931)
I remember trying to set up a PVR and getting pretty far using mpv and at. The system worked as long as it was left on. rtcwake was the bridge that was too far: Upon waking, recording started but ACPI errors occurred soon after, culminating with ivtv reporting the encoder had died. I never got past that stage, but it was a worthy try - and I learned that some bugs ain't never going to be fixed. Edit: It was an Arch setup from about 5 years ago.
Re:Why does Linux have so much trouble sleeping and waking? by 1996 on Friday December 11, 2020 @12:48PM (#25388484)
Some manufacturer selectively implement ACPI (ex: no S3 or S4, only S0 for connected standby) making things worse
Re:Why does Linux have so much trouble sleeping and waking? by petermcneeley on Friday December 11, 2020 @11:52AM (#25387802)
I would add that this is also related to "The 30 million line problem" aka massive OS complexity due to a plethora of heterogenous hardware.

https://youtu.be/kZRE7HIO3vk

Re:Why does Linux have so much trouble sleeping and waking? by everdrive on Friday December 11, 2020 @09:55AM (#25386443)
On some laptops and desktops it works flawlessly. This is purely anecotal, but my last 5-7 linux computers over the years (~15 years) have never had issues sleeping and waking.

Usually, I've been running something that is either not very new, or else, is specifically branded as having linux support.

Re:Why does Linux have so much trouble sleeping and waking? by easde on Friday December 11, 2020 @08:53PM (#25394506)
I don't think I've encountered a single smartphone by a reputable vendor that has had significant issues sleeping, no matter the chip vendor or OS.

Meanwhile people do have serious issues with sleep even on Intel Macs running MacOS and Thinkpads running Windows. For whatever reason PC chip / hardware vendors just cannot get sleep to work properly. Apparently the problem is so low-level that even a company like Apple cannot paper over the problems without throwing out Intel entirely and using their own SoC in the new Macbooks.

Re:Why does Linux have so much trouble sleeping and waking? by kreetx on Friday December 11, 2020 @09:36AM (#25386236)
E.g on my 2015 macbook pro I need to remove and re-add the wifi driver module to make it connect.
Re:Why does Linux have so much trouble sleeping and waking? by Klonoar on Friday December 11, 2020 @03:46PM (#25390761)
...what?

The 2015's were incredibly solid machines, I've never heard of an issue like this happening. I still daily my 2015MBP and the thing is an absolute tank where everything just works.

I would literally bet money that your issue is hardware, not software.

Edit: I realize now that this comment could be referring to running Linux on a 2015 MBP, in which case I'm a moron and we can just disregard my comment.

Re:Why does Linux have so much trouble sleeping and waking? by kreetx on Saturday December 12, 2020 @12:45AM (#25395908)
Yeah, it's Linux. :) macOS always ran nicely, and the hardware itself is great. I think if somebody more capable in Linux kernel/drivers' hacking looked into it they could fix it, it's just that nobody cares (and `rmmod brcmfmac && modprobe brcmfmac` is simple enough).
Re:Why does Linux have so much trouble sleeping and waking? by ncmncm on Friday December 11, 2020 @05:10PM (#25392003)
I have not seen this problem on Linux in the past decade.

I am obliged to conclude that it must be just an NVidia problem, because I always avoid those. (My laptops are built with an NVidia chip in them, but powered off. On-chip Intel graphics work very, very well lately.)

Re:Why does Linux have so much trouble sleeping and waking? by graposaymaname on Friday December 11, 2020 @01:58PM (#25389292)
Would it be for the same reason that it takes too long to shutdown? My laptop (dualboot - ubuntu/windows) takes significantly longer to shutdown when on linux. Even with the SSD - which made windows really faster.
Re:Why does Linux have so much trouble sleeping and waking? by Zancarius on Friday December 11, 2020 @02:34PM (#25389780)
I have a desktop that shuts down nearly instantly and a ThinkPad that shuts down nearly instantly.

I have another laptop that takes about a minute to shut down, and it appears related to the wireless NIC. While it's an Intel-based card (Killer-rebranded... absolute garbage), I've had nothing but trouble with it. I plan on swapping it out one of these days.

Re:Why does Linux have so much trouble sleeping and waking? by Delk on Friday December 11, 2020 @02:39PM (#25389877)
Perhaps, or maybe some service just keeps hanging for some reason before it shuts down. It might be a software matter, too.
Re:Why does Linux have so much trouble sleeping and waking? by raffraffraff on Saturday December 12, 2020 @06:25AM (#25397588)
Yup. Go for the most boring hardware you can. No fancy GPU. Or be willing to spend time editing blacklist files, or writing your own rmmod/modprobe hooks for sleep/wake.
Re:Why does Linux have so much trouble sleeping and waking? by cultus on Friday December 11, 2020 @11:57AM (#25387861)
One particular issue is that nobody actually implements the ACPI power management protocol correctly.
Re:Why does Linux have so much trouble sleeping and waking? by vlovich123 on Friday December 11, 2020 @12:03PM (#25387939)
Then the problem is with the protocol no? Seems like an architectural issue that the Linux community needs to spearhead with HW vendors to resolve. Good standards that reduce sources of error are the only antidote to vertical integration approaches that big tech is going down.
Re:Why does Linux have so much trouble sleeping and waking? by zhengyi13 on Friday December 11, 2020 @12:13PM (#25388058)
I think even the best standards can have ambiguities. SHOULD, MAY, etc.

Assuming you're not running a Mac (where the vendor controls the entire stack), you've got your OS vendor, your MB vendor, your every-single-external-device-vendor...

... and the interactions of all this hardware mediated through the OS, its drivers, and the reading comprehension and the development pressures of every single dev who's worked on any part of this stack.

There's an awful lot of room for ambiguities there. Protocol definition at this level is kind of a collaborative lurching towards consensus.

Re:Why does Linux have so much trouble sleeping and waking? by adrianmonk on Friday December 11, 2020 @01:32PM (#25388967)
> problem is with the protocol

I wouldn't assume so. Is there a problem with the spec for using your turn signals while driving? And yet...

Re:Why does Linux have so much trouble sleeping and waking? by vlovich123 on Friday December 11, 2020 @05:04PM (#25391893)
I’ve implemented a lot of protocols. The more complex a protocol is and the more moving parts, the harder it is.

The fundamental challenge is complexity. Understanding how to build this stuff is a mix between figuring out which complexity to expose to “the masses” (masses here being other developers) and what else to hide in abstractions or better tooling.

I think the market would look very different if senior Linux kernel maintainers (including Torvalds) got together and said “this is the Linux power save API - implement it”. The challenge is that the same HW powers Windows (and used to power Macs and probably still does to at least some degree). No protocol worth a damn can handle that much variability. So then the question is can the firmware and driver code be given less to be responsible for rather than more and then let the kernel make all the decision making power. The problem with ACPI (at least as I understand it from reading about it superficially - I’ve never read the spec itself) is that decision making is extremely interdependent with the kernel ultimately not being fully in charge of decisions.

For example, a simple design for something like this is defining ACPI-lite that handles 80% of the hardware that ACPI currently supports but that drastically simplified the mental model and lets the kernel implement all the common logic with the driver and firmware not being responsible for anything more than translating kernel commands to the HW. Then you leave ACPI for the remaining 20% of HW that doesn’t fit in the bucket but you also make the warning verbose (you’re running legacy ACPI device X - this may degrade your battery power / prevent sleep wake from working effectively).

If they can also get Windows kernel engineers on board then you would have a compelling market forcing function on HW makers/driver writers to simplify their code.

Re:Why does Linux have so much trouble sleeping and waking? by adrianmonk on Sunday December 13, 2020 @04:53PM (#25410714)
I'm not negating that complexity is a problem. I'm saying that there are two problems, complexity and incentives.

If you want someone to do something, then you must make it realistic for them to do it, and you must make sure that they have some reason to bother.

When shopping for computer components, do people research whether that graphics card or USB hub behaves well in power saving modes? And if they wanted to, do they have easy access to that information? If not, then manufacturers will probably not prioritize it. They will prioritize whatever goes into the purchasing decision instead.

Though it is good in a way to know that there are specific things that could be improved on the technical side, because it means there's the possibility that things could be better.

Random thought: maybe some organization whose mission is energy conservation (government like Energy Star in the US or nonprofit) would be willing to fund the software revamp. Maybe in combination with people who pay data center electric bills.

Re:Why does Linux have so much trouble sleeping and waking? by cultus on Friday December 11, 2020 @12:28PM (#25388235)
Yeah, it seems most tech standards are design-by-committee disasters.