=== DRM drivers (i.e. GPU drivers)

Links: +
link:https://github.com/freebsd/drm-kmod[Git repository on GitHub] URL: link:https://github.com/freebsd/drm-kmod[] +

Contact: Emmanuel Vadot <manu@FreeBSD.org> +
Contact: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> +
Contact: The Graphics team <freebsd-x11@FreeBSD.org>

GPUs are driven by DRM drivers.
They are developed specifically for Linux using a permissive license.
Our mission is to port those drivers to FreeBSD to make sure modern GPUs are fully supported.

We didn't publish a report to share our progress for a long time.
Therefore this status report entry will cover more than just the last quarter.

==== Update to Linux 5.15 LTS and Linux 5.16

As of this status report, the package:graphics/drm-kmod[] meta port still installs the DRM drivers from Linux 5.10 (released on December 13, 2020) on FreeBSD 13.1 and greater.
This version of the driver lacks support for recent GPUs, in particular Intel 12th gen Alder Lake ones.
In the past months, we worked to update the DRM drivers to bring support for more modern AMD and Intel GPUs.

The `drm-kmod` Git repository `master` branch was first updated to Linux 5.15 (released on October 31, 2021).
This is an LTS branch in Linux and we wanted to take advantage of that.
Thus at that point, we followed two paths:

* A `5.15-lts` branch was created to backport all bug fixes from Linux 5.15.x patch releases. This work is now available in the `drm-515-kmod` port.
* The porting effort from subsequent Linux versions continued. The `master` branch is now at Linux 5.16 (release on January 9, 2022).

The Intel driver from Linux 5.15 LTS supports 12th gen GPUs (Alder Lake).
It looks to work on FreeBSD but we only tested it lightly so far.
We still need more of that, that's why package:graphics/drm-kmod[] still installs package:graphics/drm-510-kmod[] instead of package:graphics/drm-515-kmod[].
At last, FreeBSD should run as a desktop on this GPU generation and several new AMD GPUs, though problems will surely appear through real test and use.

In the process, we updated firmwares to link:https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git[linux-firmware] 20230210.

==== Linux 5.17 and future work

DRM drivers from Linux 5.17 (released on March 20, 2022) were already ported but link:https://github.com/freebsd/drm-kmod/pull/236[this work still sits in its own branch].

A couple of issues block further testing and the merge into the `master` branch:

* Our current integration with man:vt[4], the console/terminal driver, is quite far from the DRM drivers expectations which are based on Linux' fbdev KPI. Something changed in both the Intel and AMD drivers, meaning that man:vt[4] breaks with the 5.17 update.
* The initial Linux 5.17 release does not contain the fixes backported to Linux 5.15 LTS. It seems quite unstable with the Intel 12th gen GPU mentioned earlier.

To address the issue with our man:vt[4] integration layer, we started to link:https://github.com/freebsd/drm-kmod/pull/243[write a new vt backend specifically to use the fbdev callbacks exposed by the DRM drivers].
This backend will be provided with the DRM drivers, not the FreeBSD kernel, to make it easier to maintain as the drivers evolve.
This is still a work in progress and locking in particular is tricky to get right.

Regarding the bad support of Intel 12th gen in the 5.17 update, bug fixes backported to Linux 5.17.x patch releases will probably not be ported as part of this work.
Instead we will focus on Linux 5.18 (released on May 22, 2022) and following.
