Ubuntu 18.04.1 LTS R9 390X amdgpu guide / testing summary

This is a guide and a testing summary for enabling amdgpu (instead of radeon) on Ubuntu 18.04.1 having a R9 390X installed and trying out various kernels.

After reading this and reading/watching Level1Techs guide and many others I finally managed to get amdgpu loaded instead of radeon. The following steps show how to accomplish that.

Problem

I want to play games on Linux via DXVK using an open source driver (not amdgpu-pro). Since DXVK only works with the amdgpu driver I had to get rid of Ubuntu loading radeon all the time.

My setup

  • Ubuntu 18.04.1 LTS

  • i7-5830k

  • R9 390X (actually 2, but should not matter)

How to

I. Newest drivers

@NOT-TESTED: It should also work with the official drivers delivered with the Ubuntu 18.04.1 installation. If you do not want to run unofficial drivers skip this step.

@NOTE: Download newer unofficial drivers from PPA to get better performance in DXVK. May be unstable.

Install the latest driver from https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers:

sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo apt update && sudo apt dist-upgrade
sudo apt install mesa-vulkan-drivers mesa-vulkan-drivers:i386

@ERROR unmet dependencies: install original drivers first:

sudo add-apt-repository --remove ppa:oibaf/graphics-drivers
sudo apt install mesa-vulkan-drivers mesa-vulkan-drivers:i386

@ATTENTION: Ensure you do not have another graphics driver PPA like ppa:paulo-miguel-dias/mesa added. You may check his Mesa drivers out: STABLE or UNSTABLE

@ERROR general error due to PPA: Purge graphic driver PPA(s) to fall back to original drivers and clean up:

sudo apt install ppa-purge && aptitude
sudo ppa-purge ppa:oibaf/graphics-drivers
sudo apt autoremove && sudo apt autoclean

You may start over.

II. Xorg configuration

Create a xorg configuration file that will be loaded automatically on boot:

/usr/share/X11/xorg.conf.d/<nr-name>.conf for example 42-amdgpu.conf

#/usr/share/X11/xorg.conf.d/42-amdgpu.conf
Section "Device"
    Identifier "AMDGPU"
    Driver "amdgpu"
    Option "AccelMethod" "glamor"
    Option "DRI" "3"
EndSection

@NOT-TESTED: Add this to the already existing 10-amdgpu.conf file. May gets overwritten by driver installation.

@OPTION: You can also add this to /etc/X11/xorg.conf or /etc/xorg.conf.

III. Blacklist radeon

Create a blacklist file with the module that shall be blacklisted:

/etc/modprobe.d/<name>.conf for example blacklist-radeon.conf

#/etc/modprobe.d/blacklist-radeon.conf
blacklist radeon

@OPTION: It is possible to use already existing blacklist.conf files by just appending blacklist radeon somewhere.

IV. GRUB configuration

Add or change these parameters in the grub configuration /etc/default/grub:

#/etc/default/grub
...
GRUB_GFXMODE=1920x1080x32
GRUB_CMDLINE_LINUX_DEFAULT="radeon.si_support=0 radeon.cik_support=0 amdgpu.si_support=1 amdgpu.cik_support=1 amdgpu.dc=1 amdgpu.dpm=1 amdgpu.modeset=1"
...

@DID-NOT-WORK: I made a copy of the 40_custom file in /etc/grub.d/. It did not work when I placed it in 40_amdgpu instead of /etc/default/grub. (see the /etc/grub.d/README for more info)

V. Update GRUB and the initial ramdisk

Let the changes above take affect:

sudo update-grub2 && sudo update-initramfs -u -k all

and

reboot

VI. Verify

To verify that the amdgpu driver has loaded and is in use, execute one or more of the following commands:

lsmod | egrep 'Used|amdgpu'

sudo lspci -v | grep amdgpu -B 19

sudo lshw -c video | grep amdgpu -B 10 -A 1

Run a Vulkan test application:

sudo apt install vulkan-utils

and

vulkan-smoketest

VII.I Testing with newer kernels (as of 2018-11-19)

I tried to boot various kernels after the steps above.

