bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
https://bayas.dev/envycontrol
MIT License
1.14k stars 55 forks source link

[BUG] Nvidia_drm.modeset=1 is not properly set, based on nvidia module names in /lib/modules/[your-kernel-version]/updates/dkms #144

Closed Klusio19 closed 8 months ago

Klusio19 commented 8 months ago

Describe the bug If nvidia modules in /lib/modules/[your-kernel-version]/updates/dkms are named different than nvidia for example I have (and there will be plenty of people which will have the same name) nvidia-current-drm.ko, nvidia-current-modeset.ko, nvidia-current-peermem.ko, nvidia-current-uvm.ko, nvidia-current.ko, which is basically nvidia-current, instead of nvidia the nvidia_drm.modeset=1 will not be applied, thus you won't be able login to Wayland session, etc.

To check if nvidia_drm.modeset is loaded, I run: sudo cat /sys/module/nvidia_drm/parameters/modeset. If the answer is 'Y' it is loaded. If it's 'N', it's not.

To Reproduce Steps to reproduce the behavior:

  1. Run sudo envycontrol -s nvidia (or sudo envycontrol -s hybrid)
  2. Nvidia_drm is not loaded if you have different nvidia modules names as described earlier.

Expected behavior Properly load nvidia_drm.

System Information:

Additional context To properly load nvidia_drm, (if you have different nvidia modules names like described earlier, in my case nvidia-current) change line generated by EnvyControl in file located in /etc/modprobe.d/nvidia.conf from options nvidia-drm modeset=1 to options nvidia-current-drm modeset=1. After that regenerate your initramfs image by running: sudo update-initramfs -u -k all and reboot. Every time you change mode via EnvyControl, it overrides that file, so you have to repeat that every time you need.

bayasdev commented 8 months ago

@Klusio19 just checked my Ubuntu 23.10 with Nvidia 535.129.03 install and the kernel module is named nvidia-drm (not sure if this is a Debian specific caveat).

I'm not sure how we can reliably detect the appropriate name if we're into the following situation:

Integrated mode --> Hybrid/Nvidia mode

Since the Nvidia modules are not loaded in this mode.

However I can implement an opt-in CLI flag like --use-nvidia-current.

Let me know what you think.

Klusio19 commented 8 months ago

@bayasdev I found out about the Nvidia modules naming scheme here in the forum: (https://forums.debian.net/viewtopic.php?t=154344), the guy says it's because of DKMS. So I don't think it is Debian-specific, however it doesn't really matter here.

You are correct about the fact that in situations where switching from integrated -> hybrid/Nvidia there is no way to determine what the names of the Nvidia modules are. At the moment I can't think about anything better, than the solution provided by you. I think a simple CLI argument would be enough.

Also if you decide to implement that, a small update in the readme about that situation with Nvidia modules naming scheme would be helpful. But I'm sure you are aware of that 🙂

bayasdev commented 8 months ago

@Klusio19 please test the new 3.3.1 release

Klusio19 commented 8 months ago

@Klusio19 please test the new 3.3.1 release

Uppgraded, using the flag works flawlessly, nvidia_drm module is properly loaded now!