You are not logged in.

#1 2023-05-04 09:08:37

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

[SOLVED] disabling specific graphics card based on the kernel choice?

Original Subject : How do i disable specific graphics card based on the kernel choice?

i have an arch system with two kernels installed on it, they are Linux-hardened and Linux-zen, i also have two graphic cards on my system which are the integrated AMD radeon graphics card and a discrete NVIDIA graphics card, whenever i boot into the Linux-hardened kernel , i would like that the AMD card to be used and the NVIDIA card to be disabled, and whenever i boot into the Linux-zen kernel, i want the NVIDIA card to be used and the AMD card to be disabled, is it possible to set this up so that i wouldn't have to run any commands while booting, all of this should happen automatically in the background when i select my kernel in the systemd-boot boot-loader, Also i don't plan to use Xorg for this setup, my plan was that

1. setup the kernels-specific driver disabling
2. boot into Linux-hardened and work in sway Wm for normal usage, i need the AMD GPU to be enabled and the NVIDIA card to be disabled because the developers of sway hate NVIDIA and i don't want to game on sway Wm
3. boot into Linux-zen kernel whenever i want to play games, this is why i need the AMD card to be disabled and the NVIDIA card should run with the proprietary drivers. the DE i chose for gaming is KDE, and i don't plan to use it with Xorg because of the screen tearing issues.
4. Profit??

My questions here are :
Is it possible to set this up? if yes how?
are there any better alternatives? 

Things I've tried so far :
blacklisting NVIDIA and AMD modules in files named blacklist-hardened.conf and blacklist-zen.conf inside /etc/modprobe.d/ this doesn't work, this seems to apply the black lists to both the kernels.
trying to setup kernel parameters for DRM in Linux-zen, i couldn't seem to find any kernel-specific ways to set kernel parameters.
i have already installed both the kernels and setup their boot-loader loader configs /boot/loader/entries

Things i need help with:
How do i setup kernel parameters for each kernel separately?
how do i setup different modules to load for different kernels and different blacklists for each kernel?
how do i make this setup auto-update so that i don't have to do all of this every-time something gets updated.

I have my system up to date, i have already installed the necessary packages NVIDIA-dkms and xf86 package for amdgpu

Any help would be appreciated.

EDIT : The solution (after going through the responses in this thread) is
1. setting up kernel specific driver disabling : This has to be done using kernel parameters in the boot-loader, go through this page to see how to apply kernel parameters for your boot-loader, i used two kernels Linux-hardened for work and Linux-zen for gaming, but the process is same for any kernel, remember that if you want to use a kernel other than Linux for gaming, you need the NVIDIA-dkms package not NVIDIA

2. the blacklist : for the Linux-zen(gaming) kernel, add the

nvidia_drm.modeset=1

kernel parameter into the boot-loader config. for the Linux-hardened(work) kernel add the

install nvidia /bin/true module_blacklist=nvidia

kernel parameters, for setting up NVIDIA-dkms go through the guides here

3.Result : By now the Linux-zen(gaming) kernel has NVIDIA installed and running, and the Linux-hardened(work) kernel blacklists the NVIDIA module so the amdgpu module will be automatically used, most of the original requirements are now complete, the only thing left is making sure that the gaming kernel uses only the NVIDIA card and not the AMD one

3. Making sure only NVIDIA is used:
for this, i made a separate user for gaming, this user doesn't need sudo rights, but it is more convenient if it does, so to set this up you need to add

DRI_PRIME=pci-0000_01_00_0 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia

to your environment variables and make sure that every-time you login, your DE uses them, I used KDE for my gaming DE, so for that i added the variables into ~/.config/environment.d/envvars.conf by following the instructions here, so i also added

export $(./usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator | xargs)

to my .bash_profile, now every-time i want to work, i login to my main work user on the Linux-hardened kernel and when i want to play games,  i boot into the Linux-zen kernel from the boot-loader and login to my gaming user.

