AMDGPU (简体中文)

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
翻译状态:本文是 AMDGPU翻译。上次翻译日期:2019-09-02。如果英文版本有所更改,则您可以帮助同步翻译。

amdgpu 是 AMD Radeon 显卡的开源图形驱动。

选择正确的驱动

请参考Xorg#AMD选择合适的显卡驱动,这个页面包含 AMDGPUAMDGPU PRO的说明。

目前驱动支持Volcanic Islands (VI) (和更新的显卡) 并且实验性支持 Sea Islands (CI)Southern Islands (SI) 显卡,AMD 没有计划支持更老的 GCN GPUs。

驱动不支持的显卡用户可以使用开源radeon驱动代替。

安装

安装这个mesa 软件包,它提供 DRI 和 3D 加速。

想要开启accelerated video decoding,可以安装libva-mesa-driverlib32-libva-mesa-driver软件包来支持 VA-API,安装mesa-vdpaulib32-mesa-vdpau软件包支持VDPAU。

开启 Southern Islands (SI) and Sea Islands (CIK) 支持

linux 软件包 可以开启 AMDGPU 支持对于 the Southern Islands (SI) 和 Sea Islands (CIK)的显卡。 当编译和构建一个 kernels (简体中文), 需要设置CONFIG_DRM_AMDGPU_SI=YCONFIG_DRM_AMDGPU_CIK=Y 参数。

指定正确的模块加载顺序

当内核启用 AMDGPU 对 SI/CIK 显卡的支持时,radeon驱动可能会在amdgpu驱动之前加载。

确保amdgpuMkinitcpio#MODULES数组中被设置为第一个模块,例如MODULES=(amdgpu radeon)

设置所需的模块参数

amdgpuradeon模块都需要设置的module parameterscik_support= and si_support=

它们必需设置为内核参数或者在一个modprobe配置文件中,并且取决于显卡的 GCN 版本。

提示: dmesg可能会指示应该使用的正确内核参数: [..] amdgpu 0000:01:00.0: Use radeon.cik_support=0 amdgpu.cik_support=1 to override.
在内核命令行中设置模块参数

设置以下 kernel parameters之一:

  • Southern Islands (SI): radeon.si_support=0 amdgpu.si_support=1
  • Sea Islands (CIK): radeon.cik_support=0 amdgpu.cik_support=1
设置内核参数在 modprobe.d 中

/etc/modprobe.d/中创建配置 modprobe 文件, 查看 modprobe.d(5) 可以了解语法细节。

对于 Southern Islands (SI) 使用 si_support=1 选项,对于 Sea Islands (CIK) 使用 cik_support=1 选项,就像下面的例子一样:

/etc/modprobe.d/amdgpu.conf
options amdgpu si_support=1
options amdgpu cik_support=0
/etc/modprobe.d/radeon.conf
options radeon si_support=0
options radeon cik_support=0

确保 modconf 添加到 HOOKS 数组中在 /etc/mkinitcpio.confregenerate the initramfs

AMDGPU PRO

AMD 提供一个叫 AMDGPU PRO 的专有二进制用户驱动,它工作于开源驱动 AMDGPU 之上。

From Radeon Software 18.50 vs Mesa 19 benchmarks article: When it comes to OpenGL games, the RadeonSI Gallium3D driver simply dominates the proprietary AMD OpenGL driver. About the only advantage to the closed-source AMD OpenGL driver is its support for GL 4.6 while RadeonSI is still limited to GL 4.5 until its SPIR-V ingestion support is completed.

安装 amdgpu-pro-libglAUR软件包, 也可以安装 lib32-amdgpu-pro-libglAUR 软件包提供32位程序支持。

加载

应该会在系统启动时自动加载。

如果没有自动加载:

Enable early KMS

See Kernel mode setting#Early KMS start.

Xorg configuration

Xorg will automatically load the driver and it will use your monitor's EDID to set the native resolution. Configuration is only required for tuning the driver.

If you want manual configuration, create /etc/X11/xorg.conf.d/20-amdgpu.conf, and add the following:

/etc/X11/xorg.conf.d/20-amdgpu.conf
Section "Device"
     Identifier "AMD"
     Driver "amdgpu"
 EndSection

Using this section, you can enable features and tweak the driver settings, see amdgpu(4) first before setting driver options.

Tear Free Rendering

TearFree controls tearing prevention using the hardware page flipping mechanism. If this option is set, the default value of the property is 'on' or 'off' accordingly. If this option isn't set, the default value of the property is auto, which means that TearFree is on for rotated outputs, outputs with RandR transforms applied and for RandR 1.4 slave outputs, otherwise off:

Option "TearFree" "true"

DRI level

DRI sets the maximum level of DRI to enable. Valid values are 2 for DRI2 or 3 for DRI3. The default is 3 for DRI3 if the Xorg version is >= 1.18.3, otherwise DRI2 is used:

Option "DRI" "3"

Variable refresh rate

See Variable refresh rate.

Features

Video acceleration

See Hardware video acceleration.

Overclocking

Since Linux 4.17, it is possible to adjust clocks and voltages of the graphics card via /sys/class/drm/card0/device/pp_od_clk_voltage. It is however required to unlock access to it in sysfs by appending the boot parameter amdgpu.ppfeaturemask=0xffffffff.