To install other kernels I used the Ubuntu Kernel Update Utility:

sudo apt-add-repository -y ppa:teejee2008/ppa
sudo apt update
sudo apt install ukuu

Here is the summary of my testing:

4.15.0 WORKING! Ubuntu 18.04.1 LTS default kernel

4.17.5 WORKING! kernel used in this video

4.18.0 WORKAROUND! current default kernel of Ubuntu 19.10 Disco (2018-11-19)

4.18.15 WORKAROUND! latest 4.18.x kernel with changes to amdgpu

4.18.19 WORKAROUND! latest 4.18.x kernel

4.19 FAILURE! blackscreen or dmesg:

[drm:dm_pp_get_static_clocks [amdgpu]] *ERROR* DM_PPLIB: invalid powerlevel state: 0!

4.19.1 FAILURE! blackscreen or dmesg:

drm:dm_pp_get_static_clocks [amdgpu]] *ERROR* DM_PPLIB: invalid powerlevel state: 0!
drm:amdgpu_vce_ring_test_ring [amdgpu]] *ERROR* amdgpu: ring 12 test failed
drm:amdgpu_device_init.cold.28 [amdgpu]] *ERROR* hw_init of IP block <vce_v2_0> failed -110
amdgpu 0000:05:00.0: amdgpu_device_ip_init failed
amdgpu 0000:05:00.0: Fatal error during GPU init

4.19.2 FAILURE! dmesg:

Direct firmware load for amdgpu/hawaii_mc.bin failed with error -2

@NOTE: I did not investigate more on the errors of the 4.19.x kernels yet.

VII.II Workaround

4.18-4.18.19

To get 4.18 kernels working:

  1. Backup your current firmware files:

    sudo cp -r /lib/firmware /lib/firmware-$(uname -r)
    
  2. Download the linux-firmware of Ubuntu 19.10 Disco (current Disco version uses kernel 4.18.0 as default) from https://packages.ubuntu.com/en/disco/linux-firmware or:

    wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/linux-firmware_1.176.tar.gz
    
  3. Extract files:

    tar -xvzf linux-firmware_1.76.tar.gz
    
  4. Go into the new firmware direcotry:

    cd linux-firmware
    
  5. Install the firmware:

    sudo make install
    
  6. Reboot

    reboot
    

VII.II Testing with newer kernels (as of 2020-01-01)

Here is a summary of my testing:

4.18.16 WORKING! Mint 19.1 with all mentioned kernel parameters and Radeon blacklisted

4.18.17 - 4.18.20 BLACKSCREEN! Firmware update did not fix the issue

4.18.17 - 4.18.20 NOT TESTED! omit the dpm kernel parameter

4.20.12 WORKING! dpm kernel parameter omitted

5.00.00 WORKING! dpm kernel parameter omitted

5.2.21 RECOMMENDED! WORKING! amdgpu.dpm=1 is fixed and works

VIII Write a fan control service to fix stutter issues & for silent gaming

    warning: many gpus have a maximum temperature of 95°C / 203°F
    exceeding that can damage your gpu, look at your config twice! 
  1. write a service with file name: amdgpu-fancontrol.service

    [Unit]
    Description=amdgpu-fancontrol
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/amdgpu-fancontrol
    
    [Install]
    WantedBy=multi-user.target
    
  2. put the service into

    /etc/systemd/system
    
  3. take the script from github: link

  4. change the parameters of script if you want to

4.1. change all numbers from zero to one if you also have integrated graphic.

/sys/class/drm/card1/device/hwmon/hwmon1/

4.2. change the temp/revolutions mapping. The change of fan speed does interfere with the rendering. Therefore the values should be held constant such that no interpolation takes place in between. The last value will be chosen as maximum fan speed for overheating protection.

TEMPS=( 60000 65000 80000 95000 96000 )
PWMS=(   170   170   170   170   255  )

4.3 check the directory to be sure that it exists

  1. put the script into /usr/bin/amdgpu-fancontrol

  2. activate the service

    sudo systemctl daemon-reload
    sudo systemctl enable amdgpu-fancontrol.service
    sudo systemctl start amdgpu-fancontrol.service