now you just have to update your packages and reboot once, and it's ready. Thanks to the community for helping me out on this.

Last edited by anicearchnewbie (2023-06-08 16:39:22)

Offline

#2 2023-05-04 10:41:24

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

You can blacklist a module on the kernel commandline which you can relevantly do for each of the entries: https://wiki.archlinux.org/title/Kernel … and_line_2 . For the nvidia special case you could also "cheat" and not install the linux-hardened-headers so that DKMS can't build the nvidia module for the hardened kernel in the first place. But blacklisting the relevant modules on the cmdline for the specific kernels will be the easiest/surefire way of getting this.

As for how to edit the kernel parameters for each kernel you can adjust the options line of the relevant systemd-boot entries relevantly: https://wiki.archlinux.org/title/System … ng_loaders

Last edited by V1del (2023-05-04 10:43:25)

Offline

#3 2023-05-05 05:22:25

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

V1del wrote:

You can blacklist a module on the kernel commandline which you can relevantly do for each of the entries: https://wiki.archlinux.org/title/Kernel … and_line_2 . For the nvidia special case you could also "cheat" and not install the linux-hardened-headers so that DKMS can't build the nvidia module for the hardened kernel in the first place. But blacklisting the relevant modules on the cmdline for the specific kernels will be the easiest/surefire way of getting this.

As for how to edit the kernel parameters for each kernel you can adjust the options line of the relevant systemd-boot entries relevantly: https://wiki.archlinux.org/title/System … ng_loaders

I have done both of these, after all the edits, this is what my /boot/loader/entries/linux-*.conf looks like :

linux-hardened :

 
# Created by: archinstall
# Created on: 2023-03-20_08-34-56
title Arch Linux (linux-hardened)
linux /vmlinuz-linux-hardened
initrd /amd-ucode.img
initrd /initramfs-linux-hardened.img
options root=PARTUUID=66beed3b-08a1-4d53-838c-d0a7aaabd6ca zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs install nvidia /bin/true module_blacklist=nvidia

linux-zen :

title Arch Linux (Zen)
linux /vmlinuz-linux-zen
initrd /amd-ucode.img
initrd /initramfs-linux-zen.img
options root=PARTUUID=66beed3b-08a1-4d53-838c-d0a7aaabd6ca zswap.enabled=0 rootflags=subvol=@ rw quiet rootfstype=btrfs module_blacklist=amdgpu,radeon nvidia_drm.modeset=1

