Direct Rendering Manager

From Wikipedia, the free encyclopedia
  (Redirected from KMS driver)
Jump to: navigation, search
Direct Rendering Manager
Original author(s) &
Developer(s) &
Written in C

The Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for interfacing with GPUs of modern video cards. DRM exposes an API that user space programs can use to send commands and data to the GPU, and perform operations like configuring the mode setting of the display. DRM was first developed as the kernel space component of the X Server's Direct Rendering Infrastructure,[1] but since then it has been used by other graphic stack alternatives like Wayland.

The Direct Rendering Manager can be compiled into the Linux kernel or loaded via the standard module interface.


The Linux Kernel already had an API called fbdev allowing to manage the framebuffer of a graphics adapter, but it couldn't be used to handle the needs of modern 3D accelerated GPU based video cards. These type of cards usually require setting and managing a command queue in the memory of the card (Video RAM) to dispatch commands to the GPU, and also they need a proper management of the buffers and free space of the Video RAM itself.[2] Initially own user space programs (like the X Server) directly managed these resources, but these programs usually acted as if they were the only ones with access to the card's resources. When two or more programs tried to control the same video card at the same time, and set its resources each one in its own way, most times they ended catastrophically.[2]

Access to video card without DRM
Without DRM
Access to video card with DRM
With DRM
DRM allows multiple programs concurrently access to the 3D video card avoiding collisions

When the Direct Render Manager was first created, the purpose was that multiple programs that would use the resources of the video card cooperate through it. The DRM has exclusive access to the video card's resources, and it's responsible for initializing and maintaining the command queue, the VRAM and any other hardware resource of the GPU. The programs that want to use a GPU send their requests to DRM, which acts as an arbitrator and takes care to avoid possible conflicts.

Since then, the scope of DRM has been expanded over the years to cover more functionality previously handled by user space programs, like framebuffer managing and mode setting, memory sharing objects and memory synchronization.[3][4] These expansions had carried its own specific names, like Graphics Execution Manager (GEM) or Kernel Mode-Setting (KMS), and are often called by these names when referring specifically to its functionality. But they are really parts of the whole kernel DRM subsystem.

Software architecture[edit]

A process using the Direct Rendering Manager of the Linux Kernel to access a 3D accelerated graphics card

The Direct Rendering Manager resides in kernel space, so the user space programs must use kernel system calls to request its services. However, DRM doesn't define its own customized system calls. Instead, it follows the Unix principle "everything is a file" to expose the GPUs through the filesystem name space using device files under the /dev hierarchy. Each GPU detected by DRM is referred as a DRM device, and a device file /dev/dri/cardX (where X is a correlative number) is created to interface with the device.[5][6] The user space programs that want to talk to the GPU must open the file and use ioctl calls to communicate with DRM. Different ioctls correspond to different functions of the DRM API.

A library called libdrm was created to facilitate the interface of user space applications with the DRM subsystem. This library is merely a wrapper that provides a function written in C for every ioctl of the DRM API, as well as constants, structures and other helper elements.[7] The use of libdrm not only avoids exposing the kernel interface directly to the user space applications, but presents the usual advantages of reusing and sharing code between programs.

It consists of two in-kernel drivers: a generic drm driver, and another which has specific support for the GPUs. This pair of drivers allows a userspace client direct access to the video hardware. The entire DRI system enables hardware accelerated 3D rendering, video decoding as well as GPGPU.

AGP, PCIe and other graphics cards contain an IOMMU called Graphics address remapping table (GART) which can be used to map various pages of system memory into the GPU's address space. The result is that, at any time, an arbitrary (scattered) subset of the system's RAM pages are accessible to the GPU.[8]