注意: In sysfs, paths like /sys/class/drm/... are just symlinks and may change between reboots. Persistent locations can be found in /sys/devices/, e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/. Adjust the commands accordingly for a reliable result.

To set the GPU clock for the maximum pstate 7 on e.g. a Polaris GPU to 1209MHz and 900mV voltage, run:

# echo "s 7 1209 900" > /sys/class/drm/card0/device/pp_od_clk_voltage

The same procedure can be applied to the VRAM, e.g. maximum pstate 2 on Polaris 5xx series cards:

# echo "m 2 1850 850" > /sys/class/drm/card0/device/pp_od_clk_voltage
警告: Double check the entered values, as mistakes might instantly cause fatal hardware damage!

To apply, run

# echo "c" > /sys/class/drm/card0/device/pp_od_clk_voltage

To check if it worked out, read out clocks and voltage under 3D load:

# watch -n 0.5  cat /sys/kernel/debug/dri/0/amdgpu_pm_info

You can reset to the default values using this:

# echo "r" > /sys/class/drm/card0/device/pp_od_clk_voltage

It is also possible to forbid the driver so switch to certain pstates, e.g. to workaround problems with deep powersaving pstates like flickering artifacts or stutter. To force the highest VRAM pstate on a Polaris RX 5xx card, while still allowing the GPU itself to run with lower clocks, run:

# echo "manual" > /sys/class/drm/card0/device/power_dpm_force_performance_level
# echo "2" >  /sys/class/drm/card0/device/pp_dpm_mclk

Allow only the three highest GPU pstates:

# echo "5 6 7" >  /sys/class/drm/card0/device/pp_dpm_sclk

To set the allowed maximum power consumption of the GPU to e.g. 50 Watts, run

# echo 50000000 > /sys/class/drm/card0/device/hwmon/hwmon0/power1_cap

Until Linux kernel 4.20, it will only be possible to decrease the value, not increase.

注意: The above procedure was tested with a Polaris RX 560 card. There may be different behavior or bugs with different GPUs.

Enable GPU display scaling

To avoid the usage of the scaler which is built in the display, and use the GPU own scaler instead, when not using the native resolution of the monitor, execute:

$ xrandr --output "<output>" --set "scaling mode" "<scaling mode>"

Possible values for "scaling mode" are: None, Full, Center, Full aspect

  • To show the available outputs and settings, execute:
$ xrandr --prop
  • To set scaling mode = Full aspect for just every available output, execute:
$ for output in $(xrandr --prop | grep -E -o -i "^[A-Z\-]+-[0-9]+"); do xrandr --output "$output" --set "scaling mode" "Full aspect"; done

Troubleshooting

Xorg or applications won't start

  • "(EE) AMDGPU(0): [DRI2] DRI2SwapBuffers: drawable has no back or front?" error after opening glxgears, can open Xorg server but OpenGL apps crash.
  • "(EE) AMDGPU(0): Given depth (32) is not supported by amdgpu driver" error, Xorg won't start.

Setting the screen's depth under Xorg to 16 or 32 will cause problems/crash. To avoid that, you should use a standard screen depth of 24 by adding this to your "screen" section:

/etc/X11/xorg.conf.d/10-screen.conf
Section "Screen"
       Identifier     "Screen"
       DefaultDepth    24
       SubSection      "Display"
               Depth   24
       EndSubSection
EndSection

Screen artifacts and frequency problem

Dynamic power management may cause screen artifacts to appear when displaying to monitors at higher frequencies (120+Hz) due to issues in the way GPU clock speeds are managed[1][2].

A workaround [3] is saving high or low in /sys/class/drm/card0/device/power_dpm_force_performance_level.

There is also a GUI solution [4] where you can manage the "power_dpm" with radeon-profile-gitAUR and radeon-profile-daemon-gitAUR.

R9 390 series Poor Performance and/or Instability

If you experience issues [5] with a AMD R9 390 series graphics card, set radeon.cik_support=0 radeon.si_support=0 amdgpu.cik_support=1 amdgpu.si_support=1 amdgpu.dpm=1 amdgpu.dc=1 as kernel parameters to force the use of amdgpu driver instead of radeon.

If it still does not work, try disabling DPM, by setting the kernel parameters to: radeon.cik_support=0 radeon.si_support=0 amdgpu.cik_support=1 amdgpu.si_support=1

Freezes with "[drm] IP block:gmc_v8_0 is hung!" kernel error

If you experience freezes and kernel crashes during a GPU intensive task with the kernel error " [drm] IP block:gmc_v8_0 is hung!" [6], a workaround is to set amdgpu.vm_update_mode=3 as kernel parameters to force the GPUVM page tables update to be done using the CPU. Downsides are listed here [7].

Cursor corruption

If you experience issues with the mouse cursor sometimes not rendering properly, set Option "SWCursor" "True" in the "Device" section of the /etc/X11/xorg.conf.d/20-amdgpu.conf configuration file.

If you are using xrandr for scaling and the cursor is flickering or disappearing, you may be able to fix it by setting the TearFree property: xrandr --output HDMI-A-0 --set TearFree on.