Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Sharing - AMDgpu and Nvidia Hybrid
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 395
Location: Paris

PostPosted: Sun Aug 02, 2020 4:49 am    Post subject: Sharing - AMDgpu and Nvidia Hybrid Reply with quote

Hi, guys

I just bought a new laptop with AMD 4600H with NVIDIA GTX 1650. Gentoo is newly installed with KDE plasma5 and SDDM. Until now, I can run the system and application with amdgpu without any problem and run specific application with Nvidia property driver. The Nvidia/Optimus support hybrid of AMDgpu and Nvidia I don't know since when. Make sure the laptop boot up with option switchable graphic or hybrid option in BIOS, enable GPU swithing support in Kernel. Here below is what I did. Hope it can help people who have the same hardware

I use the Nvidia property driver, No try for nouveau. Use blacklist method in /etc/modprobe.d/blacklist.conf to block the nvidia modules by udev. Otherwise there is some error with udev to load nvidia property driver. Probably stuck in booting and shutdown during the udev to load/remove nvidia modules. Sometimes you may see message from dmesg like "udev timeout 'nvidia-udev.sh add". Looks like it's a bug and not fixed yet. You can search related discussion in the gentoo forum.

running nvidia-xconfig may not generate the xorg.conf configuration correctly. Need manually adjust it. see blow my configuration.
I use sddm as display manager. see page of Gentoo wiki Nvidia/Optimus
Nvidia modules need to be fully loaded before SDDM. Since it's blocked in udev, need to add a sh file in /etc/profile.d/99-nvidia.sh
after all done, run xrandr --listproviders and you will see the message below

Code:
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x54 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 1 associated providers: 0 name:Unknown AMD Radeon GPU @ pci:0000:05:00.0
Provider 1: id: 0x1f6 cap: 0x2, Sink Output crtcs: 4 outputs: 4 associated providers: 0 name:NVIDIA-G0


Refer to the Nvidia instruction Chapter 33 and Chapter 34 and know how to run application with nvidia driver.
Code:
less /usr/share/doc/nvidia-drivers-450.57/README.bz2


/etc/module.d/blasklist
Code:

blacklist nvidia
blacklist nvidia_drm
blacklist nvidia_modeset


/etc/X11/xorg.conf
Code:
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 450.57


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "AMDgpu" 0 0
    Inactive       "nvidia"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "AllowNVIDIAGPUScreens"
EndSection

Section "Files"
EndSection

Section "InputDevice"

    # generated from data in "/etc/conf.d/gpm"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

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

Section "Device"
    Identifier     "AMDgpu"
    Driver         "amdgpu"
    VendorName     "AMD"
    BusID          "PCI:5:0:0"
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier     "AMDgpu"
    Device         "AMDgpu"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection



/etc/sddm.conf
Code:
[X11]
DisplayCommand=/etc/sddm/scripts/Xsetup


/etc/sddm/scripts/Xsetup
Code:
xrandr --setprovideroutputsource 1 0
xrandr --auto


/etc/profile.d/99-nvidia.sh
Code:
#!/bin/sh
modprobe nvidia
modprobe nvidia-drm
modprobe nvidia-uvm
Back to top
View user's profile Send private message
crazy-andi
n00b
n00b


Joined: 12 Sep 2019
Posts: 4

PostPosted: Fri Dec 04, 2020 8:12 am    Post subject: Additional parameter for module amdgpu needed Reply with quote

Hi folks!

It took me 3 hours to get my X11 working...
Above config now works nice - but i needed this:

Code:

/etc/modprobe.d/amdgpu.conf
options amdgpu exp_hw_support=1



This is my hardware:
Code:

lspci | grep VGA:
01:00.0 VGA compatible controller: NVIDIA Corporation Device 2192 (rev a1)
05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Renoir (rev c6)


Have some fun!
_________________
Es sagte einst ein weiser Mann : Da wo du hingehst - da bist du dann!
Back to top
View user's profile Send private message
crazy-andi
n00b
n00b


Joined: 12 Sep 2019
Posts: 4

PostPosted: Mon Jan 18, 2021 7:46 am    Post subject: Reply with quote

Hi @all.

There was another challenge.

I got an portable external HDMI-Monitor an tried do get 'em acting as secondary monitor on my notebook.
Above config did not work, as the HDMI port is connected to the nvidia chip.

Playing around, I found this setup.
There's a caveat. As this setup uses the nvidia gpu as primary gpu, optimus takes no effekt. we will use the nvidia GPU all the time , so there are no powersavings...

If someone found a setup allowing to use external monitors with amdgpu as primary gpu AND functional OPTIMUS - PLEASE POST!

My Hardware
CPU : AMD Ryzen 7 4800H with Radeon Graphics
NVIDIA GPU : GeForce GTX 1650 Ti
The primary notebook monitor seems to be wired to the amdgpu. The external monitor connectors seem to be wired to the nvidia gpu.

Current Software:
Gentoo profile : default/linux/amd64/17.1
kernel : gentoo-sources-5.4.80
xorg-server : 1.20.10
mesa : 20.2.4
xf86-video-amdgpu : 19.1.0
nvidia-drivers : 460.27.04


xorg.conf using nvidia gpu as primary gpu but allow external monitors:
Code:

Section "ServerLayout"
    Identifier     "Default Layout"
    Screen         "Screen0" 0 0
    Inactive       "amdGPU"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "AllowNVIDIAGPUScreens"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "nvidiaGPU"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
Section "Device"
    Identifier     "nvidiaGPU"
    Driver         "nvidia"
    VendorName     "AMD"
    BusID          "PCI:1:0:0"
    Option         "PrimaryGPU" "Yes"
EndSection
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
    Option         "AutoRepeat" "500 30"
    Option         "XkbRules" "xorg"
    Option         "XkbLayout" "de"
    Option         "XkbModel" "pc105"
    Option         "XkbOptions" "altwin:super_win"
EndSection


Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "amdGPU"
    Driver         "modesetting"
    VendorName     "Unknown"
EndSection


this is not sufficient as now the external monitor is the primary monitor and notebooks monitor remains black...
we need to setup via xrandr...
you should setup your login manager to execute this on startup.

xrandr.setup:
Code:

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --output eDP-1-1 --primary --auto --left-of HDMI-0
xrandr --output HDMI-0 --auto --right-of eDP-1-1


Have some fun!
_________________
Es sagte einst ein weiser Mann : Da wo du hingehst - da bist du dann!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum