GPU Kernel Options and Firmware

The Linux kernel has multiple drivers for all sorts of hardware, including GPUs, and most open source drivers are in the kernel. This includes AMD, i915, and Nouveau. There are other drivers as well that can be useful for certain users. Firmware is also necessary for many drivers.

Kernel Configuration

The kernel options below enable GPU and virtual GPU drivers. Enable the ones you need and recompile the kernel if necessary.

Device Drivers --->
  Graphics support --->
    <*/M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
                                                                      ...  [DRM]
      # For r300 or r600:
      < /*/M> ATI Radeon                                            [DRM_RADEON]
      # For radeonsi:
      < /*/M> AMD GPU                                               [DRM_AMDGPU]
      [*]       Enable amdgpu support for SI parts               [DRM_AMDGPU_SI]
      [*]       Enable amdgpu support for CIK parts             [DRM_AMDGPU_CIK]
        Display Engine Configuration --->
        [*]   AMD DC - Enable new display engine                    [DRM_AMD_DC]
      # For nouveau:
      < /*/M> Nouveau (NVIDIA) cards                               [DRM_NOUVEAU]
      [*]       Use GSP firmware for Turing/Ampere (needs firmware installed)
                                                  ...  [DRM_NOUVEAU_GSP_DEFAULT]
      # For i915, crocus, or iris:
      < /*/M> Intel 8xx/9xx/G3x/G4x/HD Graphics                       [DRM_I915]
      # For LLVMPipe or Softpipe:
      < /*>   Virtual GEM provider                                    [DRM_VGEM]
      # For svga:
      < /*/M> DRM driver for VMware Virtual GPU                     [DRM_VMWGFX]
[Note]

Note

There are comments for the options above, corresponding with Mesa's Gallium3D dri driver names.

Selecting CONFIG_DRM_RADEON, CONFIG_DRM_AMDGPU, or CONFIG_DRM_NOUVEAU as y is not recommended. If it is, any required firmware must be built as a part of the kernel image or the initramfs for the driver to function correctly.

The sub-entries under CONFIG_DRM_AMDGPU are used to ensure the AMDGPU kernel driver supports all GPUs using the radeonsi driver. They are not needed if you won't need CONFIG_DRM_AMDGPU itself. They may be unneeded for some GPU models.

For LLVMPipe or LLVMPipe, CONFIG_DRM_VGEM is required or Xorg clients will probably fail with a cryptic message Error: couldn't get an RGB, Double-buffered visual. While this can be compiled as a module, it is more convenient to just build it into the kernel, otherwise the module will not be loaded automatically.

Firmware

ATI Firmware

ATI Radeon GPUs require firmware to be able to use KMS (kernel modesetting - the preferred option) as well as for Xorg. The firmware is in linux-firmware.

In order to save space, it is recommended to use pciutils-3.13.0 and it's packaged binary lspci to identify what the VGA controller is. After you find out that, check the RadeonFeature page of the Xorg wiki for Decoder ring for engineering vs marketing names to identify the family (you may need to know this for the Xorg driver — Southern Islands and Sea Islands use the radeonsi driver) and the specific model.

Now that you know which controller you are using, consult the Radeon Firmware page of the Gentoo wiki which has a table listing the required firmware blobs for the various chipsets. Note that Southern Islands and Sea Islands chips use different firmware for kernel 3.17 and later compared to earlier kernels. Identify and download the required blobs then install them:

mkdir -pv /usr/lib/firmware/radeon &&
cp -v <YOUR_BLOBS> /usr/lib/firmware/radeon

RadeonSI Firmware

AMDGPU devices require firmware in order to be used in general. Install pciutils-3.13.0 to check the model name of your card, and look for 'VGA compatible controller:'. If you have an APU (Accelerated Processing Unit, i.e. CPU and video on the same chip) that will probably tell you the name. If you have a separate amdgpu video card you will need to search to determine which name it uses (e.g. a card described as Advanced Micro Devices, Inc. [AMD/ATI] Baffin [Radeon RX 550 640SP / RX 560/560X] need Polaris11 firmware. There is a table of "Family, Chipset name, Product name and Firmware" at the end of the Kernel sections in AMDGPU page of the Gentoo wiki.

Once you have identified the firmware name, install all the relevant files for it. For example, the Baffin card mentioned above has 21 different polaris11* files, APUs such as renoir and picasso have at least 12 files and might gain more in future updates (e.g. the raven APU now has a 13th file, raven_ta.bin).

mkdir -pv /usr/lib/firmware/amdgpu &&
cp -v <YOUR_BLOBS> /usr/lib/firmware/amdgpu

If disk space is not a problem, you could install all the current amdgpu firmware files and not worry about exactly which chipset is installed.

i915 Firmware

Intel integrated GPUs from Skylake onwards can use firmware for GuC (the Graphics microcontroller), and also for the HuC (HEVC/H265 microcontroller which offloads to the GPU) and the DMC (Display Microcontroller) to provide additional low-power states. The GuC and HuC have had a chequered history in the kernel and updated firmware may be disabled by default, depending on your kernel version.Further details may be found at https://01.org/linuxgraphics/downloads/firmware/ and https://wiki.archlinux.org/index.php/intel_graphics.

NVIDIA Firmware

Some NVIDIA GPUs from Kepler onwards, including RTX and GTX 9xx series onwards, require firmware signed by NVIDIA to work. NVIDIA has now released firmware up to Ada (40xx) to linux-firmware. Read the CodeNames page of the Nouveau wiki to figure out the code name of your NVIDIA GPU (for example, the code name of the GeForce RTX 4060 Ti is AD106). The directory for the firmware files you need is named as the result converting the code name to lowercase (ad106 for the example). The directory (or some of its contents) may be actually a symlink to another directory (or some files in another directory).

The WHENCE file in the linux-firmware directory documents all the firmware files and potential symlinks. Once you found what you need, look it up in WHENCE and make the necessary symlinks. If you cannot find your GPU listed in WHENCE, it means your GPU either doesn't need firmware or the firmware has not been released yet. If you don't want to bother and would rather install all the drivers and symlinks, follow the instructions below in order to install the newer firmware properly automatically:

git clone https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git  &&
cd linux-firmware                                                                      &&
mkdir -pv /usr/lib/firmware/nvidia                                                     &&
mkdir -pv DESTDIR/usr/lib/firmware                                                     &&
sh copy-firmware.sh --ignore-duplicates DESTDIR/usr/lib/firmware                       &&
cp -vr DESTDIR/usr/lib/firmware/nvidia/* /usr/lib/firmware/nvidia                      &&
rm -rf DESTDIR

For NVIDIA GPUs from Tesla to Kepler, the Nouveau driver requires some extra firmware to support video decoding acceleration. These firmware files are not released by NVIDIA but they can be extracted from the NVIDIA runfile:

wget https://anduin.linuxfromscratch.org/BLFS/nvidia-firmware/extract_firmware.py        &&
wget https://us.download.nvidia.com/XFree86/Linux-x86/340.32/NVIDIA-Linux-x86-340.32.run &&
sh NVIDIA-Linux-x86-340.32.run --extract-only                                            &&
python3 extract_firmware.py                                                              &&
mkdir -p /usr/lib/firmware/nouveau                                                       &&
cp -d nv* vuc-* /usr/lib/firmware/nouveau/