Enabling AMD Radeon 6900 XT Graphics on FreeBSD 14.0-RELEASE

Author: Jonathan Vasquez <jon@xyinn.org>
Last Updated: 2023-12-10-1700
Currently On: FreeBSD 14.0-RELEASE

Screenshot

Summary

The following will show you how to get the AMD Radeon 6900 XT card running on FreeBSD 14.0-RELEASE. This card was a bit trickier to set up in FreeBSD 13, but is now very easy to get up and running. Unfortunately, my workstation's AMD Ryzen 9 7950X's integrated graphics (Raphael) isn't supported on FreeBSD (yet), so I decided to get a dedicated card based on the success of astyle found here. Thank you astyle for your post!

The installation is basically extremely simple now. You just need to install the kernel driver via pkg, load the driver, and add it to your /etc/rc.conf to auto-load on boot.

Install the kernel driver

This should install the graphics meta package which should pull in drm-515-kmod and a bunch of firmware files. We really only care about sienna_cichlid, but for simplicity we will just install everything.

# pkg install drm-kmod

Load the module

# kldload amdgpu

Configure system to auto-load module on boot

Add the module to your /etc/rc.conf so that it loads automatically at boot:

/etc/rc.conf:

kld_list="amdgpu"

If you then query the installed packages filtering on drm and kmod, it should look something like this:

jon@leslie:~ $ pkg info | grep drm | grep kmod
drm-515-kmod-5.15.118_1        DRM drivers modules
drm-kmod-20220907_1            Metaport of DRM modules for the linuxkpi-based KMS components
gpu-firmware-kmod-20230210_1,1 Firmware modules for the drm-kmod drivers

That's basically it! Depending on your setup, you may need some extra configuration.

Other

Set the correct PCI card in Xorg (if needed)

If you have multiple GPUs (like an integrated card and a dedicated card), Xorg might freak out when starting. In this case, you can set the card you want to use with Xorg explicitly. For my machine I added the following in /usr/local/etc/X11/xorg.conf.d/00_video.conf, and it started up with no issues:

Section "Device"
    Identifier  "Card0"
    Driver      "modesetting"
    BusID       "PCI:3:0:0"
EndSection

The other (integrated) card detected would have been configured as:

Section "Device"
    Identifier  "Card1"
    Driver      "modesetting"
    BusID       "PCI:19:0:0"
EndSection

If you need to get the PCI number for your card, you can use pciconf -vl. This is the output related to my cards:

# Integrated Card

vgapci1@pci0:19:0:0:    class=0x030000 rev=0xc1 hdr=0x00 vendor=0x1002 device=0x164e subvendor=0x1043 subdevice=0x8877
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Raphael'
    class      = display
    subclass   = VGA

# Dedicated Card

vgapci0@pci0:3:0:0:     class=0x030000 rev=0xc0 hdr=0x00 vendor=0x1002 device=0x73af subvendor=0x1043 subdevice=0x04fe
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Navi 21 [Radeon RX 6900 XT]'
    class      = display
    subclass   = VGA

and the following is the output of dmesg | grep drm:

[drm] amdgpu kernel modesetting enabled.
drmn0: <drmn> on vgapci0
vgapci0: child drmn0 requested pci_enable_io
vgapci0: child drmn0 requested pci_enable_io
[drm] initializing kernel modesetting (SIENNA_CICHLID 0x1002:0x73AF 0x1043:0x04FE 0xC0).
drmn0: Trusted Memory Zone (TMZ) feature not supported
[drm] register mmio base: 0xFCA00000
[drm] register mmio size: 1048576
[drm] add ip block number 0 <nv_common>
[drm] add ip block number 1 <gmc_v10_0>
[drm] add ip block number 2 <navi10_ih>
[drm] add ip block number 3 <psp>
[drm] add ip block number 4 <smu>
[drm] add ip block number 5 <dm>
[drm] add ip block number 6 <gfx_v10_0>
[drm] add ip block number 7 <sdma_v5_2>
[drm] add ip block number 8 <vcn_v3_0>
[drm] add ip block number 9 <jpeg_v3_0>
drmn0: Fetched VBIOS from VFCT
[drm] VCN(0) decode is enabled in VM mode
[drm] VCN(1) decode is enabled in VM mode
[drm] VCN(0) encode is enabled in VM mode
[drm] VCN(1) encode is enabled in VM mode
[drm] JPEG decode is enabled in VM mode
drmn0: HBM ECC is not presented.
drmn0: SRAM ECC is not presented.
[drm] vm size is 262144 GB, 4 levels, block size is 9-bit, fragment size is 9-bit
drmn0: VRAM: 16368M 0x0000008000000000 - 0x00000083FEFFFFFF (16368M used)
drmn0: GART: 512M 0x0000000000000000 - 0x000000001FFFFFFF
[drm] Detected VRAM RAM=16368M, BAR=16384M
[drm] RAM width 256bits GDDR6
[drm] amdgpu: 16368M of VRAM memory ready
[drm] amdgpu: 16368M of GTT memory ready.
[drm] GART: num cpu pages 131072, num gpu pages 131072
[drm] PCIE GART of 512M enabled (table at 0x0000008000300000).
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_sos.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_ta.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_smc.bin'
lkpi_iic0: <LinuxKPI I2C> on drmn0
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_dmcub.bin'
[drm] Loading DMUB firmware via PSP: version=0x02020017
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_pfp.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_me.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_ce.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_rlc.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_mec.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_mec2.bin'
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_sdma.bin'
[drm] use_doorbell being set to: [true]
[drm] use_doorbell being set to: [true]
[drm] use_doorbell being set to: [true]
[drm] use_doorbell being set to: [true]
drmn0: successfully loaded firmware image 'amdgpu/sienna_cichlid_vcn.bin'
[drm] Found VCN firmware Version ENC: 1.26 DEC: 2 VEP: 0 Revision: 0
drmn0: Will use PSP to load VCN firmware
[drm] reserve 0xa00000 from 0x83fe000000 for PSP TMR
drmn0: smu driver if version = 0x00000039, smu fw if version = 0x00000041, smu fw version = 0x003a5600 (58.86.0)
drmn0: SMU driver if version not matched
drmn0: use vbios provided pptable
drmn0: SMU is initialized successfully!
[drm] Display Core initialized with v3.2.104!
[drm] DMUB hardware initialized: version=0x02020017
[drm] REG_WAIT timeout 1us * 100000 tries - mpc2_assert_idle_mpcc line:482
lkpi_iic1: <LinuxKPI I2C> on drmn0
lkpi_iic2: <LinuxKPI I2C> on drmn0
lkpi_iic3: <LinuxKPI I2C> on drmn0
lkpi_iic4: <LinuxKPI I2C> on drmn0
[drm] kiq ring mec 2 pipe 1 q 0
[drm] VCN decode and encode initialized successfully(under DPG Mode).
[drm] JPEG decode initialized successfully.
drmn0: SE 4, SH per SE 2, CU per SH 10, active_cu_number 80
[drm] fb mappable at 0xF800570000
[drm] vram apper at 0xF800000000
[drm] size 14745600
[drm] fb depth is 24
[drm]    pitch is 10240
[drm] REG_WAIT timeout 1us * 100000 tries - mpc2_assert_idle_mpcc line:482
name=drmn0 flags=0x0 stride=10240 bpp=32
drmn0: ring gfx_0.0.0 uses VM inv eng 0 on hub 0
drmn0: ring comp_1.0.0 uses VM inv eng 1 on hub 0
drmn0: ring comp_1.1.0 uses VM inv eng 4 on hub 0
drmn0: ring comp_1.2.0 uses VM inv eng 5 on hub 0
drmn0: ring comp_1.3.0 uses VM inv eng 6 on hub 0
drmn0: ring comp_1.0.1 uses VM inv eng 7 on hub 0
drmn0: ring comp_1.1.1 uses VM inv eng 8 on hub 0
drmn0: ring comp_1.2.1 uses VM inv eng 9 on hub 0
drmn0: ring comp_1.3.1 uses VM inv eng 10 on hub 0
drmn0: ring kiq_2.1.0 uses VM inv eng 11 on hub 0
drmn0: ring sdma0 uses VM inv eng 12 on hub 0
drmn0: ring sdma1 uses VM inv eng 13 on hub 0
drmn0: ring sdma2 uses VM inv eng 14 on hub 0
drmn0: ring sdma3 uses VM inv eng 15 on hub 0
drmn0: ring vcn_dec_0 uses VM inv eng 0 on hub 1
drmn0: ring vcn_enc_0.0 uses VM inv eng 1 on hub 1
drmn0: ring vcn_enc_0.1 uses VM inv eng 4 on hub 1
drmn0: ring vcn_dec_1 uses VM inv eng 5 on hub 1
drmn0: ring vcn_enc_1.0 uses VM inv eng 6 on hub 1
drmn0: ring vcn_enc_1.1 uses VM inv eng 7 on hub 1
drmn0: ring jpeg_dec uses VM inv eng 8 on hub 1
vgapci0: child drmn0 requested pci_get_powerstate
lkpi_iic5: <LinuxKPI I2C> on drm2
lkpi_iic6: <LinuxKPI I2C> on drm3
lkpi_iic7: <LinuxKPI I2C> on drm4
[drm] Initialized amdgpu 3.40.0 20150101 for drmn0 on minor 0

I'm not currently using my integrated card given the lack of support so I just disabled it in the BIOS. Once Raphael graphics is supported, and if GPU passthrough technology on bhyve reaches a point where I could pass my dedicated card to it to play games on Windows 10, I would be open to using it again with that setup. For now I'll continue to game on other laptop with my Windows 10 Dark Mode approach.

Lastly, if you are using poudriere to build your packages (which is how I normally manage my packages across all of my FreeBSD machines), you'll need to specify the flavor for the gpu-firmware-amd-kmod package. If you don't do this, it will default to only using the first flavor, which is not what we want in our case. Your poudriere packages file should have the following:

graphics/drm-515-kmod
graphics/gpu-firmware-amd-kmod@sienna_cichlid

Notice that I used @sienna_cichlid to specify the specific flavor. You can find the documentation for the poudriere flavor stuff here. Search for FLAVORS.