Now, upon booting into linux-hardened ( i haven't installed linux-hardened-headers like you said), everything works fine, lsmod shows that amdgpu module is being used for the display, nvidia is nowhere to be seen in the lsmod output so all good.

But when i boot into linux-zen, i try to login to plasma session. the display manager i'm using is ly, it gives a black screen right after authentication, and i can't even get another tty to open, Ctrl+Alt+F1 through F6 are unresponsive i have the drm modeset to 1, but it appears that it is not being loaded properly.

the output of

lsmod | grep nvidia

: (When booted into linux-zen)

nvidia_drm                   98304  0
nvidia_uvm              3190784  0
nvidia_modeset      1519616  1 nvidia_drm
nvidia                     61702144  2 nvidia_uvm,nvidia_modeset
video                             77824  2 ideapad_laptop,nvidia_modeset

the output of

lsmod | grep amd

: (When booted into linux-zen)

snd_sof_amd_rembrandt    16384  0
snd_sof_amd_renoir     16384  0
snd_sof_amd_acp        57344  2 snd_sof_amd_rembrandt,snd_sof_amd_renoir
snd_sof_pci            24576  2 snd_sof_amd_rembrandt,snd_sof_amd_renoir
snd_sof_xtensa_dsp     20480  1 snd_sof_amd_acp
snd_sof               401408  2 snd_sof_amd_acp,snd_sof_pci
edac_mce_amd           57344  0
kvm_amd               204800  0
kvm                  1400832  1 kvm_amd
snd_pcm               217088  12 snd_sof_amd_acp,snd_hda_codec_hdmi,snd_pci_acp6x,snd_hda_intel,snd_hda_codec,snd_sof,snd_compress,snd_soc_core,snd_sof_utils,snd_hda_core,snd_pci_ps,snd_pcm_dmaengine
snd_acp_config         16384  4 snd_rn_pci_acp3x,snd_sof_amd_rembrandt,snd_acp_pci,snd_sof_amd_renoir
snd_soc_acpi           16384  2 snd_sof_amd_acp,snd_acp_config
ccp                   159744  1 kvm_amd

i got these outputs by booting into linux-zen and logging into a shell from ly instead of logging into kde plasma wayland

How do i proceed forward?

Offline

#4 2023-05-05 08:17:13

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,104

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

ly is a broken piece of s... notorious for setting up the session incorrectly, use something else. Is this a laptop? In which case you probably don't want to blacklist amdgpu and need to keep it enabled and then see https://wiki.archlinux.org/title/PRIME# … er_offload for invoking the nvidia GPU on demand.

Offline

#5 2023-05-21 12:06:09

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

heyy, thanks for the reply, the prime render offload works!!! sorry i couldn't post earlier, like you said, KDE does seem to be using amdgpu and whenever i want to play games, they are running properly with NVIDIA prime render, but the AMD GPU that i have can't handle 4k screens, i know that the NVIDIA GPU is capable enough to do that, is there anyway i can force KDE to use the NVIDIA card whenever i connect an external display, or maybe when i run a command?, thanks.

Offline

#6 2023-05-21 14:52:53

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

the AMD GPU that i have can't handle 4k screens

I beg your pardon?

is there anyway i can force KDE to use the NVIDIA card whenever i connect an external display

Not if the external display is connected to the AMD GPU.

Post an xorg log from such setup, the output of "xrandr --listproviders" and explain why you think the AMD GPU isn't capable of handling a 4k output.
If at all, the output (older version of HDMI) isn't capable of 4k.

Offline

#7 2023-06-03 13:05:53

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

i'm using KDE with Wayland, KDE limits the resolution of my 4k screen to 1080p in the system settings, and i know that my amd gpu is an internal gpu so it's not powerful enough to render something on a 4k screen, atleast that's what i think, i've never been able to run 4k screen using this gpu even back when i got it with windows pre-installed, so i have to somehow make NVIDIA render the second screen or preferably both screens if needed, also i would appreciate it  if you could provide a solution that uses wayland instead of xorg, If there is anyway to make both the screens use nvidia card, that is fine for me, i just want to use amd gpu when using the hardened kernel, this is when i'm working, and the nvidia gpu when i'm gaming on the zen kernel. Any help would be appreciated.

Offline

#8 2023-06-03 15:23:48

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

https://wiki.archlinux.org/title/PRIME# … figuration but I asked for the Xorg log to get a basic oversight on the situation (what hardware and where the outputs are attached)

I highly doubt that the IGP is somewhat limited to FullHD, but if it is and the 4k output is attached to it, there's no way to make that work.
We'll see.

is there anyway i can force KDE to use the NVIDIA card whenever i connect an external display, or maybe when i run a command?, thanks.

And if you want to run the entire session on the GPU, you'll have to start it on the GPU (ie. in doubt restart it)

Offline

#9 2023-06-05 10:25:22

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

seth wrote:

And if you want to run the entire session on the GPU, you'll have to start it on the GPU (ie. in doubt restart it)

How do i do that? I tried to do that by blacklisting amdgpu and radeon modules in the kernel parameters but that ended up giving black screen, is there any way to make KDE wayland always use the NVIDIA card as it's main and only graphics driver and completely ignore the amd card?

Offline

#10 2023-06-05 10:37:36

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,893

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

The vast majority of systems with an integrated gpu are configured by the manufacturer to always need the integrated videocard working if one wants to use a discrete one.

On some systems you can change that in the firmware (often called bios) setup.

Last edited by Lone_Wolf (2023-06-05 10:37:52)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#11 2023-06-05 13:53:47

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

Other than that the link in #8 explains how to run the session on the GPU.
Also

I asked for the Xorg log to get a basic oversight on the situation

Because I don't buy "aNd i kNoW ThAt mY AmD GpU Is aN InTeRnAl gPu sO It's nOt pOwErFuL EnOuGh tO ReNdEr sOmEtHiNg oN A 4k sCrEeN" at all.

Offline

#12 2023-06-07 09:34:41

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

Hey @Seth so I've followed that link you gave me, and after some digging, i made a separate user for gaming, and added that user's environment variables so that the KDE session always gets started on NVIDIA card, that works well, glxinfo shows me that NVIDIA card is being used, but even now i can't seem to use 4k resolution when i connect my tv using HDMI, I know for a fact that both my NVIDIA card and TV support 4k resolution because I've used it on windows once, I'm not sure what's wrong here, here is that Xorg log that you asked for : Xorg log, I'm all out of ideas here.

Edit 1 : i also tried adding

video=HDMI-A-1:3840x2160@60

to my boot loader config at

/boot/loader/entries/linux-zen.conf

but it made no difference, the display is still at 1080p.

Last edited by anicearchnewbie (2023-06-07 10:00:05)

Offline

#13 2023-06-07 12:16:35

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

Is the xorg log supposed to cover a run where the HDMI output is attached?
Because it doesn't show up at all…

for name in /sys/class/drm/card*/edid; do echo $name; edid-decode < $name; done

https://aur.archlinux.org/packages/edid-decode-git

but even now i can't seem to use 4k resolution when i connect my tv using HDMI, I know for a fact that both my NVIDIA card and TV support 4k resolution because I've used it on windows once

I suggest to get all of that out of your head for now. I promise you, neither GPU in your system will have troubles w/ 4k.
It is either the output (HDMI), cable or the monitor.

Offline

#14 2023-06-07 13:33:59

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

the output of the command you specified : https://0x0.st/Hc-z.txt

i went through this myself, i understood some parts of it, i haven't seen the numbers 3840 or 2160 anywhere so i guess that is not a good sign. again I'm clueless here, but here you go.

Offline

#15 2023-06-07 13:50:33

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

The EDID certainly doesn't announce 4k, what's the Tv's exact model?
Is there an adapter involved?

Offline

#16 2023-06-07 14:54:56

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

There's no adapter involved, it's just plain old HDMI cable straight from the laptop to the TV, the TV is a Sony KLV-43772E

Last edited by anicearchnewbie (2023-06-07 15:03:32)

Offline

#17 2023-06-07 15:18:43

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

Page 35 of the manual says it's hdmi 1.4 which would allow 1440p @60Hz or 2160p @24Hz, but it also only lists resolutions up to 1080p, so is perfectly in line w/ the edid.

Offline

#18 2023-06-08 07:50:15

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

So, the problem is with my TV not supporting HDMI version more than 1.4?

Offline

#19 2023-06-08 07:55:45

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

The limitation might actually only apply to the 2nd HDMI input (honestly, the tech sheet is not very precise)

Offline

#20 2023-06-08 16:04:19

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

So, in theory, if i reduce the frame rate to 24 fps, can I run 4k on this? Also the original issue is solved so i'm marking this thread as solved

Last edited by anicearchnewbie (2023-06-08 16:07:32)

Offline

#21 2023-06-08 16:58:18

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,330

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

Neither manual nor edid suggest that that resolution is supported.
First try the other hdmi port on the tv.

Offline

#22 2023-06-12 11:42:16

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] disabling specific graphics card based on the kernel choice?

It didn't work either, turns out the issue is in the TV, i tried to connect to a different 4k screen with the same cable and it worked very well, with full 4k and everything. So i guess that issue is also solved, Thanks a lot Seth!

Offline

Board footer

Powered by FluxBB