Enabling Navi 10 On Fedora 31
Contents
Purpose
This guide explains how to add enable Navi 10 based GPUs such as the AMD RX Radeon 5700 XT on Fedora 31.
Background
Linux kernel versions up to and including 5.5 do not support display output when using Navi based cards. A set of kernel patches have been developed ot enable display support. To enable the display the kernel must be recompiled.
Preparations
Disabling fast-reset
AMD GPUs can only have firmware loaded once between resets. This causes issues when the fast-reset support is enabled. Before continuing with this guide, please disable fast-reset by rebooting to petitboot.
First, exit to the shell in petitboot.
Petitboot (v1.10.3-pdd2d545) C1P9S01 REV 1.01 D1000092 ────────────────────────────────────────────────────────────────────────────── [Disk: nvme0n1p1 / fcc4819d-39e1-49f0-81ad-c26d444cb806] Fedora (0-rescue-03d8a2f6d3e946e896b45faac2a97657) 32 (Rawhide) Fedora (5.4.0-rc7+) 32 (Workstation Edition) (*) Fedora (5.4.0-2.fc32.ppc64le) 32 (Rawhide) [USB: sdb / 2019-10-23-22-57-00-00] Rescue a Fedora system (64-bit kernel) Test this media & install Fedora 31 (64-bit kernel) Install Fedora 31 (64-bit kernel) System information System configuration System status log Language Rescan devices Retrieve config from URL Plugins (0) *Exit to shell ────────────────────────────────────────────────────────────────────────────── Enter=accept, e=edit, n=new, x=exit, l=language, g=log, h=help [enP4p1s0f2] PXE autoconfiguration failed
Next, update the nvram configuration using nvram -p ibm,skiboot --update-config fast-reset=0
To confirm that the variable was updated, use nvram -p ibm,skiboot --print-config
Exiting petitboot. Type 'exit' to return. You may run 'pb-sos' to gather diagnostic data No password set, running as root. You may set a password in the System Configuration screen. # nvram -p ibm,skiboot --update-config fast-reset=0 # nvram -p ibm,skiboot --print-config "ibm,skiboot" Partition
fast-reset=0 #
Exit and boot back in to Fedora.
Installing the Development Tools
Before building a custom kernel, the development tools must be installed
sudo dnf install @development-tools
Compiling The Kernel
An update kernel with the kernel patches applied must be created. This can be done following the below guide based on https://fedoraproject.org/wiki/Building_a_custom_kernel#Building_a_kernel_from_the_exploded_git_trees
First, checkout the kernel source code. IN this case, we are using the kernel-5.5.0-0.rc1.git0.1.fc32 branch:
[user@bb ~]$ cd ~ [user@bb ~]$ mkdir git [user@bb ~]$ cd git [user@bb git]$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/fedora.git --depth 1 --branch kernel-5.5.0-0.rc1.git0.1.fc32 Cloning into 'fedora'... remote: Enumerating objects: 70582, done. remote: Counting objects: 100% (70582/70582), done. remote: Compressing objects: 100% (67451/67451), done. Receiving objects: 100% (69754/69754), 184.63 MiB | 733.00 KiB/s, done. Resolving deltas: 100% (5304/5304), done. Note: switching to '46d9a88e328bb8135db0a6b58b21cfd3b71ba75e'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false Updating files: 100% (65721/65721), done. [user@bb git]$
Download and apply the kernel patches:
[user@bb git]$ cd fedora/ [user@bb fedora]$ wget https://gitlab.freedesktop.org/drm/amd/uploads/f8c299fc4fd373a8cbc380f348204b61/0001-amdgpu-Prepare-DCN-floating-point-macros-for-generic.patch [user@bb fedora]$ wget https://gitlab.freedesktop.org/drm/amd/uploads/7d194992837c8706ca5966b682d5680b/0002-amdgpu-Enable-initial-DCN-support-on-POWER.patch [user@bb fedora]$ wget https://gitlab.freedesktop.org/drm/amd/uploads/86353afdb43409add84005cef8c5abc0/0003-amdgpu-Wrap-FPU-dependent-functions-in-dc20.patch [user@bb fedora]$ git am *.patch Applying: amdgpu: Prepare DCN floating point macros for generic arch support Applying: amdgpu: Enable initial DCN support on POWER Applying: amdgpu: Wrap FPU dependent functions in dc20 [user@bb fedora]$ sed -i 's/.num_dsc = 5,//g' drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
Configure the kernel, selecting the defaults and DCN_2_0 if prompted:
[user@bb fedora]$ cp /boot/config-*.ppc64le .config [user@bb fedora]$ sed -i 's/CONFIG_DEBUG_INFO=y/# CONFIG_DEBUG_INFO is not set/g' .config [user@bb fedora]$ sed -i 's/CONFIG_DEBUG_INFO_BTF=y/# CONFIG_DEBUG_INFO_BTF is not set/g' .config [user@bb fedora]$ make oldconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf scripts/kconfig/conf --oldconfig Kconfig * * Restart config... * * * Kernel options * Timer frequency > 1. 100 HZ (HZ_100) 2. 250 HZ (HZ_250) 3. 300 HZ (HZ_300) 4. 1000 HZ (HZ_1000) choice[1-4?]: 1 ... * * Display Engine Configuration * AMD DC - Enable new display engine (DRM_AMD_DC) [Y/n/?] y DCN 2.0 family (DRM_AMD_DC_DCN2_0) [Y/n/?] y DCN 2.1 family (DRM_AMD_DC_DCN2_1) [N/y/?] n DSC support (DRM_AMD_DC_DSC_SUPPORT) [N/y/?] n Enable HDCP support in DC (DRM_AMD_DC_HDCP) [N/y/?] (NEW) ...
Build the kernel
[user@bb fedora]$ make -j`nproc` ...
Installing the kernel
[user@bb fedora]$ sudo make INSTALL_MOD_STRIP=1 -j`nproc` modules_install [sudo] password for user: **** ... INSTALL sound/usb/snd-usb-audio.ko INSTALL sound/usb/snd-usbmidi-lib.ko INSTALL sound/usb/usx2y/snd-usb-usx2y.ko DEPMOD 5.5.0-rc1+ Warning: modules_install: missing 'System.map' file. Skipping depmod. [user@bb fedora]$ sudo make INSTALL_MOD_STRIP=1 -j`nproc` install LDS arch/powerpc/boot/zImage.lds WRAP arch/powerpc/boot/zImage.pseries WRAP arch/powerpc/boot/zImage.epapr sh -x ./arch/powerpc/boot/install.sh "5.5.0-rc1+" vmlinux System.map "/boot" + set -e + '[' -x /root/bin/installkernel ']' + '[' -x /sbin/installkernel ']' + exec /sbin/installkernel 5.5.0-rc1+ vmlinux System.map /boot [user@bb fedora]$
At this point, the new kernel has been installed and can be booted. However, the kernel will not be selected as the default and should only be done once it's confirmed working.
Defaulting to the new Kernel
Before the patched kernel will be automatically booted, the grub configuration file must be changed.
Locate the entry id
[user@bb ~]$ sudo grep "menuentry 'Fedora (5.5.0-rc1+)" /boot/grub2/grub.cfg | cut -d "=" -f2 | cut -d " " -f1 03d8a2f6d3e946e896b45faac2a97657-5.5.0-rc1+
Update the default kernel
The /boot/grub2/grubenv file must be updated. (Replace the text in red as appropriate.)
[user@bb ~]$ sudo sed -i 's/saved_entry=.*/saved_entry=03d8a2f6d3e946e896b45faac2a97657-5.5.0-rc1+/g' /boot/grub2/grubenv [user@bb ~]$ sudo cat /boot/grub2/grubenv # GRUB Environment Block saved_entry=03d8a2f6d3e946e896b45faac2a97657-5.5.0-rc1+ kernelopts=root=/dev/mapper/fedora_bb-root ro rd.lvm.lv=fedora_bb/root rd.lvm.lv=fedora_bb/swap rhgb quiet boot_success=0 boot_indeterminate=0 #####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Configuring The Display
Before continuing, X11 must be configured to use the Navi card instead of the built-in AST device. This must be done by following steps one and two of Troubleshooting/GPU#Workaround_2:_Select_desired_GPU_at_runtime