bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
MIT License
1.34k stars 62 forks source link

Fixed suspend in nvidia and hybrid mode #127

Closed Boria138 closed 1 year ago

Boria138 commented 1 year ago

I had suspend not working on nvidia and hybrid mods after I added to envycontrol settings for nvidia from https://github.com/CachyOS/CachyOS-Settings everything worked.

bayasdev commented 1 year ago

I wonder if removing

options nvidia NVreg_PreserveVideoMemoryAllocations=1

prevents Gnome Wayland from showing up

Boria138 commented 1 year ago

I wonder if removing

options nvidia NVreg_PreserveVideoMemoryAllocations=1

prevents Gnome Wayland from showing up

As far as I know it defaults to 1, but I'll check that tomorrow and report back

Boria138 commented 1 year ago

Oh, a little off-topic pr but I'll write here anyway, I talked to someone who tweaks Nvidia for CachyOS about the fact that they include rtd3 by default on all cards including those that are not supported, referring to you I wrote that this is not a good practice, to which I replied that in Fedora also in the default drivers is rtd3 and no one has complained about the problem of power saving, so you have faq error rtd3 can be enabled on older cards before Turing nothing will happen.

Boria138 commented 1 year ago

It also seems to me that you can remove the disabling of usb devices because since the kernel version 5.5 they work normally, and now even on lts kernel like 5.15 so it is not to the point

Boria138 commented 1 year ago

@bayasdev I take it because my pr hides Wayland session in GDM you will not add it ? It's just that you haven't contacted me for a whole day, then I guess pr can be closed ?

Boria138 commented 1 year ago

If you're still going to take the pr I'll tweak it a bit, because even though Nvidia's website says that since kernel 5.5 all disable devices work fine with dynamic power management I've had my computer freeze during tests without disabling these devices, I guess I was too hasty in removing their disablement.

pingarelho commented 1 year ago

Is this on AMD + Nvidia? Cause I'm having issues on hybrid mode when waking up from sleep. I'm getting errors amdgpu: couldn't schedule ib on ring <gfx-low> and [amdgpu] *ERROR* Error scheduling IBs (-22).

Boria138 commented 1 year ago

Is this on AMD + Nvidia? Cause I'm having issues on hybrid mode when waking up from sleep. I'm getting errors amdgpu: couldn't schedule ib on ring <gfx-low> and [amdgpu] *ERROR* Error scheduling IBs (-22).

I've only tested with intel + Nvidia, whether this fix will help you I don't know, but you can always grab envycontrol from my repository and try it out

bayasdev commented 1 year ago

If you're still going to take the pr I'll tweak it a bit, because even though Nvidia's website says that since kernel 5.5 all disable devices work fine with dynamic power management I've had my computer freeze during tests without disabling these devices, I guess I was too hasty in removing their disablement.

@Boria138 sadly I don't own any Nvidia hardware newer than Pascal so I'm unable to test your changes. Those Udev rules come from the official Nvidia docs through.

Boria138 commented 1 year ago

If you're still going to take the pr I'll tweak it a bit, because even though Nvidia's website says that since kernel 5.5 all disable devices work fine with dynamic power management I've had my computer freeze during tests without disabling these devices, I guess I was too hasty in removing their disablement.

@Boria138 sadly I don't own any Nvidia hardware newer than Pascal so I'm unable to test your changes. Those Udev rules come from the official Nvidia docs through.

I've already returned the rules back as without them there were freezes, which is strange because on the Nvidia website it is written that the drivers work normally with kernel 5.5, but no matter I returned it and also removed nvidia-uvm as specifically to manage hybrid graphics it is not needed, it only fixes the error in plymouth.

Boria138 commented 1 year ago

PR is ready and tested, I'd also like to ask @pingarelho to do a test as I only have intel and haven't checked if this will fix the sleep when using amd

bayasdev commented 1 year ago

@Boria138 also add a try catch block around the calls to subprocess.run where you toggle the systemd unit as it may fail on systems that use other init system

Boria138 commented 1 year ago

@bayasdev review my code please

bayasdev commented 1 year ago

@Boria138 thanks, will test later after I get access to my gaming laptop. So far it looks good.

pingarelho commented 1 year ago

@Boria138 will gladly test that for you when I have time! today or tomorrow I'll post an update here.

pingarelho commented 1 year ago

Can confirm that this PR fixes waking up from sleep on my Ryzen 5 4600H + GTX 1650 laptop in hybrid mode with rtd3. Awesome.

Boria138 commented 1 year ago

@bayasdev I already wrote it above but I will repeat in the faq you wrote that using rtd3 on unsupported hardware increases battery consumption which is probably not true because first of all at the moment rtd3 is completely broken and therefore you could not make correct measurements secondly this feature is enabled by default at least in Fedora and Manjaro I have not noticed any complaints from owners of unsupported hardware so could you do the test again with my corrections so as not to mislead people if you are really wrong ?