# suspend/resume



## joplass (May 25, 2019)

What do you guys do to suspend and resume your machines?  I use xfce4 power management settings.  The machine goes to sleep fine but when I resume by slightly pressing the power button, the machine does not wake up entirely.  Some lines marking the last application I was using are displayed on the screen. The mouse and keyboard have no effects.  I usually have to do a hard reboot.

Any advice?


----------



## k.jacker (May 25, 2019)

Suspend/resume does not work with Nvidia graphic cards as far as I know (never tested myself).
Apart from that, it usually works very well on almost all hardware.

When using the old and deprecated i915kms.ko driver from the base system, the system sometimes crashes during resume on some hardware.
The up-to-date graphics/drm-kmod driver from the ports works much better with suspend/resume from my experience.

And there is an open bug in the snd_uaudio.ko driver, that makes the computer seem to have crashed, but actually it's not, but all usb devices stall after resume if the audio device was in use.
(one can still ssh into the machine)

The sysutils/xfce4-power-manager executes `acpiconf -s3`, you can do that manually, too.
Run that as root and it will suspend to RAM your machine (FreeBSD does not yet support suspend to disk).
Your suspend settings seem ok, as you see the console during resume, and the system attempts to resume.

Could you provide some more hardware info and paste the console messages?

Edit: only external audio devices use the uaudio driver, that wouldn't affect you if you are using something else.


----------



## joplass (May 26, 2019)

I don't believe the forum admins will be happy if I pasted the output of 
	
	



```
dmesg
```
 here and 
	
	



```
lspci
```
 is not working for me.  The result I got is extremely long.  I do have the nvidia driver installed.  When I first installed FreeBSD, my screen was out of wack. 

Is there a particular hardware info I should post?


----------



## badbrain (May 26, 2019)

joplass said:


> I don't believe the forum admins will be happy if I pasted the output of
> 
> 
> 
> ...


Pastebin or something similar for very long text or just attach the text file.


----------



## k.jacker (May 26, 2019)

So you got nvidia graphics. I guess you're out of luck using suspend/resume then. I couldn't find any official info about suspend/resume not working with nvidia, searching the driver descriptions and the wiki, but I've seen several complains about that here on the forum. I haven't seen anyone complaining about it recently, but no positive news either.
You could paste the output from  `pciconf -lv | grep -A4 ^vga` and `dmesg | grep -iE 'vga|nvidia'` and ask if there are any Nvidia users that have information about current state of suspend/resume?"



joplass said:


> I don't believe the forum admins will be happy if I pasted the output of...


It's ok to paste something like _dmesg_. You could strip away irrelevant parts for better readability, but if you're not sure, paste the whole thing. So in general, no problem to paste log files or configuration files. You did perfectly right already when you asked what to paste in order to provide necessary information.
One shouldn't post screenshots when copy/paste of some text could be used.


----------



## joplass (May 26, 2019)

I hope someone else will chip in as you mentionned.  Thanks for your help.


----------



## joplass (May 26, 2019)

```
$ pciconf -lv | grep -A4 ^vga
vgapci0@pci0:1:0:0:     class=0x030000 card=0x404a1682 chip=0x040210de rev=0xa1 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'G84 [GeForce 8600 GT]'
    class      = display
    subclass   = VGA
$ dmesg | grep -iE 'vga|nvidia'
VT(vga): resolution 640x480
vtvga0: <VT VGA driver> on motherboard
vgapci0: <VGA-compatible display> port 0x2000-0x207f mem 0xa2000000-0xa2ffffff,0x80000000-0x9fffffff,0xa0000000-0xa1ffffff irq 16 at device 0.0 on pci1
vgapci0: Boot video device
nvidia0: <GeForce 8600 GT> on vgapci0
vgapci0: child nvidia0 requested pci_enable_io
vgapci0: child nvidia0 requested pci_enable_io
$
```


----------



## serjsk8 (Dec 13, 2020)

Hi joplass
I have the same issue with my NVIDIA card.
In my laptom Lenovo T530 I have NVIDIA card and Intel Graphic card.
When I use NVIDIA driver I can suspend my machine but can't resume.
If I use Intel Graphic driver I can suspend and resume with out problem.


----------



## kpedersen (Dec 13, 2020)

In the nvidia driver port there is an option for power management. Bizarrely it is off by default. My guess is if you compile the port after enabling that option, suspend and resume will be supported.


----------



## serjsk8 (Dec 13, 2020)

I have this options:

```
# pkg options nvidia-driver-390
nvidia-driver-390 - ACPI_PM: on
nvidia-driver-390 - DOCS: on
nvidia-driver-390 - LINUX: on
nvidia-driver-390 - WBINVD: off

$ sysctl sysctl hw.acpi.supported_sleep_state
hw.acpi.supported_sleep_state: S3 S4 S5
```

But after resume the machine does not wake up entirely and the mouse and keyboard have no effects.
Or some times I have some artifact like on pic:


----------



## joplass (Dec 14, 2020)

serjsk8 said:


> Hi joplass
> I have the same issue with my NVIDIA card.
> In my laptom Lenovo T530 I have NVIDIA card and Intel Graphic card.
> When I use NVIDIA driver I can suspend my machine but can't resume.
> If I use Intel Graphic driver I can suspend and resume with out problem.


