Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for hibernation (S4) for all NovaCustom laptops #471

Closed
wessel-novacustom opened this issue Aug 2, 2023 · 20 comments
Closed

Support for hibernation (S4) for all NovaCustom laptops #471

wessel-novacustom opened this issue Aug 2, 2023 · 20 comments
Labels
enhancement New feature or request

Comments

@wessel-novacustom
Copy link

The problem you're addressing (if any)

Users expect to be able to resume their laptop, even after - let's say - 24 or 48 hours after they put the laptop in suspend mode (either triggered by closing the lid, FN+F12 or selected in the OS).

Describe the solution you'd like

Support for hibernation (S4) and suspend-then-hibernate.

Where is the value to a user, and who might that user be?

Even though hibernation is relatively little used, hibernation can still be triggered in most GNU/Linux operating systems and Windows.

Moreover, it can be a perfect solution for HAP disabled devices without S3 support. In such case, suspend mode doesn't reach the lowest power state, causing the battery to drain in suspend mode.

But even for S3 supported devices, it can help tremendously to extend the battery life while suspending. For example, users might be able to setup a suspend-then-hibernate policy. This would mean that if the laptop wasn't resumed from suspend after x hours, the laptop would hibernate. This would save a lot of energy, meaning almost no battery is being drained while in suspend mode.

Obviously, it would be a requirement to restore the state of all applications after resuming from hibernation (as it should be).

Describe alternatives you've considered

We are aware that hibernation requires a swap partition and a modified GRUB configuration in order to work. In some cases, the operating system files need to be changed as well. Nevertheless, we didn't succeed in getting hibernation working in either GNU/Linux nor Windows.

Additional context

No response

@wessel-novacustom wessel-novacustom added the enhancement New feature or request label Aug 2, 2023
@keybounce
Copy link

Additional comment:

  1. A laptop's design goal is to be moved. So hibernating, then moving the set up -- including an external drive with lots of video files, and a second monitor -- should not mess up the programs running. I have seen forcing filesystems to disconnect/reconnect, which invalidates any program running off of the external or any program that has files open on the external; moving all windows off the external monitor to the internal.

  2. When doing a presentation, I want to be able to set things up at home, move to some place, and just go. Even if I have everything set up to only be using the internal drive, I want my programs to maintain their state/status, the windows to maintain positions (so my laptop screen has presentation controls, and the external hookup has the information being displayed).

It isn't just your laptops. I'm realizing now that I haven't seen a UEFI laptop that properly hibernated in 20 years, and the last time I saw a machine that could do it properly was a desktop.

(The current work-around is to book an extra half hour for prep time beforehand. I'd like to be able to eliminate that.)

The mention of "laptops without S3 support" -- It seems that modern systems are moving away from S3 support now. It's like the "one size fits all" / "if it works for us in corporate, it will work for everyone everywhere" model of apple/google/microsoft is taking over.

Please, be better. :-)

@wessel-novacustom
Copy link
Author

@keybounce Thank you for leaving your comment. I agree and that's why I opened this ticket in the first place.

About S3: we took a lot of time to investigate this and we came to the conclusion that the S3 suspend mode is not possible due to the NS5x/NS7x (ADL) hardware design. So that's another reason to add hibernation support (S4) as an alternative solution.

@miczyg1
Copy link
Contributor

miczyg1 commented Aug 8, 2023

Hibernation should be already available. I have tested it and works out-of-the-box on Windows 11 (restored all opened windows and applications I had before hiberating), however one must unhide the Hibernate option first: https://support.microsoft.com/en-us/windows/shut-down-sleep-or-hibernate-your-pc-2941d165-7d0a-a5e8-c5ad-8c972e8e6eff

There are rumors that hibernation is not suitable for SSDs due to its faster wear out. However, limiting the frequency of hibernation and simply doing shutdown wherever applicable won't make much difference. But doing hibernation 10 times a day with nearly full RAM may be a bit tough for the SSD.

Ubuntu 22.04 needs extra steps to do hibernation.

  1. Installing pm-utils package
  2. Preparing a swap partition (unfortunately it is not created in modern installations, so one has to either shrink rootfs and make swap equal to RAM size or do a fresh install with swap prepared during partitioning).
  3. Point to swap partition in kernel cmdline.

Some documentation how to do it: https://www.linuxandubuntu.com/home/how-to-enable-hibernate-in-ubuntu-linux
Also when there is LUSK disk encryption involved, the some extra caution is needed: https://wiki.archlinux.org/title/Dm-crypt/Swap_encryption#With_suspend-to-disk_support

Also no idea how QubesOS/Xen hypervisor will behave, but it seems to not be supported: QubesOS/qubes-issues#2414

@keybounce
Copy link

keybounce commented Aug 8, 2023 via email

@wessel-novacustom
Copy link
Author

