devutils/ATFQ/book ATFQ git

Part I · How it works

5.2 GPU drivers: the kernel, Mesa and NVIDIA

alsogpu drivergpu driversgraphics drivergraphics driversnvidia drivermesanouveauamdgpui915xeproprietary driverdrmopenglvulkanglxinfovulkaninfodriver/library version mismatch

TL;DR

  • A GPU driver has two halves: a kernel driver (DRM) that owns the device and its memory, and a user-space library that turns OpenGL or Vulkan calls into GPU commands.
  • Intel (i915, xe) and AMD (amdgpu) are in the kernel, and Mesa provides their OpenGL and Vulkan: nothing to install.
  • NVIDIA's own driver ships a kernel module and libraries that must match exactly. nouveau is the open driver, slower on recent cards.
lspci -k | grep -A3 -E 'VGA|3D'       # "Kernel driver in use"
glxinfo -B                            # OpenGL renderer (mesa-utils)
vulkaninfo --summary

On your machine

alice@laptopexample
$ atfq 5.2
  card0     Intel, driver i915, shows the boot screen
  Screens   eDP-1 1920x1200 · free: DP-1, HDMI-A-1
  Compute   /dev/dri/renderD128

  Loaded    4 modules; biggest: nvidia 53.7 MiB, nvidia_modeset 1.5 MiB,
            iwlwifi 476.0 KiB, snd_hda_intel 60.0 KiB
  Tainted   P: proprietary module loaded
            O: out-of-tree module loaded

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

What does each half do?

The kernel side sets screen modes, manages video memory, and schedules command buffers from many programs safely: one program can't read another's buffers. The user side, Mesa or NVIDIA's libraries, does the heavy lifting: compiling shaders into the GPU's instruction set and building the command buffers. Vulkan and OpenGL find it through loader files in /usr/share/vulkan/icd.d/ and glvnd.

Why is NVIDIA different?

NVIDIA long kept its kernel driver closed, so it can't be part of Linux and is built against each kernel separately. Since 2022 its kernel modules exist as open source (the default for recent GPUs), but the user-space libraries stay closed and versioned with them. Meanwhile, Mesa's NVK brings an open Vulkan driver for NVIDIA cards, on top of nouveau.

Commands
lspci glxinfo vulkaninfo modinfo
Paths
/sys/class/drm/ /proc/driver/nvidia/version
See also
21.2 Kernel modules
5.3 How a picture reaches the screen: KMS, Wayland and X11
20.2 The kernel command line