So yes, there is another thread that explains that it is pratically impossible, for now at least, to resume sleep with NVIDIA drivers. Intel should work. If you don't need NVIDIA you should use the Intel driver.


----------



## sandrain (Apr 4, 2021)

I am just wondering if any solution for this suspend/resume problem exists yet.


----------



## Snurg (Apr 4, 2021)

Since five years, I have said it felt 10000 times:
There is a bug in vesa.ko which breaks resume on Nvidia cards.

Comment out this line with the bad BIOS call that causes the Nvidia driver to hang when resuming in /usr/src/sys/dev/fb/vesa.c and rebuild + install kernel.


```
case STATE_LOAD:
        bcopy(p, vesa_state_buf, vesa_state_buf_size);
/*
        x86bios_intr(&regs, 0x10);
*/
        break;
    }
```

*It is so simple.
Just remember to reapply the fix and rebuild and install kernel every time after you ran  freebsd-update.*

I am at complete loss why this bug has been present since the FreeBSD security officer found already in FreeBSD 9.0 times that vesa.ko breaks resume with Nvidia cards, but apparently didn't bother insisting the bug to be identified and fixed.
So I had to do this.

Please also see these links for some background info:






						253733 – vesa.ko: Invalid BIOS call when resuming from S3 suspend/sleep causes nvidia driver hang
					






					bugs.freebsd.org
				











						Solved - Please, assist me in correctly wording a PR to get a 12-year-old kernel module bug fixed!
					

Since its introduction in 2009, the vesa.ko kernel module contains a bug, presumably of the category "use of uninitialized data structures".  This bug prevents the system resuming correctly on systems with nvidia graphics card and using the sc console in text mode. To build+install a custom...




					forums.freebsd.org
				








						224069 – X, text console and suspend/resume fail
					






					bugs.freebsd.org
				



https://wiki.freebsd.org/SuspendResume (see all the notes about having to remove the VESA driver from the kernel to make suspend/resume work)


----------



## sandrain (Apr 4, 2021)

Thanks Snurg . 

This has been bugging me for a while, and it seems like your patch fixes it. I've tested repeatedly, and no problems so far.


----------



## Les Ferguson (Oct 30, 2021)

Snurg said:


> ...
> There is a bug in vesa.ko which breaks resume on Nvidia cards.
> Comment out this line with the bad BIOS call...
> ...see all the notes about having to remove the VESA driver from the kernel to make suspend/resume work


So which is the best option?  Change the code for vesa.ko or remove vesa from the kernel?
Is vesa.ko required?
Do I need to get sources and build a kernel for both options?

edit: in fact it doesn't look like vesa is being loaded. how can I tell if it is affecting sleep or resume actions?
The sleep command in KDE makes everything appear to sleep, but I can't wake it back up.


----------



## grahamperrin@ (Oct 31, 2021)

Recently:



Les Ferguson said:


> It's an old AMD Athlon PC. …



Which version of FreeBSD, exactly? 

`freebsd-version -kru`

`uname -aKU`

Can you describe the graphics hardware? 

`pciconf -lv | grep -B 3 -A 2 display` 

– or, as previously suggested, share the result of a probe. Thanks.


----------



## Les Ferguson (Nov 1, 2021)

Version is:  FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 1300139 1300139

I had a nvidia card, GeForce 8600 GT, which was working nicely with KDE, apart from not being able to resume from sleep.
I took out the graphics card to try it with the onboard chip:  Integrated ATI Radeon HD3200
This shuts down on the sleep command but also cannot be woken up again.

pciconf:
vgapci0@pci0:1:5:0:     class=0x030000 rev=0x00 hdr=0x00 vendor=0x1002 device=0x9610 subvendor=0x1458 subdevice=0xd000
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'RS780 [Radeon HD 3200]'
    class      = display
    subclass   = VGA
hdac0@pci0:1:5:1:       class=0x040300 rev=0x00 hdr=0x00 vendor=0x1002 device=0x960f subvendor=0x1458 subdevice=0x960f

CPU is: hw.model: AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
Mobo: https://www.gigabyte.com/Motherboard/GA-MA78GM-S2HP-rev-21#ov


----------



## grahamperrin@ (Nov 1, 2021)

Les Ferguson said:


> FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr 9 04:24:09 UTC 2021



Please update the system.


----------



## Les Ferguson (Nov 2, 2021)

grahamperrin said:


> Please update the system.


Ok now I have FreeBSD 13.0-RELEASE-p4,  but same issue persists.
I have this occurring 40 times in dmesg:
ACPI Error: AE_NOT_FOUND, While resolving a named reference package element - LNKB (20201113/dspkginit-605)

which could be related.
This PC has been able to use sleep mode and resume ok running Linux and Windows 7, so not sure why it is so hard to achieve it with FreeBSD.


----------



## Les Ferguson (Nov 6, 2021)

Finally updated the BIOS and can now resume from sleep by tapping the power button.  Cool.
Not sure if I can also get the keyboard to wake it up, but this is great progress.


----------



## grahamperrin@ (Nov 28, 2021)

Snurg said:


> … <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253733> …



Cross-reference: 









						Solved - (CURRENT) options VESA removal from x86 GENERIC and x86 MINIMAL
					

Heads-up:   Partial context:   … background info:  [URL unfurl=true]https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253733[/URL]  …




					forums.freebsd.org


----------