Thank you very much for your explanation, @miczyg1. I have discussed this with @macpijan today and it should be part of the test scope (if it's feasible of course).

We have seen as well that hibernation works properly on a NV41-ADL laptop with Windows. But in another case (NS7x-ADL) while using Kubuntu, the state of opened applications was not restored when booting after hibernation. We did follow the steps you mentioned (among adding the GUI option for hibernation) and no disk encryption was applied.

It's a valid point that the support from the OS should be there, so it's just no option for OSes like Qubes. But it should be working from the firmware side under Ubuntu and Windows 11, which should be tested for a next release.

Maybe we can even get support for suspend-then-hibernate.

About the SSD story: that's a good point. This is why it would be preferable to have a suspend-then-hibernate solution for all NovaCustom Dasharo laptops, where hibernation isn't triggered very soon but only after x hours or even days of not using the laptop. I don't believe there are cases in which hibernation is used multiple times on a day and on a daily base.

It's a good thing to mention again that S0ix nor S3 is available for the NS5x/NS7x devices with Intel ME disabled. This is another reason why it's a priority request. S4 hibernation would be an acceptable alternative for traveling, while S2Idle is not (as the fan is still on and laptop is still hot during traveling). You can say users to fully shut down the laptop instead, but the use case is that the customer wants to resume and work again without having to close and/or reopen applications.

I'm sorry for the delay this can cause for the new firmware release.

@miczyg1
Copy link
Contributor

miczyg1 commented Aug 8, 2023

About the SSD story: that's a good point. This is why it would be preferable to have a suspend-then-hibernate solution for all NovaCustom Dasharo laptops, where hibernation isn't triggered very soon but only after x hours or even days of not using the laptop. I don't believe there are cases in which hibernation is used multiple times on a day and on a daily base.

This is basically all on OS settings and policies configured to prioritize S3 over S4 or wait at least X hours before hibernate. not much firmware can do about it.

@wessel-novacustom
Copy link
Author

Ah okay. Yes, so then let's make sure S4 is working on NovaCustom laptops by adding it to the test scope.

@miczyg1
Copy link
Contributor

miczyg1 commented Sep 5, 2023

I have actually found a way to not reinstall Ubuntu and not make a large swap. One can create a swapfile and save the state there on rootfs: https://linuxhint.com/enable-hibernate-ubuntu-22-04-lts/

@miczyg1
Copy link
Contributor

miczyg1 commented Sep 5, 2023

After following the above process (except that I had a previously prepared swap partition instead of swapfile) it worked perfectly on Ubuntu 22.04. Also adding the Hibernate option to the power off options in the GUI worked as well.

@wessel-novacustom
Copy link
Author

That's great! Can you confirm that it also works with multiple applications running and that they restore fine from hibernation?

@miczyg1
Copy link
Contributor

miczyg1 commented Sep 5, 2023

@wessel-novacustom before the hibernation I had opened: terminal, file explorer and Firefox. All have been restored properly on the screen when booted again.

@wessel-novacustom
Copy link
Author

That's great! Can you please confirm there is no firmware-side implementation needed?

Is it nevertheless useful to add this to the test scope? Or wouldn't it make any sense because firmware is maybe not involved? I don't know to what extend firmware is involved.

@miczyg1
Copy link
Contributor

miczyg1 commented Sep 5, 2023

That's great! Can you please confirm there is no firmware-side implementation needed?

Confirmed, no modifications needed. You may as well use the latest link wit the guide I have provided and test on the latest release.

Is it nevertheless useful to add this to the test scope? Or wouldn't it make any sense because firmware is maybe not involved? I don't know to what extend firmware is involved.

Yes, we are working on adding hibernation to the test scope. Firmware has very little involvement in S4/hibernation (it just has to expose that S4 is supported) because it is not much different from regular power on. Most action is done on OS side

@wessel-novacustom
Copy link
Author

For simplicity, I will wait for the next firmware release and assume that it is working starting from then, even though with the need of some software modifications, which don't seem to be too hard, though.

Thank you again for your assistance!

@keybounce
Copy link

keybounce commented Sep 9, 2023 via email

@wessel-novacustom
Copy link
Author

@keybounce Could you please let me know what operating system, kernel version and Dasharo version you are using?

It's worth mentioning that I know about this problem from the past. Back then, I realised that the problem didn't occur if the touchpad and keyboard aren't touched before at least one second after the screen display has turned on again. Is this the case for you, too?

@keybounce
Copy link

keybounce commented Sep 9, 2023 via email

@pietrushnic
Copy link

Same version of the bios that was shipped -- not sure how to tell which one
that is.

sudo dmidecode -t bios

@keybounce
Copy link

keybounce commented Sep 12, 2023 via email

@wessel-novacustom
Copy link
Author

Ok, this is cool, especially with the suspend-then-hibernate feature. It seems to work fine, verified on the NV41 Series (12th Gen) with Dasharo v1.6.0 and Xubuntu, but requires some setup.

I just set this up for a customer by following this guide. I also installed pm-utils with the command sudo apt install pm-utils to make suspend-then-hibernation work. In fact, it automatically appeared in the menu of XFCE after going through these steps.

suspend-then-hibernate is very useful for those who disable Intel ME. Because by disabling Intel ME, the suspend mode S0ix (modern standby) uses ~3W instead of ~1W, draining the battery. With this suspend-then-hibernate policy, you can suspend the laptop and trigger hibernation after x seconds/minutes/hours. Plus, it can also increase the laptop's security in combination with disk encryption, although that hasn't been tested yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants