This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

AMDGPU

From Gentoo Wiki (test)
(Redirected from Amdgpu)
Jump to:navigation Jump to:search
Resources

AMDGPU is the next generation family of open source graphics drivers using the new Display Core (DC) framework for Vega GPUs and Raven Ridge APUs. It is however also capable of handling newer AMD/ATI Radeon graphics cards based on GCN1.1+, namely the Southern Islands, Sea Islands, Volcanic Islands, and Arctic Islands chipsets.

If the card in question does not appear in the Feature support section below, it is not supported by AMDGPU. In that case check the radeon article, which contains instructions for older open-source AMD/ATI Radeon graphics card drivers.

Prior to Kernel 4.15 Display Core (DC, developed from Display Abstraction Layer, DAL) was not included in the vanilla kernel sources, thus AMDGPU was not able to provide graphics output to a monitor on VEGA and later chips.

Installation

Setting up a system to use AMDGPU requires identifying the proper card, installing the corresponding firmware, configuring the kernel, and installing the X11 driver.

Prerequisites

Hardware detection

To choose the right driver, first detect the graphics card. Use lspci for this task:

root #lspci | grep -i VGA

Check the output for one of the product names listed in the table below.

Feature support

Family Chipset name ArchitectureA Product name OpenGL OpenGL ES VIDEO_CARDS
Southern Islands3 CAPE VERDE, PITCAIRN, TAHITI, OLAND, HAINAN GCN1.1+ HD7750-HD7970, R9 270, R9 280, R9 370X, R7 240, R7 250 4.1 3.0 amdgpu radeonsi
Sea Islands1 BONAIRE, KABINI, KAVERI, HAWAII, MULLINS GCN2.x HD7790, R7 260, R9 290, R7 360, R9 390 4.3 3.1 amdgpu radeonsi
Volcanic Islands CARRIZO, FIJI, STONEY, TONGA, TOPAZ GCN3.x R9 285, R9 380, R9 380X, R9 Fury, R9 Nano, R9 Fury X, Pro Duo 4.3 3.1 amdgpu radeonsi
Arctic Islands2 POLARIS10, POLARIS11, POLARIS12 GCN4.x RX 460, RX 470, RX 480, RX 540, RX 550, RX 560, RX 570, RX 580 4.3 3.1 amdgpu radeonsi
Vega4 VEGA10, RAVEN5 GCN5.x, DCN1.05 RX Vega 56, RX Vega 64, Raven Ridge APU series5 4.5 3.2 amdgpu radeonsi
A GCN stands for Graphics Core Next Architecture and was introduced with the Radeon HD7000 series (GCN1.0). Raven Ridge APUs feature a mobile Vega graphics core and are referred to as DCN1.0.
1 Support is optional in the kernel.
2 Since kernel 4.7-rc6
3 Experimental, optional support added since kernel 4.9-rc1
4 usable for graphics output since kernel 4.15
5 planned for kernel 4.16 to be finally usable[1][2]

Firmware

It is necessary to install the proper firmware (or microcode) for your card. Firmware files are provided by sys-kernel/linux-firmware. Make sure you have all necessary files for your hardware in your configuration file if you use the savedconfig flag.

USE flags for sys-kernel/linux-firmware Linux firmware files

+initramfs Create and install initramfs for early microcode loading in /boot (only AMD for now)
+redistributable Install also non-free (but redistributable) firmware files
bindist Flag to enable or disable options for prebuilt (GRP) packages (eg. due to licensing issues)
compress-xz Compress firmware using xz (app-arch/xz-utils) before installation
compress-zstd Compress firmware using zstd (app-arch/zstd) before installation
deduplicate Create symlinks for all firmware that is duplicate using rdfind
dist-kernel Enable subslot rebuilds on Distribution Kernel upgrades
savedconfig Allows individual selection of firmware files
unknown-license Install firmware files whose license is unknown

root #emerge --ask sys-kernel/linux-firmware

The firmware files installed this way will be incorporated into the kernel.

Kernel

Note
For ease of installation, it is recommended to choose "AMD GPU" as a module (M) and skip the firmware selection below. This will load the driver a little later once udev becomes active. The firmware will never need to be manually managed in this case.

Set the following kernel options for the graphic chipsets mentioned above:

KERNEL
Processor type and features  --->
    [*] MTRR (Memory Type Range Register) support
Device Drivers  --->
    Graphics support  --->
        <*/M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
              [*]   Enable legacy fbdev support for your modesetting driver
        <   > ATI Radeon
        <M/*> AMD GPU
              [ /*] Enable amdgpu support for SI parts
                    (only needed for Southern Islands GPUs with the amdgpu driver)
              [ /*] Enable amdgpu support for CIK parts 
                    (only needed for Sea Islands GPUs with the amdgpu driver)
              [*]   Enable AMD powerplay component  
              ACP (Audio CoProcessor) Configuration  ---> 
                  [*] Enable AMD Audio CoProcessor IP support (CONFIG_DRM_AMD_ACP)
                        (only needed for APUs)
              Display Engine Configuration  --->
                  [*] AMD DC - Enable new display engine
                  [ /*] DC support for Polaris and older ASICs
                        (only needed for Polaris, Carrizo, Tonga, Bonaire, Hawaii)
                  [ /*] AMD FBC - Enable Frame Buffer Compression
                  [ /*] DCN 1.0 Raven family
                        (only needed for Vega RX as part of Raven Ridge APUs)
        <*/M> HSA kernel driver for AMD GPU devices
    <*/M> Sound card support  --->
        <*/M> Advanced Linux Sound Architecture  --->
            [*]   PCI sound devices --->
                  HD-Audio  --->
                      <*> HD Audio PCI
                      [*] Support initialization patch loading for HD-audio
                      <*> whatever audio codec your soundcard needs
                      <*> Build HDMI/DisplayPort HD-audio codec support
                  (2048) Pre-allocated buffer size for HD-audio driver
Note
When using AMDGPU, it is recommended to unset the ATI Radeon option so that the radeon module is not built. Or alternatively, the module can be built and blacklisted (after rebooting check with lsmod | grep radeon to see if the blacklisting worked). The amdgpu and radeon modules are not meant to be loaded simultaneously, unless, for example multiseat, system requires it.

The options from the Sound card support menu need only to be set if the card supports HDMI or DisplayPort audio and you want to use it. On newer kernels where Enable AMD Audio CoProcessor IP support appears, that should also be set.

AMDGPU with Display Core works primarily for VEGA10 (GCN5.0) and RAVEN (with DCN 1.0) GPUs/APUs. Older cards (GCN1.1 and newer) can be activated in the kernel or using the kernel command line option amdgpu.dc=1 and provide better (but experimental) support than the older radeon kernel module.

See the radeon article for more details about using HDMI/DisplayPort audio.

Incorporating firmware

The firmware package installed in an earlier section provides files in /lib/firmware/amdgpu (for Volcanic Islands and Arctic Islands cards) and/or /lib/firmware/radeon (for Southern Islands and Sea Islands cards). Configure the kernel to use the correct firmware files by setting the following options:

KERNEL Including firmware in the kernel (prior to 4.18)
Device Drivers  --->
    Generic Driver Options  --->
        -*- Userspace firmware loading support
        [*] Include in-kernel firmware blobs in kernel binary
            (amdgpu/<YOUR-MODEL>.bin or radeon/<YOUR-MODEL>.bin)
            (/lib/firmware) Firmware blobs root directory
KERNEL Including firmware in the kernel (4.18 and later)
Device Drivers  --->
    Generic Driver Options  --->
        Firmware loader --->
          -*- Firmware loading facility
          (amdgpu/<YOUR-MODEL>.bin or radeon/<YOUR-MODEL>.bin) Build named firmware blobs into the kernel binary
          (/lib/firmware) Firmware blobs root directory

amdgpu/<YOUR-MODEL>.bin or radeon/<YOUR-MODEL>.bin should be replaced with the full list of filenames given with the chipset's name in the table below, separated by spaces. Use echo to expand the filenames. E.g. for Volcanic Islands/TONGA, run

user $echo amdgpu/tonga_{ce,k_smc,mc,me,mec2,mec,pfp,rlc,sdma1,sdma,smc,uvd,vce}.bin
amdgpu/tonga_ce.bin amdgpu/tonga_k_smc.bin amdgpu/tonga_mc.bin amdgpu/tonga_me.bin amdgpu/tonga_mec2.bin amdgpu/tonga_mec.bin amdgpu/tonga_pfp.bin amdgpu/tonga_rlc.bin amdgpu/tonga_sdma1.bin amdgpu/tonga_sdma.bin amdgpu/tonga_smc.bin amdgpu/tonga_uvd.bin amdgpu/tonga_vce.bin

Then amdgpu/tonga_ce.bin amdgpu/tonga_k_smc.bin amdgpu/tonga_mc.bin amdgpu/tonga_me.bin amdgpu/tonga_mec2.bin amdgpu/tonga_mec.bin amdgpu/tonga_pfp.bin amdgpu/tonga_rlc.bin amdgpu/tonga_sdma1.bin amdgpu/tonga_sdma.bin amdgpu/tonga_smc.bin amdgpu/tonga_uvd.bin amdgpu/tonga_vce.bin is the string that should be put into the kernel configuration.

Important
If the amdgpu module is compiled as a loadable kernel module (i.e. AMDGPU in the kernel configuration is set to M), the firmware files need to be present on the filesystem at the time the module is loaded. In particular, if the module is loaded from an initrd, the firmware also needs to be included in the initrd. On the other hand, if the module is built into the kernel, the firmware files will also be built into the kernel itself.

After expanding the firmware file names from the following table and copying them into the kernel configuration, save the configuration, then compile and install the new kernel and modules.

Important
More recent kernels (Aug. 2018, at least 4.15.x and up) seem to require an updated / extended set of firmware to boot successfully than listed here. Check your e.g. /lib/firmware/amdgpu directory for added files (through sys-kernel/linux-firmware) and make sure you also have an updated configuration file in case you use savedconfig USE flag for this package. Incorporate all the newly added files to your kernel config in the firmware line and recompile + install your new kernel image. Otherwise you boot will likely fail with a blank screen and stalling.
Family Chipset name Product name Firmware
Southern Islands CAPE VERDE HD7750, HD7770, R7 250, R7 250X, R9 370X radeon/{verde_{ce,mc,me,pfp,rlc,smc},TAHITI_{uvd,vce}}.bin
PITCAIRN HD7800, R9 270X radeon/{pitcairn_{ce,mc,me,pfp,rlc,smc,k_smc},TAHITI_{uvd,vce}}.bin
TAHITI HD7870 XT, HD7900, R9 280X radeon/{tahiti_{ce,mc,me,pfp,rlc,smc},TAHITI_{uvd,vce}}.bin
OLAND HD8550M-HD8790M, R7 240 radeon/{oland_{ce,mc,me,pfp,rlc,smc},TAHITI_uvd}.bin
HAINAN HD8970M radeon/{hainan_{ce,mc,me,pfp,rlc,smc},TAHITI_uvd}.bin
Sea Islands BONAIRE HD7790, R7 260, R7 260X, R7 360 radeon/bonaire_{ce,k_smc,mc,me,mec,pfp,rlc,sdma1,sdma,smc,uvd,vce}.bin
KABINI HD8180-HD8400 radeon/kabini_{ce,me,mec,pfp,rlc,sdma1,sdma,uvd,vce}.bin
KAVERI radeon/kaveri_{ce,me,mec2,mec,pfp,rlc,sdma1,sdma,uvd,vce}.bin
HAWAII R9 290, R9 290X, R9 390, R9 390X radeon/hawaii_{ce,k_smc,mc,me,mec,pfp,rlc,sdma,sdma1,smc,uvd,vce}.bin
MULLINS radeon/mullins_{ce,me,mec,pfp,rlc,sdma1,sdma,uvd,vce}.bin
Volcanic Islands CARRIZO amdgpu/carrizo_{ce,me,mec2,mec,pfp,rlc,sdma1,sdma,uvd,vce}.bin
FIJI R9 Fury, R9 Fury X, R9 Nano, Pro Duo amdgpu/fiji_{ce,mc,me,mec2,mec,pfp,rlc,sdma1,sdma,smc,uvd,vce}.bin
TONGA R9 285, R9 380, R9 380X amdgpu/tonga_{ce,k_smc,mc,me,mec2,mec,pfp,rlc,sdma1,sdma,smc,uvd,vce}.bin
TOPAZ R7 M260, R7 M265, R7 M340, R7 M360, R7 M360, R7 M370, R7 M440, R7 M445, R7 M460, R7 M465 amdgpu/topaz_{ce,mc,me,mec2,mec,pfp,rlc,sdma1,sdma,smc}.bin
STONEY amdgpu/stoney_{ce,me,mec,pfp,rlc,sdma,uvd,vce}.bin
Arctic Islands POLARIS10 RX 470, RX 480, RX 570, RX 580 amdgpu/polaris10_{ce,ce_2,k_smc,mc,me,me_2,mec2,mec2_2,mec,mec_2,pfp,pfp_2,rlc,sdma1,sdma,smc,smc_sk,uvd,vce}.bin
POLARIS11 RX 460, RX 550 640SP, RX 560 amdgpu/polaris11_{ce,k_smc,mc,me,mec2,mec,pfp,rlc,sdma1,sdma,smc,smc_sk,uvd,vce}.bin
POLARIS12 RX 540, RX 550 amdgpu/polaris12_{ce,ce_2,mc,me,me_2,mec,mec2,mec2_2,mec_2,pfp,pfp_2,rlc,sdma,sdma1,smc,uvd,vce}.bin
Vega VEGA10 RX Vega 56, RX Vega 64 amdgpu/vega10_{acg_smc,asd,ce,gpu_info,me,mec,mec2,pfp,rlc,sdma,sdma1,smc,sos,uvd,vce}.bin
RAVEN Raven Ridge APU series amdgpu/raven_{asd,ce,gpu_info,me,mec,mec2,pfp,rlc,sdma,vcn}.bin

X11 driver

USE flags

Set the USE flags for the amdgpu driver as needed.