The Linux API is composed out of the System Call Interface of the Linux kernel, the GNU C Library (by GNU), libcgroup,[9] libdrm, libalsa and libevedv[10] (by

The DRM core exports several interfaces to user-space applications, generally intended to be used through corresponding libdrm wrapper functions. In addition, drivers export device-specific interfaces for use by user-space drivers & device-aware applications through ioctls and sysfs files. External interfaces include: memory mapping, context management, DMA operations, AGP management, vblank control, fence management, memory management, and output management.

Translation Table Maps[edit]

Translation Table Maps memory manager developed by Tungsten Graphics.

Graphics Execution Manager[edit]

The Graphics Execution Manager (GEM) is part of the DRM API that allow multiple applications to share graphics device memory resources (called GEM objects). GEM ensures conflict-free sharing of data between applications by managing the memory synchronization. In contrary to its name, it executes nothing, it manages graphics memory.

KMS driver (Kernel mode setting)[edit]

There must be a "DRM master" in user-space, this program has exclusive access to KMS.

The KMS driver is the component which is solely responsible for the mode setting. It is the device driver for a display controller, and it can be distinguished from the device driver of a rendering accelerator. Due to the fact that dies of modern the GPU found on graphics cards for desktop computers integrate "processing logic", "display controller" and "hardware video acceleration" SIP cores, non-technical people don't distinguish between these three very different components. SoCs on the other hand, regularly mix SIP from different developers, and e.g. ARM's Mali SIP does not feature a display controller. For historical reasons, the DRM and the KMS of the Linux kernel were amalgamated into one component. They were split in 2013 for technical reasons.[11]

The video Embedded Linux Conference 2013 – Anatomy of an Embedded KMS driver on YouTube explains what a KMS driver is.

Render nodes[edit]

A render node is a character device that exposes a GPU's off-screen rendering and GPGPU capabilities to unprivileged programs, without exposing any display manipulation access. This is the first step in of an effort to decouple the kernel's interfaces for GPUs and display controllers from the obsolete notion of a graphics card.[11] Unprivileged off-screen rendering is presumed by both Wayland and Mir display protocols — only the compositor is entitled to send its output to a display, and rendering on behalf of client programs is outside the scope of these protocols.

Universal plane[edit]

Patches for universal plane were submitted by Intel's Matthew. D. Roper in May 2014. The idea behind universal plane is to expose all types of hardware planes to userspace via one consistent Kernel–user space API.[12] Universal plane brings framebuffers (primary planes), overlays (secondary planes) and cursors (cursor planes) together under the same API. No more type specific ioctls, but common ioctls shared by them all.[13]

Universal plane prepares the way for Atomic mode setting and nuclear pageflip.

Hardware support[edit]

DRM is to be used by user-mode graphics devices driver, like e.g. AMD Catalyst or Mesa 3D. User-space programm use the Linux System Call Interface to access DRM. DRM augments the Linux System Call Interface with own system calls.

As of August 2013, the kernel component of the freedreno driver mainly authored by Rob Clark for Qualcomm's Adreno GPU family, called MSM driver, has been accepted into mainline, and has been available since Linux kernel 3.12.[14][15]

In Linux kernel 3.13

  • DRM support for Marvell's ARMADA 510 display subsystem.[16]

DRM/i915 obtained support for MIPI Display Serial Interface (DSI) for Linux kernel 3.16.[17]


The Direct Rendering Manager is developed within the Linux kernel, and its source code resides in the /drivers/gpu/drm directory of the Linux source code. The subsystem maintainter is Dave Airlie, with other maintainers taking care of specific drivers.[18] As usual in the Linux kernel development, DRM submaintainers and contributors send their patches with new features and bug fixes to the main DRM maintainer which integrates them into its own Linux repository. The DRM maintainer in turn submits all of these patches that are ready to be mainlined to Linus Torvalds whenever a new Linux version is going to be released. Torvalds, as top maintainer of the whole kernel, holds the last word on whether a patch is suitable or not for inclusion in the kernel.

For historical reasons, the source code of the libdrm library is maintained under the umbrella of the Mesa project.[19]


In 1999, while developing DRI for XFree86, Precision Insight created the first version of DRM for the 3dfx video cards, as a linux kernel patch included within the Mesa source code.[20] Later that year, the DRM code was mainlined in Linux kernel 2.3.18 under the /drivers/char/drm/ directory for character devices.[21] During the following years the number of supported video cards grew. When Linux 2.4.0 was released in January 2001 there was already support for Creative Labs GMX 2000, Intel i810, Matrox G200/G400 and ATI Rage 128, in addition to 3dfx Voodoo3 cards.[22]

Recent developments[edit]

Render nodes[edit]

In 2013, as part of GSoC, David Herrmann developed the multiple render nodes feature.[23] His code was added to the Linux kernel version 3.12 as an experimental feature[24][25][26][27][28] and enabled by default since Linux 3.17.[29]

See also[edit]


  1. ^ "Linux kernel/drivers/gpu/drm/README.drm". Retrieved 2014-02-26. 
  2. ^ a b White, Thomas. "How DRI and DRM Work". Retrieved 22 July 2014. 
  3. ^ Corbet, Jonathan. "Memory management for graphics processors". LWN.Net. Retrieved 23 July 2014. 
  4. ^ Packard, Keith; Anholt, Eric. "The Graphics Execution Manager". LWN.Net. Retrieved 23 July 2014. 
  5. ^ Kitching, Simon. "DRM and KMS kernel modules". Retrieved 23 July 2014. 
  6. ^ Herrmann, David. "Splitting DRM and KMS device nodes". Retrieved 23 July 2014. 
  7. ^ "libdrm README". Retrieved 23 July 2014. 
  8. ^ "Memory management for graphics processors". 2007-11-06. Retrieved 2014-06-25. 
  9. ^ "ControlGroupInterface". 
  10. ^ "libevdev". 
  11. ^ a b "Splitting DRM and KMS nodes". David Herrmann. 2013-09-01. 
  12. ^ "Universal plane support". 2014-05-07. 
  13. ^ "From pre-history to beyond the global thermonuclear war". 2014-06-05. 
  14. ^ "Merge the MSM driver from Rob Clark". 2013-08-28. Retrieved 2014-06-25. 
  15. ^ "drm/msm for Linux kernel 3.13". 2013-10-20. 
  16. ^ "Armada DRM support for Linux kernel 3.13". 
  17. ^ "Neat drm/i915 stuff for 3.16". 2014-06-10. 
  18. ^ "List of maintainers of the linux kernel". Retrieved 14 July 2014. 
  19. ^ "libdrm git repository". Retrieved 23 July 2014. 
  20. ^ "First DRI release of 3dfx driver.". Mesa 3D. Retrieved 15 July 2014. 
  21. ^ "Import 2.3.18pre1". The History of Linux in GIT Repository Format 1992-2010 (2010). Retrieved 15 July 2014. 
  22. ^ Torvalds, Linus. "Linux 2.4.0 source code". Retrieved 29 July 2014. 
  23. ^ Herrmann, David. "DRM Render- and Modeset-Nodes". Retrieved 21 July 2014. 
  24. ^ Corbet, Jonathan. "3.12 merge window, part 2". LWN.Net. Retrieved 21 July 2014. 
  25. ^ "drm: implement experimental render nodes". 
  26. ^ "drm/i915: Support render nodes". 
  27. ^ "drm/radeon: Support render nodes". 
  28. ^ "drm/nouveau: Support render nodes". 
  29. ^ Corbet, Jonathan. "3.17 merge window, part 2". Retrieved 7 October 2014. 

External links[edit]