AMD integrated graphics and Geforce GPU with 2 screens on laptop

I’m trying to set up my laptop along with an external monitor. I’m using xfce Fedora 34 with a Geforce RTX 3060 and AMD ryzen 5800h.
If i just install the nvidia drivers via Howto/NVIDIA - RPM Fusion, both screens work, but the gpu shows a constant usage of 20 or 40% when no applications are running, and I got issues with electron apps unless I pass the --disable-gpu flag. The nvidia-settings also doesn’t show any configuration options for the x server:

I tried running the nvidia-xserver program, and after restarting the x server, the idle usage went to 0%, and the x server options in the nvidia settings appeared. However, only my second monitor works, connected to the GPU via HDMI. The laptop screen, connected to the integrated AMD graphics, stays dead.

For now I removed the created xorg.conf file from /etc/X11, so at least both screens work.

What do I need to add configure in the xorg.conf file for this setup to work?

  • lshw -c display output:
       description: VGA compatible controller
       product: GA106M [GeForce RTX 3060 Mobile / Max-Q]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: /dev/fb0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom fb
       configuration: depth=32 driver=nvidia latency=0 mode=1920x1080 visual=truecolor xres=1920 yres=1080
       resources: iomemory:fc0-fbf iomemory:fe0-fdf irq:95 memory:fb000000-fbffffff memory:fc00000000-fdffffffff memory:fe00000000-fe01ffffff ioport:f000(size=128) memory:fc000000-fc07ffff
       description: VGA compatible controller
       product: Cezanne
       vendor: Advanced Micro Devices, Inc. [AMD/ATI]
       physical id: 0
       bus info: pci@0000:06:00.0
       version: c5
       width: 64 bits
       clock: 33MHz
       capabilities: pm pciexpress msi msix vga_controller bus_master cap_list
       configuration: driver=amdgpu latency=0
       resources: iomemory:fe0-fdf iomemory:fe0-fdf irq:44 memory:fe10000000-fe1fffffff memory:fe20000000-fe201fffff ioport:d000(size=256) memory:fc500000-fc57ffff
  • xrandr -q:
Screen 0: minimum 320 x 200, current 3840 x 1249, maximum 16384 x 16384
eDP connected 1920x1080+1920+169 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080    240.00*+  60.00  
   1680x1050    240.00  
   1280x1024    240.00  
   1440x900     240.00  
   1280x800     240.00  
   1280x720     240.00  
   1024x768     240.00  
   800x600      240.00  
   640x480      240.00  
DP-1-0 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
   1920x1080     60.00*+  59.94    50.00  
   1680x1050     59.88  
   1440x900      59.90  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1024x768     119.99   100.00    75.03    70.07    60.00  
   800x600      119.97   100.00    75.00    72.19    60.32    56.25  
   720x576       50.00  
   720x480       59.94  
   640x480      120.01    99.99    75.00    72.81    59.94    59.93  
DP-1-2 disconnected (normal left inverted right x axis y axis)

I suggest you put back the /etc/X11/xorg.conf file.
Also that you copy the /usr/share/X11/xorg.conf.d/nvidia.conf file to /etc/X11/xorg.conf.d/nvidia.conf.
Restart and now the nvidia driver should be able to manage both screens.

That is exactly what I tried before, leading to the described result: only the HDMI monitor is active.
the xorg.conf file:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"

Section "Files"

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24

and the xorg.conf.d/nvidia.conf file:

Section "OutputClass"
	Identifier "nvidia"
	MatchDriver "nvidia-drm"
	Driver "nvidia"
	Option "AllowEmptyInitialConfiguration"
	Option "SLI" "Auto"
	Option "BaseMosaic" "on"

Section "ServerLayout"
	Identifier "layout"
	Option "AllowNVIDIAGPUScreens"

For now I got it to work by simply forcing everything to the nvidia GPU in the bios settings. I’d still be thankful for helpful input though.

The only difference in your nvidia.conf file and mine is the setting to make the nvidia GPU primary.

	Option "Primary" "yes"

was added to both stanzas in that file. I never had to do anything with the settings in bios and everything just worked.

IIRC I followed the info on rpmfusion about setting up the prime config for the nvidia GPU.

I also do not have the /etc/X11/xorg.conf file. (I don’t think it was ever there since nouveau and wayland is the default config) These are the only files I have in that location.

[jvian@laptop ~]$ ls -l /etc/X11
total 28
drwxr-xr-x. 2 root root 4096 Jul 21 18:47 applnk
drwxr-xr-x. 2 root root 4096 Aug 27 19:41 fontpath.d
drwxr-xr-x. 5 root root 4096 Aug 27 19:39 xinit
-rw-r--r--. 1 root root  547 Jul 23 20:46 Xmodmap
drwxr-xr-x. 2 root root 4096 Jul 23 20:56 xorg.conf.d
-rw-r--r--. 1 root root  493 Jul 23 20:46 Xresources
drwxr-xr-x. 2 root root 4096 Aug 27 19:41 Xsession.d
[jvian@laptop ~]$ ls -l /etc/X11/xorg.conf.d/
total 8
-rw-r--r--. 1 root root 311 Mar 26  2021 00-keyboard.conf
-rw-r--r--. 1 root root 381 Aug  7 11:26 nvidia.conf

Just so you can compare.
I have done no config for GPU output anywhere except as noted with the /etc/X11/xord.conf.d/nvidia.conf file. As far as I can tell the line in the nvidia.conf file that reads Option "AllowNVIDIAGPUScreens" is what allows the nvidia GPU to drive all video outputs when it is functioning as primary GPU. I have seen some comments about putting that line in different locations but I have not needed to do so.