USE flags for x11-drivers/xf86-video-amdgpu Accelerated Open Source driver for AMDGPU cards

udev Enable virtual/udev integration (device discovery, power and storage device support, etc)

The package will be automatically emerged as a dependency of x11-base/xorg-drivers after setting VIDEO_CARDS following the instructions in the next section.

Emerge

Portage uses the VIDEO_CARDS variable for enabling support for various graphics cards in packages. Setting VIDEO_CARDS to amdgpu radeonsi (see the feature matrix section above) and asking Portage to update changed USE flags in the @world set will pull in the correct driver:

FILE /etc/portage/make.conf
VIDEO_CARDS="amdgpu radeonsi"
Note
In any case radeonsi has to be included for media-libs/mesa.
root #emerge --ask --changed-use @world

The system should now be prepared to use amdgpu after the next reboot.

Power management

Note
This section only covers dpm method. This method is only available for GPUs from R6xx -series onwards. Users of AMDGPU driver are thus automatically covered. Older dynpm and profile methods aren't covered here. Users who want to read about those should read radeon article instead.
Important
This section assumes that card0 is the GPU users want to adjust. Users should check that paths like /sys/class/drm/card0/ belong to the right GPU. Users with more than one GPU will most likely have more than just card0 entry under said locations.

dpm

In most cases since Linux 3.13 dpm is the default power management method. Unlike with dynpm and profile methods enabling or disabling dpm must be done via kernel command line. Users who have GPUs older than HD5000 -series may need to add radeon.dpm=1 on kernel command-line to enable dpm.

In most cases just enabling dpm is enough but there are some tunable settings. dpm has three main modes of operating: battery, balanced and performance. The names are quite self-explanatory. To set the GPU to most performant mode the following command is needed to run:

root #echo performance > /sys/class/drm/card0/device/power_dpm_state

Even if GPU is set to performance -mode it does not mean that the GPU is running with highest clockspeeds at all the time. This is the normal and intended way how dpm works. If it is desirable to run the GPU at the highest speeds all the time, even if there is no actual load, users can then run following command:

root #echo high > /sys/class/drm/card0/device/power_dpm_force_performance_level

This manually overrides dpm's own bahaviour. This is however mainly intended for testing purposes but may also be useful when doing GPU benchmanks.

To give control back to dpm following command is needed to run:

root #echo auto > /sys/class/drm/card0/device/power_dpm_force_performance_level
Note
There's also the low forceable performance level, which can be echoed the same way.

Troubleshooting

Kernel

Older kernels which do not support the amdgpu driver will not provide the AMDGPU option. But even with amdgpu there is no video output on VEGA and newer chips without DC (Display Code), which was first included in vanilla Kernel 4.15. In both cases, trying an unstable (denoted by a ~) kernel can provide the required kernel-sources.

SME

Currently, amdgpu does not work with AMD Secure Memory Encryption (SME) enabled, so you need to disable its use either in the kernel configuration or on the kernel command line (i.e. in /etc/default/grub as part of GRUB_CMDLINE_LINUX).

KERNEL
Processor type and features  --->
    [*] AMD Secure Memory Encryption (SME) support
    [ ]   Activate AMD Secure Memory Encryption (SME) by default

AMD_MEM_ENCRYPT may remain enabled, but either AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT must remain unset or the kernel command line option mem_encrypt=off must be used in order to turn Memory Encryption off. With mem_encrypt=on amdgpu fails to load and the screen stays frozen as it was at the time of the modprobe, or, when included in the kernel, in early printk.

AMDGPU/RadeonSI drivers do not work

If the graphics card is not supported by including amdgpu and radeonsi alone in VIDEO_CARDS, try adding radeon to make.conf's VIDEO_CARDS definition. For example:

FILE /etc/portage/make.conf
VIDEO_CARDS="amdgpu radeonsi radeon"

After the values have been set update the system so the changes take effect:

root #emerge --ask --changed-use --deep @world

Full-screen windows perform poorly

The installed version of sys-devel/llvm may be too old. Try emerging an unstable version.

Pixel-wide line on left side of screen when X server is started when using a Southern Island card

Those using a Southern Island card may notice a pixel-wide line on the left of the screen in both the X server and console environments after having started a X server (This issue doesn't exist when using Linux 4.13 or newer). This is a known bug. Disabling audio through HDMI for that display resolves this issue. This may be done via:

user $xrandr --output HDMI-A-0 --auto --set audio off

where HDMI-A-0 should be replaced by the name of the output, obtained by running xrandr

For more information please see https://bugs.freedesktop.org/show_bug.cgi?id=97861.

See also

  • AMDGPU-PRO — the next generation closed source graphics component that operates on top of the open source AMDGPU drivers for newer AMD/ATI Radeon graphics cards.

External resources

References