<s>
The	O
Direct	O
Rendering	O
Manager	O
(	O
DRM	O
)	O
is	O
a	O
subsystem	O
of	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
responsible	O
for	O
interfacing	O
with	O
GPUs	B-Architecture
of	O
modern	O
video	B-Device
cards	I-Device
.	O
</s>
<s>
DRM	O
exposes	O
an	O
API	B-Application
that	O
user-space	B-Operating_System
programs	O
can	O
use	O
to	O
send	O
commands	O
and	O
data	O
to	O
the	O
GPU	B-Architecture
and	O
perform	O
operations	O
such	O
as	O
configuring	O
the	O
mode	B-Operating_System
setting	I-Operating_System
of	O
the	O
display	O
.	O
</s>
<s>
DRM	O
was	O
first	O
developed	O
as	O
the	O
kernel-space	B-Operating_System
component	O
of	O
the	O
X	B-Operating_System
Server	I-Operating_System
Direct	B-Application
Rendering	I-Application
Infrastructure	I-Application
,	O
but	O
since	O
then	O
it	O
has	O
been	O
used	O
by	O
other	O
graphic	O
stack	O
alternatives	O
such	O
as	O
Wayland	B-Language
and	O
standalone	O
applications	O
and	O
libraries	O
such	O
as	O
SDL2	O
and	O
Kodi	O
.	O
</s>
<s>
User-space	B-Operating_System
programs	O
can	O
use	O
the	O
DRM	O
API	B-Application
to	O
command	O
the	O
GPU	B-Architecture
to	O
do	O
hardware-accelerated	B-General_Concept
3D	O
rendering	O
and	O
video	B-Application
decoding	I-Application
,	O
as	O
well	O
as	O
GPGPU	B-Architecture
computing	I-Architecture
.	O
</s>
<s>
The	O
Linux	B-Operating_System
kernel	I-Operating_System
already	O
had	O
an	O
API	B-Application
called	O
fbdev	B-Language
,	O
used	O
to	O
manage	O
the	O
framebuffer	B-Algorithm
of	O
a	O
graphics	B-Device
adapter	I-Device
,	O
but	O
it	O
could	O
n't	O
be	O
used	O
to	O
handle	O
the	O
needs	O
of	O
modern	O
3D-accelerated	O
GPU-based	O
video	O
hardware	O
.	O
</s>
<s>
These	O
devices	O
usually	O
require	O
setting	O
and	O
managing	O
a	O
command	O
queue	O
in	O
their	O
own	O
memory	O
to	O
dispatch	O
commands	O
to	O
the	O
GPU	B-Architecture
and	O
also	O
require	O
management	O
of	O
buffers	B-General_Concept
and	O
free	O
space	O
within	O
that	O
memory	O
.	O
</s>
<s>
Initially	O
,	O
user-space	B-Operating_System
programs	O
(	O
such	O
as	O
the	O
X	B-Operating_System
Server	I-Operating_System
)	O
directly	O
managed	O
these	O
resources	O
,	O
but	O
they	O
usually	O
acted	O
as	O
if	O
they	O
were	O
the	O
only	O
ones	O
with	O
access	O
to	O
them	O
.	O
</s>
<s>
The	O
DRM	O
gets	O
exclusive	O
access	O
to	O
the	O
GPU	B-Architecture
and	O
is	O
responsible	O
for	O
initializing	O
and	O
maintaining	O
the	O
command	O
queue	O
,	O
memory	O
,	O
and	O
any	O
other	O
hardware	O
resource	O
.	O
</s>
<s>
Programs	O
wishing	O
to	O
use	O
the	O
GPU	B-Architecture
send	O
requests	O
to	O
DRM	O
,	O
which	O
acts	O
as	O
an	O
arbitrator	O
and	O
takes	O
care	O
to	O
avoid	O
possible	O
conflicts	O
.	O
</s>
<s>
The	O
scope	O
of	O
DRM	O
has	O
been	O
expanded	O
over	O
the	O
years	O
to	O
cover	O
more	O
functionality	O
previously	O
handled	O
by	O
user-space	B-Operating_System
programs	O
,	O
such	O
as	O
framebuffer	B-Algorithm
managing	O
and	O
mode	B-Operating_System
setting	I-Operating_System
,	O
memory-sharing	O
objects	O
and	O
memory	O
synchronization	O
.	O
</s>
<s>
Some	O
of	O
these	O
expansions	O
were	O
given	O
specific	O
names	O
,	O
such	O
as	O
Graphics	O
Execution	O
Manager	O
(	O
GEM	O
)	O
or	O
kernel	B-Operating_System
mode-setting	I-Operating_System
(	O
KMS	O
)	O
,	O
and	O
the	O
terminology	O
prevails	O
when	O
the	O
functionality	O
they	O
provide	O
is	O
specifically	O
alluded	O
.	O
</s>
<s>
But	O
they	O
are	O
really	O
parts	O
of	O
the	O
whole	O
kernel	B-Operating_System
DRM	O
subsystem	O
.	O
</s>
<s>
The	O
trend	O
to	O
include	O
two	O
GPUs	B-Architecture
in	O
a	O
computera	O
discrete	B-Device
GPU	I-Device
and	O
an	O
integrated	O
oneled	O
to	O
new	O
problems	O
such	O
as	O
GPU	B-Device
switching	I-Device
that	O
also	O
needed	O
to	O
be	O
solved	O
at	O
the	O
DRM	O
layer	O
.	O
</s>
<s>
In	O
order	O
to	O
match	O
the	O
Nvidia	B-Application
Optimus	I-Application
technology	O
,	O
DRM	O
was	O
provided	O
with	O
GPU	B-Architecture
offloading	O
abilities	O
,	O
called	O
PRIME	O
.	O
</s>
<s>
The	O
Direct	O
Rendering	O
Manager	O
resides	O
in	O
kernel	B-Operating_System
space	I-Operating_System
,	O
so	O
user-space	B-Operating_System
programs	O
must	O
use	O
kernel	B-Operating_System
system	B-Operating_System
calls	I-Operating_System
to	O
request	O
its	O
services	O
.	O
</s>
<s>
However	O
,	O
DRM	O
does	O
n't	O
define	O
its	O
own	O
customized	O
system	B-Operating_System
calls	I-Operating_System
.	O
</s>
<s>
Instead	O
,	O
it	O
follows	O
the	O
Unix	B-Application
principle	O
of	O
"	O
everything	B-Application
is	I-Application
a	I-Application
file	I-Application
"	O
to	O
expose	O
the	O
GPUs	B-Architecture
through	O
the	O
filesystem	O
name	O
space	O
,	O
using	O
device	B-Application
files	I-Application
under	O
the	O
/dev	B-Application
hierarchy	O
.	O
</s>
<s>
Each	O
GPU	B-Architecture
detected	O
by	O
DRM	O
is	O
referred	O
to	O
as	O
a	O
DRM	O
device	O
,	O
and	O
a	O
device	B-Application
file	I-Application
/dev/dri/cardX	O
(	O
where	O
X	B-Operating_System
is	O
a	O
sequential	O
number	O
)	O
is	O
created	O
to	O
interface	O
with	O
it	O
.	O
</s>
<s>
User-space	B-Operating_System
programs	O
that	O
want	O
to	O
talk	O
to	O
the	O
GPU	B-Architecture
must	O
open	B-Language
this	O
file	O
and	O
use	O
ioctl	B-Operating_System
calls	O
to	O
communicate	O
with	O
DRM	O
.	O
</s>
<s>
Different	O
ioctls	B-Operating_System
correspond	O
to	O
different	O
functions	O
of	O
the	O
DRM	O
API	B-Application
.	O
</s>
<s>
A	O
library	B-Library
called	O
libdrm	B-Application
was	O
created	O
to	O
facilitate	O
the	O
interface	O
of	O
user-space	B-Operating_System
programs	O
with	O
the	O
DRM	O
subsystem	O
.	O
</s>
<s>
This	O
library	B-Library
is	O
merely	O
a	O
wrapper	B-Library
that	O
provides	O
a	O
function	O
written	O
in	O
C	B-Language
for	O
every	O
ioctl	B-Operating_System
of	O
the	O
DRM	O
API	B-Application
,	O
as	O
well	O
as	O
constants	O
,	O
structures	O
and	O
other	O
helper	O
elements	O
.	O
</s>
<s>
The	O
use	O
of	O
libdrm	B-Application
not	O
only	O
avoids	O
exposing	O
the	O
kernel	B-Operating_System
interface	O
directly	O
to	O
applications	O
,	O
but	O
presents	O
the	O
usual	O
advantages	O
of	O
reusing	O
and	O
sharing	O
code	O
between	O
programs	O
.	O
</s>
<s>
DRM	O
core	O
provides	O
the	O
basic	O
framework	O
where	O
different	O
DRM	O
drivers	O
can	O
register	O
and	O
also	O
provides	O
to	O
user	B-Operating_System
space	I-Operating_System
a	O
minimal	O
set	O
of	O
ioctls	B-Operating_System
with	O
common	O
,	O
hardware-independent	O
functionality	O
.	O
</s>
<s>
A	O
DRM	O
driver	O
,	O
on	O
the	O
other	O
hand	O
,	O
implements	O
the	O
hardware-dependent	O
part	O
of	O
the	O
API	B-Application
,	O
specific	O
to	O
the	O
type	O
of	O
GPU	B-Architecture
it	O
supports	O
;	O
it	O
should	O
provide	O
the	O
implementation	O
of	O
the	O
remaining	O
ioctls	B-Operating_System
not	O
covered	O
by	O
DRM	O
core	O
,	O
but	O
it	O
may	O
also	O
extend	O
the	O
API	B-Application
,	O
offering	O
additional	O
ioctls	B-Operating_System
with	O
extra	O
functionality	O
only	O
available	O
on	O
such	O
hardware	O
.	O
</s>
<s>
When	O
a	O
specific	O
DRM	O
driver	O
provides	O
an	O
enhanced	O
API	B-Application
,	O
user-space	B-Operating_System
libdrm	B-Application
is	O
also	O
extended	O
by	O
an	O
extra	O
library	B-Library
libdrm-driver	O
that	O
can	O
be	O
used	O
by	O
user	B-Operating_System
space	I-Operating_System
to	O
interface	O
with	O
the	O
additional	O
ioctls	B-Operating_System
.	O
</s>
<s>
The	O
DRM	O
core	O
exports	O
several	O
interfaces	O
to	O
user-space	B-Operating_System
applications	O
,	O
generally	O
intended	O
to	O
be	O
used	O
through	O
corresponding	O
libdrm	B-Application
wrapper	B-Library
functions	O
.	O
</s>
<s>
In	O
addition	O
,	O
drivers	O
export	O
device-specific	O
interfaces	O
for	O
use	O
by	O
user-space	B-Operating_System
drivers	O
and	O
device-aware	O
applications	O
through	O
ioctls	B-Operating_System
and	O
sysfs	B-Application
files	O
.	O
</s>
<s>
External	O
interfaces	O
include	O
:	O
memory	O
mapping	O
,	O
context	O
management	O
,	O
DMA	B-General_Concept
operations	O
,	O
AGP	B-Architecture
management	O
,	O
vblank	O
control	O
,	O
fence	O
management	O
,	O
memory	B-General_Concept
management	I-General_Concept
,	O
and	O
output	O
management	O
.	O
</s>
<s>
There	O
are	O
several	O
operations	O
(	O
ioctls	B-Operating_System
)	O
in	O
the	O
DRM	O
API	B-Application
that	O
either	O
for	O
security	O
purposes	O
or	O
for	O
concurrency	O
issues	O
must	O
be	O
restricted	O
to	O
be	O
used	O
by	O
a	O
single	O
user-space	B-Operating_System
process	O
per	O
device	O
.	O
</s>
<s>
To	O
implement	O
this	O
restriction	O
,	O
DRM	O
limits	O
such	O
ioctls	B-Operating_System
to	O
be	O
only	O
invoked	O
by	O
the	O
process	O
considered	O
the	O
"	O
master	O
"	O
of	O
a	O
DRM	O
device	O
,	O
usually	O
called	O
DRM-Master	O
.	O
</s>
<s>
Only	O
one	O
of	O
all	O
processes	B-Operating_System
that	O
have	O
the	O
device	B-Application
node	I-Application
/dev/dri/cardX	O
opened	O
will	O
have	O
its	O
file	B-Application
handle	I-Application
marked	O
as	O
master	O
,	O
specifically	O
the	O
first	O
calling	O
the	O
ioctl	B-Operating_System
.	O
</s>
<s>
Any	O
attempt	O
to	O
use	O
one	O
of	O
these	O
restricted	O
ioctls	B-Operating_System
without	O
being	O
the	O
DRM-Master	O
will	O
return	O
an	O
error	O
.	O
</s>
<s>
A	O
process	O
can	O
also	O
give	O
up	O
its	O
master	O
roleand	O
let	O
another	O
process	O
acquire	O
itby	O
calling	O
the	O
ioctl	B-Operating_System
.	O
</s>
<s>
The	O
X	B-Operating_System
Serveror	O
any	O
other	O
display	O
serveris	O
commonly	O
the	O
process	O
that	O
acquires	O
the	O
DRM-Master	O
status	O
in	O
every	O
DRM	O
device	O
it	O
manages	O
,	O
usually	O
when	O
it	O
opens	O
the	O
corresponding	O
device	B-Application
node	I-Application
during	O
its	O
startup	O
,	O
and	O
keeps	O
these	O
privileges	O
for	O
the	O
entire	O
graphical	O
session	O
until	O
it	O
finishes	O
or	O
dies	O
.	O
</s>
<s>
For	O
the	O
remaining	O
user-space	B-Operating_System
processes	B-Operating_System
there	O
is	O
another	O
way	O
to	O
gain	O
the	O
privilege	O
to	O
invoke	O
some	O
restricted	O
operations	O
on	O
the	O
DRM	O
device	O
called	O
DRM-Auth	O
.	O
</s>
<s>
The	O
client	O
gets	O
a	O
unique	O
tokena	O
32-bit	O
integerfrom	O
the	O
DRM	O
device	O
using	O
the	O
ioctl	B-Operating_System
and	O
passes	O
it	O
to	O
the	O
DRM-Master	O
process	O
by	O
whatever	O
means	O
(	O
normally	O
some	O
sort	O
of	O
IPC	B-Operating_System
;	O
for	O
example	O
,	O
in	O
DRI2	B-Application
there	O
is	O
a	O
request	O
that	O
any	O
X	B-Operating_System
client	O
can	O
send	O
to	O
the	O
X	B-Operating_System
Server	I-Operating_System
.	O
)	O
</s>
<s>
The	O
DRM-Master	O
process	O
,	O
in	O
turn	O
,	O
sends	O
back	O
the	O
token	O
to	O
the	O
DRM	O
device	O
by	O
invoking	O
the	O
ioctl	B-Operating_System
.	O
</s>
<s>
The	O
device	O
grants	O
special	O
rights	O
to	O
the	O
process	O
file	B-Application
handle	I-Application
whose	O
auth	O
token	O
matches	O
the	O
received	O
token	O
from	O
the	O
DRM-Master	O
.	O
</s>
<s>
Due	O
to	O
the	O
increasing	O
size	O
of	O
video	O
memory	O
and	O
the	O
growing	O
complexity	O
of	O
graphics	O
APIs	B-Application
such	O
as	O
OpenGL	B-Application
,	O
the	O
strategy	O
of	O
reinitializing	O
the	O
graphics	B-Device
card	I-Device
state	O
at	O
each	O
context	B-Operating_System
switch	I-Operating_System
was	O
too	O
expensive	O
,	O
performance-wise	O
.	O
</s>
<s>
Also	O
,	O
modern	O
Linux	B-Operating_System
desktops	O
needed	O
an	O
optimal	O
way	O
to	O
share	O
off-screen	B-Algorithm
buffers	I-Algorithm
with	O
the	O
compositing	B-Operating_System
manager	I-Operating_System
.	O
</s>
<s>
These	O
requirements	O
led	O
to	O
the	O
development	O
of	O
new	O
methods	O
to	O
manage	O
graphics	O
buffers	B-General_Concept
inside	O
the	O
kernel	B-Operating_System
.	O
</s>
<s>
GEM	O
provides	O
an	O
API	B-Application
with	O
explicit	O
memory	B-General_Concept
management	I-General_Concept
primitives	O
.	O
</s>
<s>
Through	O
GEM	O
,	O
a	O
user-space	B-Operating_System
program	O
can	O
create	O
,	O
handle	O
and	O
destroy	O
memory	O
objects	O
living	O
in	O
the	O
GPU	B-Architecture
video	O
memory	O
.	O
</s>
<s>
These	O
objects	O
,	O
called	O
"	O
GEM	O
objects	O
"	O
,	O
are	O
persistent	O
from	O
the	O
user-space	B-Operating_System
program	O
's	O
perspective	O
and	O
do	O
n't	O
need	O
to	O
be	O
reloaded	O
every	O
time	O
the	O
program	O
regains	O
control	O
of	O
the	O
GPU	B-Architecture
.	O
</s>
<s>
When	O
a	O
user-space	B-Operating_System
program	O
needs	O
a	O
chunk	O
of	O
video	O
memory	O
(	O
to	O
store	O
a	O
framebuffer	B-Algorithm
,	O
texture	O
or	O
any	O
other	O
data	O
required	O
by	O
the	O
GPU	B-Architecture
)	O
,	O
it	O
requests	O
the	O
allocation	O
to	O
the	O
DRM	O
driver	O
using	O
the	O
GEM	O
API	B-Application
.	O
</s>
<s>
The	O
DRM	O
driver	O
keeps	O
track	O
of	O
the	O
used	O
video	O
memory	O
and	O
is	O
able	O
to	O
comply	O
with	O
the	O
request	O
if	O
there	O
is	O
free	O
memory	O
available	O
,	O
returning	O
a	O
"	O
handle	O
"	O
to	O
user	B-Operating_System
space	I-Operating_System
to	O
further	O
refer	O
the	O
allocated	O
memory	O
in	O
coming	O
operations	O
.	O
</s>
<s>
GEM	O
API	B-Application
also	O
provides	O
operations	O
to	O
populate	O
the	O
buffer	B-General_Concept
and	O
to	O
release	O
it	O
when	O
it	O
is	O
not	O
needed	O
anymore	O
.	O
</s>
<s>
Memory	O
from	O
unreleased	O
GEM	O
handles	O
gets	O
recovered	O
when	O
the	O
user-space	B-Operating_System
process	O
closes	O
the	O
DRM	O
device	B-Application
file	I-Application
descriptorintentionally	O
or	O
because	O
it	O
terminates	O
.	O
</s>
<s>
GEM	O
also	O
allows	O
two	O
or	O
more	O
user-space	B-Operating_System
processes	B-Operating_System
using	O
the	O
same	O
DRM	O
device	O
(	O
hence	O
the	O
same	O
DRM	O
driver	O
)	O
to	O
share	O
a	O
GEM	O
object	O
.	O
</s>
<s>
GEM	O
handles	O
are	O
local	O
32-bit	O
integers	O
unique	O
to	O
a	O
process	O
but	O
repeatable	O
in	O
other	O
processes	B-Operating_System
,	O
therefore	O
not	O
suitable	O
for	O
sharing	O
.	O
</s>
<s>
The	O
process	O
can	O
then	O
pass	O
this	O
GEM	O
name	O
(	O
32-bit	O
integer	O
)	O
to	O
another	O
process	O
using	O
any	O
IPC	B-Operating_System
mechanism	O
available	O
.	O
</s>
<s>
Unfortunately	O
,	O
the	O
use	O
of	O
GEM	O
names	O
to	O
share	O
buffers	B-General_Concept
is	O
not	O
secure	O
.	O
</s>
<s>
A	O
malicious	O
third-party	O
process	O
accessing	O
the	O
same	O
DRM	O
device	O
could	O
try	O
to	O
guess	O
the	O
GEM	O
name	O
of	O
a	O
buffer	B-General_Concept
shared	O
by	O
other	O
two	O
processes	B-Operating_System
,	O
simply	O
by	O
probing	O
32-bit	O
integers	O
.	O
</s>
<s>
Once	O
a	O
GEM	O
name	O
is	O
found	O
,	O
its	O
contents	O
can	O
be	O
accessed	O
and	O
modified	O
,	O
violating	O
the	O
confidentiality	O
and	O
integrity	O
of	O
the	O
information	O
of	O
the	O
buffer	B-General_Concept
.	O
</s>
<s>
This	O
drawback	O
was	O
overcome	O
later	O
by	O
the	O
introduction	O
of	O
DMA-BUF	O
support	O
into	O
DRM	O
,	O
as	O
DMA-BUF	O
represents	O
buffers	B-General_Concept
in	O
userspace	B-Operating_System
as	O
file	B-Application
descriptors	I-Application
,	O
which	O
may	O
be	O
shared	O
securely	O
.	O
</s>
<s>
Another	O
important	O
task	O
for	O
any	O
video-memory	O
management	O
system	O
besides	O
managing	O
the	O
video-memory	O
space	O
is	O
handling	O
the	O
memory	O
synchronization	O
between	O
the	O
GPU	B-Architecture
and	O
the	O
CPU	O
.	O
</s>
<s>
Current	O
memory	B-General_Concept
architectures	I-General_Concept
are	O
very	O
complex	O
and	O
usually	O
involve	O
various	O
levels	O
of	O
caches	B-General_Concept
for	O
the	O
system	O
memory	O
and	O
sometimes	O
for	O
the	O
video	O
memory	O
too	O
.	O
</s>
<s>
Therefore	O
,	O
video-memory	O
managers	O
should	O
also	O
handle	O
the	O
cache	B-General_Concept
coherence	I-General_Concept
to	O
ensure	O
the	O
data	O
shared	O
between	O
CPU	O
and	O
GPU	B-Architecture
is	O
consistent	O
.	O
</s>
<s>
This	O
means	O
that	O
often	O
video-memory	O
management	O
internals	O
are	O
highly	O
dependent	O
on	O
hardware	O
details	O
of	O
the	O
GPU	B-Architecture
and	O
memory	B-General_Concept
architecture	I-General_Concept
,	O
and	O
thus	O
driver-specific	O
.	O
</s>
<s>
The	O
Intel	B-Device
GMA	I-Device
9xx	O
family	O
are	O
integrated	O
GPUs	B-Architecture
with	O
a	O
Uniform	O
Memory	B-General_Concept
Architecture	I-General_Concept
(	O
UMA	O
)	O
,	O
where	O
the	O
GPU	B-Architecture
and	O
CPU	O
share	O
the	O
physical	O
memory	O
,	O
and	O
there	O
is	O
not	O
a	O
dedicated	O
VRAM	O
.	O
</s>
<s>
GEM	O
defines	O
"	O
memory	O
domains	O
"	O
for	O
memory	O
synchronization	O
,	O
and	O
while	O
these	O
memory	O
domains	O
are	O
GPU-independent	O
,	O
they	O
are	O
specifically	O
designed	O
with	O
an	O
UMA	O
memory	B-General_Concept
architecture	I-General_Concept
in	O
mind	O
,	O
making	O
them	O
less	O
suitable	O
for	O
other	O
memory	B-General_Concept
architectures	I-General_Concept
like	O
those	O
with	O
a	O
separate	O
VRAM	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
other	O
DRM	O
drivers	O
have	O
decided	O
to	O
expose	O
to	O
user-space	B-Operating_System
programs	O
the	O
GEM	O
API	B-Application
,	O
but	O
internally	O
they	O
implemented	O
a	O
different	O
memory	O
manager	O
better	O
suited	O
for	O
their	O
particular	O
hardware	O
and	O
memory	B-General_Concept
architecture	I-General_Concept
.	O
</s>
<s>
The	O
GEM	O
API	B-Application
also	O
provides	O
ioctls	B-Operating_System
for	O
control	O
of	O
the	O
execution	O
flow	O
(	O
command	O
buffers	B-General_Concept
)	O
,	O
but	O
they	O
are	O
Intel-specific	O
,	O
to	O
be	O
used	O
with	O
Intel	O
i915	O
and	O
later	O
GPUs	B-Architecture
.	O
</s>
<s>
No	O
other	O
DRM	O
driver	O
has	O
attempted	O
to	O
implement	O
any	O
part	O
of	O
the	O
GEM	O
API	B-Application
beyond	O
the	O
memory-management	O
specific	O
ioctls	B-Operating_System
.	O
</s>
<s>
Translation	O
Table	O
Maps	O
(	O
TTM	O
)	O
is	O
the	O
name	O
of	O
the	O
generic	O
memory	O
manager	O
for	O
GPUs	B-Architecture
that	O
was	O
developed	O
before	O
GEM	O
.	O
</s>
<s>
It	O
was	O
specifically	O
designed	O
to	O
manage	O
the	O
different	O
types	O
of	O
memory	O
that	O
a	O
GPU	B-Architecture
might	O
access	O
,	O
including	O
dedicated	O
Video	O
RAM	O
(	O
commonly	O
installed	O
in	O
the	O
video	B-Device
card	I-Device
)	O
and	O
system	O
memory	O
accessible	O
through	O
an	O
I/O	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
unit	I-General_Concept
called	O
the	O
Graphics	B-General_Concept
Address	I-General_Concept
Remapping	I-General_Concept
Table	I-General_Concept
(	O
GART	O
)	O
.	O
</s>
<s>
TTM	O
should	O
also	O
handle	O
the	O
portions	O
of	O
the	O
video	O
RAM	O
that	O
are	O
not	O
directly	O
addressable	O
by	O
the	O
CPU	O
and	O
do	O
it	O
with	O
the	O
best	O
possible	O
performance	O
,	O
considering	O
that	O
user-space	B-Operating_System
graphics	O
applications	O
typically	O
work	O
with	O
large	O
amounts	O
of	O
video	O
data	O
.	O
</s>
<s>
Another	O
important	O
matter	O
was	O
to	O
maintain	O
the	O
consistency	O
between	O
the	O
different	O
memories	O
and	O
caches	B-General_Concept
involved	O
.	O
</s>
<s>
The	O
main	O
concept	O
of	O
TTM	O
are	O
the	O
"	O
buffer	B-General_Concept
objects	O
"	O
,	O
regions	O
of	O
video	O
memory	O
that	O
at	O
some	O
point	O
must	O
be	O
addressable	O
by	O
the	O
GPU	B-Architecture
.	O
</s>
<s>
When	O
a	O
user-space	B-Operating_System
graphics	O
application	O
wants	O
access	O
to	O
a	O
certain	O
buffer	B-General_Concept
object	O
(	O
usually	O
to	O
fill	O
it	O
with	O
content	O
)	O
,	O
TTM	O
may	O
require	O
relocating	O
it	O
to	O
a	O
type	O
of	O
memory	O
addressable	O
by	O
the	O
CPU	O
.	O
</s>
<s>
Further	O
relocationsor	O
GART	O
mapping	O
operationscould	O
happen	O
when	O
the	O
GPU	B-Architecture
needs	O
access	O
to	O
a	O
buffer	B-General_Concept
object	O
but	O
it	O
is	O
n't	O
in	O
the	O
GPU	B-Architecture
's	O
address	O
space	O
yet	O
.	O
</s>
<s>
Another	O
important	O
TTM	O
concept	O
is	O
fences	B-General_Concept
.	O
</s>
<s>
Fences	B-General_Concept
are	O
essentially	O
a	O
mechanism	O
to	O
manage	O
concurrency	O
between	O
the	O
CPU	O
and	O
the	O
GPU	B-Architecture
.	O
</s>
<s>
A	O
fence	O
tracks	O
when	O
a	O
buffer	B-General_Concept
object	O
is	O
no	O
longer	O
used	O
by	O
the	O
GPU	B-Architecture
,	O
generally	O
to	O
notify	O
any	O
user-space	B-Operating_System
process	O
with	O
access	O
to	O
it	O
.	O
</s>
<s>
The	O
fact	O
that	O
TTM	O
tried	O
to	O
manage	O
all	O
kind	O
of	O
memory	B-General_Concept
architectures	I-General_Concept
,	O
including	O
those	O
with	O
and	O
without	O
a	O
dedicated	O
VRAM	O
,	O
in	O
a	O
suitable	O
way	O
,	O
and	O
to	O
provide	O
every	O
conceivable	O
feature	O
in	O
a	O
memory	O
manager	O
for	O
use	O
with	O
any	O
type	O
of	O
hardware	O
,	O
led	O
to	O
an	O
overly	O
complex	O
solution	O
with	O
an	O
API	B-Application
far	O
larger	O
than	O
needed	O
.	O
</s>
<s>
Some	O
DRM	O
developers	O
thought	O
that	O
it	O
would	O
n't	O
fit	O
well	O
with	O
any	O
specific	O
driver	O
,	O
especially	O
the	O
API	B-Application
.	O
</s>
<s>
When	O
GEM	O
emerged	O
as	O
a	O
simpler	O
memory	O
manager	O
,	O
its	O
API	B-Application
was	O
preferred	O
over	O
the	O
TTM	O
one	O
.	O
</s>
<s>
But	O
some	O
driver	O
developers	O
considered	O
that	O
the	O
approach	O
taken	O
by	O
TTM	O
was	O
more	O
suitable	O
for	O
discrete	O
video	B-Device
cards	I-Device
with	O
dedicated	O
video	O
memory	O
and	O
IOMMUs	B-General_Concept
,	O
so	O
they	O
decided	O
to	O
use	O
TTM	O
internally	O
,	O
while	O
exposing	O
their	O
buffer	B-General_Concept
objects	O
as	O
GEM	O
objects	O
and	O
thus	O
supporting	O
the	O
GEM	O
API	B-Application
.	O
</s>
<s>
Examples	O
of	O
current	O
drivers	O
using	O
TTM	O
as	O
an	O
internal	O
memory	O
manager	O
but	O
providing	O
a	O
GEM	O
API	B-Application
are	O
the	O
radeon	B-Device
driver	O
for	O
AMD	O
video	B-Device
cards	I-Device
and	O
the	O
nouveau	B-Application
driver	I-Application
for	O
NVIDIA	O
video	B-Device
cards	I-Device
.	O
</s>
<s>
The	O
DMA	B-General_Concept
Buffer	B-General_Concept
Sharing	O
API	B-Application
(	O
often	O
abbreviated	O
as	O
DMA-BUF	O
)	O
is	O
a	O
Linux	B-Operating_System
kernel	I-Operating_System
internal	O
API	B-Application
designed	O
to	O
provide	O
a	O
generic	O
mechanism	O
to	O
share	O
DMA	B-General_Concept
buffers	B-General_Concept
across	O
multiple	O
devices	O
,	O
possibly	O
managed	O
by	O
different	O
types	O
of	O
device	B-Application
drivers	I-Application
.	O
</s>
<s>
For	O
example	O
,	O
a	O
Video4Linux	B-Application
device	O
and	O
a	O
graphics	B-Device
adapter	I-Device
device	O
could	O
share	O
buffers	B-General_Concept
through	O
DMA-BUF	O
to	O
achieve	O
zero-copy	O
of	O
the	O
data	O
of	O
a	O
video	O
stream	O
produced	O
by	O
the	O
first	O
and	O
consumed	O
by	O
the	O
latter	O
.	O
</s>
<s>
Any	O
Linux	B-Application
device	I-Application
driver	I-Application
can	O
implement	O
this	O
API	B-Application
as	O
exporter	O
,	O
as	O
user	O
(	O
consumer	O
)	O
or	O
both	O
.	O
</s>
<s>
This	O
feature	O
was	O
exploited	O
for	O
the	O
first	O
time	O
in	O
DRM	O
to	O
implement	O
PRIME	O
,	O
a	O
solution	O
for	O
GPU	B-Architecture
offloading	O
that	O
uses	O
DMA-BUF	O
to	O
share	O
the	O
resulting	O
framebuffers	B-Algorithm
between	O
the	O
DRM	O
drivers	O
of	O
the	O
discrete	O
and	O
the	O
integrated	O
GPU	B-Architecture
.	O
</s>
<s>
An	O
important	O
feature	O
of	O
DMA-BUF	O
is	O
that	O
a	O
shared	O
buffer	B-General_Concept
is	O
presented	O
to	O
user	B-Operating_System
space	I-Operating_System
as	O
a	O
file	B-Application
descriptor	I-Application
.	O
</s>
<s>
For	O
the	O
development	O
of	O
PRIME	O
two	O
new	O
ioctls	B-Operating_System
were	O
added	O
to	O
the	O
DRM	O
API	B-Application
,	O
one	O
to	O
convert	O
a	O
local	O
GEM	O
handle	O
to	O
a	O
DMA-BUF	O
file	B-Application
descriptor	I-Application
and	O
another	O
for	O
the	O
exact	O
opposite	O
operation	O
.	O
</s>
<s>
These	O
two	O
new	O
ioctls	B-Operating_System
were	O
later	O
reused	O
as	O
a	O
way	O
to	O
fix	O
the	O
inherent	O
unsafety	O
of	O
GEM	O
buffer	B-General_Concept
sharing	O
.	O
</s>
<s>
Unlike	O
GEM	O
names	O
,	O
file	B-Application
descriptors	I-Application
can	O
not	O
be	O
guessed	O
(	O
they	O
are	O
not	O
a	O
global	O
namespace	O
)	O
,	O
and	O
Unix	B-Application
operating	I-Application
systems	I-Application
provide	O
a	O
safe	O
way	O
to	O
pass	O
them	O
through	O
a	O
Unix	B-Protocol
domain	I-Protocol
socket	I-Protocol
using	O
the	O
SCM_RIGHTS	O
semantics	O
.	O
</s>
<s>
A	O
process	O
that	O
wants	O
to	O
share	O
a	O
GEM	O
object	O
with	O
another	O
process	O
can	O
convert	O
its	O
local	O
GEM	O
handle	O
to	O
a	O
DMA-BUF	O
file	B-Application
descriptor	I-Application
and	O
pass	O
it	O
to	O
the	O
recipient	O
,	O
which	O
in	O
turn	O
can	O
get	O
its	O
own	O
GEM	O
handle	O
from	O
the	O
received	O
file	B-Application
descriptor	I-Application
.	O
</s>
<s>
This	O
method	O
is	O
used	O
by	O
DRI3	B-Application
to	O
share	O
buffers	B-General_Concept
between	O
the	O
client	O
and	O
the	O
X	B-Operating_System
Server	I-Operating_System
and	O
also	O
by	O
Wayland	B-Language
.	O
</s>
<s>
In	O
order	O
to	O
work	O
properly	O
,	O
a	O
video	B-Device
card	I-Device
or	O
graphics	B-Device
adapter	I-Device
must	O
set	O
a	O
modea	O
combination	O
of	O
screen	B-General_Concept
resolution	I-General_Concept
,	O
color	O
depth	O
and	O
refresh	O
ratethat	O
is	O
within	O
the	O
range	O
of	O
values	O
supported	O
by	O
itself	O
and	O
the	O
attached	O
display	B-Device
screen	I-Device
.	O
</s>
<s>
This	O
operation	O
is	O
called	O
mode-setting	B-Operating_System
,	O
and	O
it	O
usually	O
requires	O
raw	O
access	O
to	O
the	O
graphics	O
hardwarei.e.	O
</s>
<s>
the	O
ability	O
to	O
write	O
to	O
certain	O
registers	O
of	O
the	O
video	B-Device
card	I-Device
display	O
controller	O
.	O
</s>
<s>
A	O
mode-setting	B-Operating_System
operation	O
must	O
be	O
performed	O
before	O
starting	O
to	O
use	O
the	O
framebuffer	B-Algorithm
,	O
and	O
also	O
when	O
the	O
mode	O
is	O
required	O
to	O
change	O
by	O
an	O
application	O
or	O
the	O
user	O
.	O
</s>
<s>
In	O
early	O
days	O
,	O
the	O
user	B-Operating_System
space	I-Operating_System
programs	O
that	O
wanted	O
to	O
use	O
the	O
graphical	O
framebuffer	B-Algorithm
were	O
also	O
responsible	O
for	O
providing	O
the	O
mode-setting	B-Operating_System
operations	O
,	O
and	O
therefore	O
they	O
needed	O
to	O
run	O
with	O
privileged	O
access	O
to	O
the	O
video	O
hardware	O
.	O
</s>
<s>
In	O
Unix-type	O
operating	O
systems	O
,	O
the	O
X	B-Operating_System
Server	I-Operating_System
was	O
the	O
most	O
prominent	O
example	O
,	O
and	O
its	O
mode-setting	B-Operating_System
implementation	O
lived	O
in	O
the	O
DDX	O
driver	O
for	O
each	O
specific	O
type	O
of	O
video	B-Device
card	I-Device
.	O
</s>
<s>
This	O
approach	O
,	O
later	O
referred	O
as	O
User	B-Operating_System
space	I-Operating_System
Mode-Setting	B-Operating_System
or	O
UMS	O
,	O
poses	O
several	O
issues	O
.	O
</s>
<s>
It	O
not	O
only	O
breaks	O
the	O
isolation	O
that	O
operating	O
systems	O
should	O
provide	O
between	O
programs	O
and	O
hardware	O
,	O
raising	O
both	O
stability	O
and	O
security	O
concerns	O
,	O
but	O
also	O
could	O
leave	O
the	O
graphics	O
hardware	O
in	O
an	O
inconsistent	O
state	O
if	O
two	O
or	O
more	O
user	B-Operating_System
space	I-Operating_System
programs	O
try	O
to	O
do	O
the	O
mode-setting	B-Operating_System
at	O
the	O
same	O
time	O
.	O
</s>
<s>
To	O
avoid	O
these	O
conflicts	O
,	O
the	O
X	B-Operating_System
Server	I-Operating_System
became	O
in	O
practice	O
the	O
only	O
user	B-Operating_System
space	I-Operating_System
program	O
that	O
performed	O
mode-setting	B-Operating_System
operations	O
;	O
the	O
remainder	O
user	B-Operating_System
space	I-Operating_System
programs	O
relied	O
on	O
the	O
X	B-Operating_System
Server	I-Operating_System
to	O
set	O
the	O
appropriate	O
mode	O
and	O
to	O
handle	O
any	O
other	O
operation	O
involving	O
mode-setting	B-Operating_System
.	O
</s>
<s>
Initially	O
the	O
mode-setting	B-Operating_System
was	O
performed	O
exclusively	O
during	O
the	O
X	B-Operating_System
Server	I-Operating_System
startup	O
process	O
,	O
but	O
later	O
the	O
X	B-Operating_System
Server	I-Operating_System
gained	O
the	O
ability	O
to	O
do	O
it	O
while	O
running	O
.	O
</s>
<s>
The	O
XFree86-VidModeExtension	O
extension	O
was	O
introduced	O
in	O
XFree86	B-Device
3.1.2	O
to	O
let	O
any	O
X	B-Operating_System
client	O
request	O
modeline	B-Device
(	O
resolution	O
)	O
changes	O
to	O
the	O
X	B-Operating_System
Server	I-Operating_System
.	O
</s>
<s>
However	O
,	O
this	O
was	O
not	O
the	O
only	O
code	O
doing	O
mode-setting	B-Operating_System
in	O
a	O
Linux	B-Operating_System
system	O
.	O
</s>
<s>
During	O
the	O
system	O
booting	O
process	O
,	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
must	O
set	O
a	O
minimal	O
text	B-Application
mode	I-Application
for	O
the	O
virtual	B-Application
console	I-Application
(	O
based	O
on	O
the	O
standard	O
modes	O
defined	O
by	O
VESA	B-Device
BIOS	I-Device
extensions	I-Device
)	O
.	O
</s>
<s>
Also	O
the	O
Linux	B-Language
kernel	I-Language
framebuffer	I-Language
driver	I-Language
contained	O
mode-setting	B-Operating_System
code	O
to	O
configure	O
framebuffer	B-Algorithm
devices	O
.	O
</s>
<s>
To	O
avoid	O
mode-setting	B-Operating_System
conflicts	O
,	O
the	O
XFree86	B-Device
Serverand	O
later	O
the	O
X.Org	O
Serverhandled	O
the	O
case	O
when	O
the	O
user	O
switched	O
from	O
the	O
graphical	O
environment	O
to	O
a	O
text	O
virtual	B-Application
console	I-Application
by	O
saving	O
its	O
mode-setting	B-Operating_System
state	O
,	O
and	O
restoring	O
it	O
when	O
the	O
user	O
switched	O
back	O
to	O
X	B-Operating_System
.	O
</s>
<s>
The	O
user	B-Operating_System
space	I-Operating_System
mode	B-Operating_System
setting	I-Operating_System
approach	O
also	O
caused	O
other	O
issues	O
:	O
</s>
<s>
The	O
suspend/resume	O
process	O
has	O
to	O
rely	O
on	O
user	B-Operating_System
space	I-Operating_System
tools	O
to	O
restore	O
the	O
previous	O
mode	O
.	O
</s>
<s>
It	O
was	O
also	O
impossible	O
for	O
the	O
kernel	B-Operating_System
to	O
show	O
error	O
or	O
debug	O
messages	O
when	O
the	O
screen	O
was	O
in	O
a	O
graphics	O
modefor	O
example	O
when	O
X	B-Operating_System
was	O
runningsince	O
the	O
only	O
modes	O
the	O
kernel	B-Operating_System
knew	O
about	O
were	O
the	O
VESA	B-Device
BIOS	I-Device
standard	O
text	B-Application
modes	I-Application
.	O
</s>
<s>
A	O
more	O
pressing	O
issue	O
was	O
the	O
proliferation	O
of	O
graphical	O
applications	O
bypassing	O
the	O
X	B-Operating_System
Server	I-Operating_System
and	O
the	O
emergence	O
of	O
other	O
graphics	O
stack	O
alternatives	O
to	O
X	B-Operating_System
,	O
extending	O
the	O
duplication	O
of	O
mode-setting	B-Operating_System
code	O
across	O
the	O
system	O
even	O
further	O
.	O
</s>
<s>
To	O
address	O
these	O
problems	O
,	O
the	O
mode-setting	B-Operating_System
code	O
was	O
moved	O
to	O
a	O
single	O
place	O
inside	O
the	O
kernel	B-Operating_System
,	O
specifically	O
to	O
the	O
existing	O
DRM	O
module	B-Application
.	O
</s>
<s>
Then	O
,	O
every	O
processincluding	O
the	O
X	B-Operating_System
Servershould	O
be	O
able	O
to	O
command	O
the	O
kernel	B-Operating_System
to	O
perform	O
mode-setting	B-Operating_System
operations	O
,	O
and	O
the	O
kernel	B-Operating_System
would	O
ensure	O
that	O
concurrent	O
operations	O
do	O
n't	O
result	O
in	O
an	O
inconsistent	O
state	O
.	O
</s>
<s>
The	O
new	O
kernel	B-Operating_System
API	B-Application
and	O
code	O
added	O
to	O
the	O
DRM	O
module	B-Application
to	O
perform	O
these	O
mode-setting	B-Operating_System
operations	O
was	O
called	O
Kernel	B-Operating_System
Mode-Setting	I-Operating_System
(	O
KMS	O
)	O
.	O
</s>
<s>
Kernel	B-Operating_System
Mode-Setting	I-Operating_System
provides	O
several	O
benefits	O
.	O
</s>
<s>
The	O
most	O
immediate	O
is	O
of	O
course	O
the	O
removal	O
of	O
duplicate	O
mode-setting	B-Operating_System
code	O
,	O
from	O
both	O
the	O
kernel	B-Operating_System
(	O
Linux	B-Application
console	I-Application
,	O
fbdev	B-Language
)	O
and	O
user	B-Operating_System
space	I-Operating_System
(	O
X	B-Operating_System
Server	I-Operating_System
DDX	O
drivers	O
)	O
.	O
</s>
<s>
KMS	O
also	O
makes	O
it	O
easier	O
to	O
write	O
alternative	O
graphics	O
systems	O
,	O
which	O
now	O
do	O
n't	O
need	O
to	O
implement	O
their	O
own	O
mode-setting	B-Operating_System
code	O
.	O
</s>
<s>
By	O
providing	O
centralized	O
mode	O
management	O
,	O
KMS	O
solves	O
the	O
flickering	O
issues	O
while	O
changing	O
between	O
console	O
and	O
X	B-Operating_System
,	O
and	O
also	O
between	O
different	O
instances	O
of	O
X	B-Operating_System
(	O
fast	O
user	O
switching	O
)	O
.	O
</s>
<s>
Since	O
it	O
is	O
available	O
in	O
the	O
kernel	B-Operating_System
,	O
it	O
can	O
also	O
be	O
used	O
at	O
the	O
beginning	O
of	O
the	O
boot	O
process	O
,	O
saving	O
flickering	O
due	O
to	O
mode	O
changes	O
in	O
these	O
early	O
stages	O
.	O
</s>
<s>
The	O
fact	O
that	O
KMS	O
is	O
part	O
of	O
the	O
kernel	B-Operating_System
allows	O
it	O
to	O
use	O
resources	O
only	O
available	O
at	O
kernel	B-Operating_System
space	I-Operating_System
such	O
as	O
interrupts	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
mode	O
recovery	O
after	O
a	O
suspend/resume	O
process	O
simplifies	O
a	O
lot	O
by	O
being	O
managed	O
by	O
the	O
kernel	B-Operating_System
itself	O
,	O
and	O
incidentally	O
improves	O
security	O
(	O
no	O
more	O
user	B-Operating_System
space	I-Operating_System
tools	O
requiring	O
root	O
permissions	O
)	O
.	O
</s>
<s>
The	O
kernel	B-Operating_System
also	O
allows	O
the	O
hotplug	B-Device
of	O
new	O
display	O
devices	O
easily	O
,	O
solving	O
a	O
longstanding	O
problem	O
.	O
</s>
<s>
Mode-setting	B-Operating_System
is	O
also	O
closely	O
related	O
to	O
memory	O
managementsince	O
framebuffers	B-Algorithm
are	O
basically	O
memory	O
buffersso	O
a	O
tight	O
integration	O
with	O
the	O
graphics	O
memory	O
manager	O
is	O
highly	O
recommended	O
.	O
</s>
<s>
That	O
's	O
the	O
main	O
reason	O
why	O
the	O
kernel	B-Operating_System
mode-setting	I-Operating_System
code	O
was	O
incorporated	O
into	O
DRM	O
and	O
not	O
as	O
a	O
separate	O
subsystem	O
.	O
</s>
<s>
To	O
avoid	O
breaking	O
backwards	B-General_Concept
compatibility	I-General_Concept
of	O
the	O
DRM	O
API	B-Application
,	O
Kernel	B-Operating_System
Mode-Setting	I-Operating_System
is	O
provided	O
as	O
an	O
additional	O
driver	O
feature	O
of	O
certain	O
DRM	O
drivers	O
.	O
</s>
<s>
Any	O
DRM	O
driver	O
can	O
choose	O
to	O
provide	O
the	O
flag	O
when	O
it	O
registers	O
with	O
the	O
DRM	O
core	O
to	O
indicate	O
that	O
supports	O
the	O
KMS	O
API	B-Application
.	O
</s>
<s>
Those	O
drivers	O
that	O
implement	O
Kernel	B-Operating_System
Mode-Setting	I-Operating_System
are	O
often	O
called	O
KMS	O
drivers	O
as	O
a	O
way	O
to	O
differentiate	O
them	O
from	O
the	O
legacywithout	O
KMSDRM	O
drivers	O
.	O
</s>
<s>
KMS	O
has	O
been	O
adopted	O
to	O
such	O
an	O
extent	O
that	O
certain	O
drivers	O
which	O
lack	O
3D	B-Architecture
acceleration	I-Architecture
(	O
or	O
for	O
which	O
the	O
hardware	O
vendor	O
does	O
n't	O
want	O
to	O
expose	O
or	O
implement	O
it	O
)	O
nevertheless	O
implement	O
the	O
KMS	O
API	B-Application
without	O
the	O
rest	O
of	O
the	O
DRM	O
API	B-Application
,	O
allowing	O
display	O
servers	O
(	O
like	O
Wayland	B-Language
)	O
to	O
run	O
with	O
ease	O
.	O
</s>
<s>
CRTCs	O
:	O
each	O
CRTC	O
(	O
from	O
CRT	B-Device
Controller	O
)	O
represents	O
a	O
scanout	O
engine	O
of	O
the	O
display	O
controller	O
,	O
pointing	O
to	O
a	O
scanout	O
buffer	B-General_Concept
(	O
framebuffer	B-Algorithm
)	O
.	O
</s>
<s>
The	O
purpose	O
of	O
a	O
CRTC	O
is	O
to	O
read	O
the	O
pixel	O
data	O
currently	O
in	O
the	O
scanout	O
buffer	B-General_Concept
and	O
generate	O
from	O
it	O
the	O
video	B-Application
mode	I-Application
timing	I-Application
signal	I-Application
with	O
the	O
help	O
of	O
a	O
PLL	O
circuit	O
.	O
</s>
<s>
The	O
number	O
of	O
CRTCs	O
available	O
determines	O
how	O
many	O
independent	O
output	O
devices	O
the	O
hardware	O
can	O
handle	O
at	O
the	O
same	O
time	O
,	O
so	O
in	O
order	O
to	O
use	O
multi-head	B-General_Concept
configurations	O
at	O
least	O
one	O
CRTC	O
per	O
display	O
device	O
is	O
required	O
.	O
</s>
<s>
Twoor	O
moreCRTCs	O
can	O
also	O
work	O
in	O
clone	O
mode	O
if	O
they	O
scan	O
out	O
from	O
the	O
same	O
framebuffer	B-Algorithm
to	O
send	O
the	O
same	O
image	O
to	O
several	O
output	O
devices	O
.	O
</s>
<s>
Connectors	O
:	O
a	O
connector	O
represents	O
where	O
the	O
display	O
controller	O
sends	O
the	O
video	B-Application
signal	I-Application
from	O
a	O
scanout	O
operation	O
to	O
be	O
displayed	O
.	O
</s>
<s>
Usually	O
,	O
the	O
KMS	O
concept	O
of	O
a	O
connector	O
corresponds	O
to	O
a	O
physical	O
connector	O
(	O
VGA	B-Protocol
,	O
DVI	B-Protocol
,	O
FPD-Link	B-Protocol
,	O
HDMI	B-Protocol
,	O
DisplayPort	B-Protocol
,	O
S-Video	O
,	O
...	O
)	O
in	O
the	O
hardware	O
where	O
an	O
output	O
device	O
(	O
monitor	B-Device
,	O
laptop	B-Device
panel	O
,	O
...	O
)	O
is	O
permanently	O
or	O
can	O
temporarily	O
be	O
attached	O
.	O
</s>
<s>
Information	O
related	O
to	O
the	O
current	O
physically	O
attached	O
output	O
devicesuch	O
as	O
connection	O
status	O
,	O
EDID	B-General_Concept
data	O
,	O
DPMS	B-General_Concept
status	O
or	O
supported	O
video	O
modesis	O
also	O
stored	O
within	O
the	O
connector	O
.	O
</s>
<s>
Encoders	O
:	O
the	O
display	O
controller	O
must	O
encode	O
the	O
video	B-Application
mode	I-Application
timing	I-Application
signal	I-Application
from	O
the	O
CRTC	O
using	O
a	O
format	O
suitable	O
for	O
the	O
intended	O
connector	O
.	O
</s>
<s>
Examples	O
of	O
encodingsfor	O
digital	O
outputsare	O
TMDS	B-Protocol
and	O
LVDS	B-Architecture
;	O
for	O
analog	O
outputs	O
such	O
as	O
VGA	B-Protocol
and	O
TV	O
out	O
,	O
specific	O
DAC	O
blocks	O
are	O
generally	O
used	O
.	O
</s>
<s>
Planes	O
:	O
a	O
plane	O
is	O
not	O
a	O
hardware	O
block	O
but	O
a	O
memory	O
object	O
containing	O
a	O
buffer	B-General_Concept
from	O
which	O
a	O
scanout	O
engine	O
(	O
a	O
CRTC	O
)	O
is	O
fed	O
.	O
</s>
<s>
The	O
plane	O
that	O
holds	O
the	O
framebuffer	B-Algorithm
is	O
called	O
the	O
primary	O
plane	O
,	O
and	O
each	O
CRTC	O
must	O
have	O
one	O
associated	O
,	O
since	O
it	O
's	O
the	O
source	O
for	O
the	O
CRTC	O
to	O
determine	O
the	O
video	O
modedisplay	O
resolution	O
(	O
width	O
and	O
height	O
)	O
,	O
pixel	O
size	O
,	O
pixel	O
format	O
,	O
refresh	O
rate	O
,	O
etc	O
.	O
</s>
<s>
A	O
CRTC	O
might	O
have	O
also	O
cursor	O
planes	O
associated	O
to	O
it	O
if	O
the	O
display	O
controller	O
supports	O
hardware	O
cursor	O
overlays	O
,	O
or	O
secondary	O
planes	O
if	O
it	O
's	O
able	O
to	O
scan	O
out	O
from	O
additional	O
hardware	B-Architecture
overlays	I-Architecture
and	O
compose	O
or	O
blend	O
"	O
on	O
the	O
fly	O
"	O
the	O
final	O
image	O
sent	O
to	O
the	O
output	O
device	O
.	O
</s>
<s>
In	O
recent	O
years	O
there	O
has	O
been	O
an	O
ongoing	O
effort	O
to	O
bring	O
atomicity	B-General_Concept
to	O
some	O
regular	O
operations	O
pertaining	O
the	O
KMS	O
API	B-Application
,	O
specifically	O
to	O
the	O
mode	B-Operating_System
setting	I-Operating_System
and	O
page	O
flipping	O
operations	O
.	O
</s>
<s>
This	O
enhanced	O
KMS	O
API	B-Application
is	O
what	O
is	O
called	O
Atomic	O
Display	O
(	O
formerly	O
known	O
as	O
atomic	O
mode-setting	B-Operating_System
and	O
atomic	O
or	O
nuclear	O
pageflip	O
)	O
.	O
</s>
<s>
The	O
purpose	O
of	O
the	O
atomic	O
mode-setting	B-Operating_System
is	O
to	O
ensure	O
a	O
correct	O
change	O
of	O
mode	O
in	O
complex	O
configurations	O
with	O
multiple	O
restrictions	O
,	O
by	O
avoiding	O
intermediate	O
steps	O
which	O
could	O
lead	O
to	O
an	O
inconsistent	O
or	O
invalid	O
video	O
state	O
;	O
it	O
also	O
avoids	O
risky	O
video	O
states	O
when	O
a	O
failed	O
mode-setting	B-Operating_System
process	O
has	O
to	O
be	O
undone	O
(	O
"	O
rollback	O
"	O
)	O
.	O
</s>
<s>
Atomic	O
mode-setting	B-Operating_System
allows	O
to	O
know	O
beforehand	O
if	O
certain	O
specific	O
mode	O
configuration	O
is	O
appropriate	O
,	O
by	O
providing	O
mode	O
testing	O
capabilities	O
.	O
</s>
<s>
When	O
an	O
atomic	O
mode	O
is	O
tested	O
and	O
its	O
validity	O
confirmed	O
,	O
it	O
can	O
be	O
applied	O
with	O
a	O
single	O
indivisible	O
(	O
atomic	O
)	O
commit	B-Operating_System
operation	O
.	O
</s>
<s>
Both	O
test	O
and	O
commit	B-Operating_System
operations	O
are	O
provided	O
by	O
the	O
same	O
new	O
ioctl	B-Operating_System
with	O
different	O
flags	O
.	O
</s>
<s>
The	O
new	O
atomic	O
API	B-Application
is	O
built	O
upon	O
the	O
old	O
KMS	O
API	B-Application
.	O
</s>
<s>
The	O
atomic	O
procedure	O
is	O
based	O
on	O
changing	O
the	O
relevant	O
properties	O
to	O
build	O
the	O
state	O
that	O
we	O
want	O
to	O
test	O
or	O
commit	B-Operating_System
.	O
</s>
<s>
The	O
properties	O
we	O
want	O
to	O
modify	O
depend	O
on	O
whether	O
we	O
want	O
to	O
do	O
a	O
mode-setting	B-Operating_System
(	O
mostly	O
CRTCs	O
,	O
encoders	O
and	O
connectors	O
properties	O
)	O
or	O
page	O
flipping	O
(	O
usually	O
planes	O
properties	O
)	O
.	O
</s>
<s>
The	O
ioctl	B-Operating_System
is	O
the	O
same	O
for	O
both	O
cases	O
,	O
the	O
difference	O
being	O
the	O
list	O
of	O
properties	O
passed	O
with	O
each	O
one	O
.	O
</s>
<s>
In	O
the	O
original	O
DRM	O
API	B-Application
,	O
the	O
DRM	O
device	O
/dev/dri/cardX	O
is	O
used	O
for	O
both	O
privileged	O
(	O
modesetting	B-Operating_System
,	O
other	O
display	O
control	O
)	O
and	O
non-privileged	O
(	O
rendering	O
,	O
GPGPU	B-Architecture
compute	O
)	O
operations	O
.	O
</s>
<s>
For	O
security	O
reasons	O
,	O
opening	O
the	O
associated	O
DRM	O
device	B-Application
file	I-Application
requires	O
special	O
privileges	O
"	O
equivalent	O
to	O
root-privileges	O
"	O
.	O
</s>
<s>
This	O
leads	O
to	O
an	O
architecture	O
where	O
only	O
some	O
reliable	O
user	B-Operating_System
space	I-Operating_System
programs	O
(	O
the	O
X	B-Operating_System
server	I-Operating_System
,	O
a	O
graphical	O
compositor	O
,	O
...	O
)	O
have	O
full	O
access	O
to	O
the	O
DRM	O
API	B-Application
,	O
including	O
the	O
privileged	O
parts	O
like	O
the	O
modeset	O
API	B-Application
.	O
</s>
<s>
Other	O
user	B-Operating_System
space	I-Operating_System
applications	O
that	O
want	O
to	O
render	O
or	O
make	O
GPGPU	B-Architecture
computations	O
should	O
be	O
granted	O
by	O
the	O
owner	O
of	O
the	O
DRM	O
device	O
(	O
"	O
DRM	O
Master	O
"	O
)	O
through	O
the	O
use	O
of	O
a	O
special	O
authentication	O
interface	O
.	O
</s>
<s>
Then	O
the	O
authenticated	O
applications	O
can	O
render	O
or	O
make	O
computations	O
using	O
a	O
restricted	O
version	O
of	O
the	O
DRM	O
API	B-Application
without	O
privileged	O
operations	O
.	O
</s>
<s>
This	O
design	O
imposes	O
a	O
severe	O
constraint	O
:	O
there	O
must	O
always	O
be	O
a	O
running	O
graphics	O
server	O
(	O
the	O
X	B-Operating_System
Server	I-Operating_System
,	O
a	O
Wayland	B-Language
compositor	O
,	O
...	O
)	O
acting	O
as	O
DRM-Master	O
of	O
a	O
DRM	O
device	O
so	O
that	O
other	O
user	B-Operating_System
space	I-Operating_System
programs	O
can	O
be	O
granted	O
the	O
use	O
of	O
the	O
device	O
,	O
even	O
in	O
cases	O
not	O
involving	O
any	O
graphics	O
display	O
like	O
GPGPU	B-Architecture
computations	O
.	O
</s>
<s>
The	O
"	O
render	O
nodes	O
"	O
concept	O
tries	O
to	O
solve	O
these	O
scenarios	O
by	O
splitting	O
the	O
DRM	O
user	B-Operating_System
space	I-Operating_System
API	B-Application
into	O
two	O
interfaces	O
–	O
one	O
privileged	O
and	O
one	O
non-privileged	O
–	O
and	O
using	O
separate	O
device	B-Application
files	I-Application
(	O
or	O
"	O
nodes	O
"	O
)	O
for	O
each	O
one	O
.	O
</s>
<s>
For	O
every	O
GPU	B-Architecture
found	O
,	O
its	O
corresponding	O
DRM	O
driverif	O
it	O
supports	O
the	O
render	O
nodes	O
featurecreates	O
a	O
device	B-Application
file	I-Application
/dev/dri/renderDX	O
,	O
called	O
the	O
render	O
node	O
,	O
in	O
addition	O
to	O
the	O
primary	O
node	O
/dev/dri/cardX	O
.	O
</s>
<s>
Clients	O
that	O
use	O
a	O
direct	O
rendering	O
model	O
and	O
applications	O
that	O
want	O
to	O
take	O
advantage	O
of	O
the	O
computing	O
facilities	O
of	O
a	O
GPU	B-Architecture
,	O
can	O
do	O
it	O
without	O
requiring	O
additional	O
privileges	O
by	O
simply	O
opening	O
any	O
existing	O
render	O
node	O
and	O
dispatching	O
GPU	B-Architecture
operations	O
using	O
the	O
limited	O
subset	O
of	O
the	O
DRM	O
API	B-Application
supported	O
by	O
those	O
nodesprovided	O
they	O
have	O
file	O
system	O
permissions	O
to	O
open	B-Language
the	O
device	B-Application
file	I-Application
.	O
</s>
<s>
Display	O
servers	O
,	O
compositors	O
and	O
any	O
other	O
program	O
that	O
requires	O
the	O
modeset	O
API	B-Application
or	O
any	O
other	O
privileged	O
operation	O
must	O
open	B-Language
the	O
standard	O
primary	O
node	O
that	O
grants	O
access	O
to	O
the	O
full	O
DRM	O
API	B-Application
and	O
use	O
it	O
as	O
usual	O
.	O
</s>
<s>
Render	O
nodes	O
explicitly	O
disallow	O
the	O
GEM	O
flink	O
operation	O
to	O
prevent	O
buffer	B-General_Concept
sharing	O
using	O
insecure	O
GEM	O
global	O
names	O
;	O
only	O
PRIME	O
(	O
DMA-BUF	O
)	O
file	B-Application
descriptors	I-Application
can	O
be	O
used	O
to	O
share	O
buffers	B-General_Concept
with	O
another	O
client	O
,	O
including	O
the	O
graphics	O
server	O
.	O
</s>
<s>
The	O
Linux	B-Operating_System
DRM	O
subsystem	O
includes	O
free	B-License
and	I-License
open-source	I-License
drivers	O
to	O
support	O
hardware	O
from	O
the	O
3	O
main	O
manufacturers	O
of	O
GPUs	B-Architecture
for	O
desktop	O
computers	O
(	O
AMD	O
,	O
NVIDIA	O
and	O
Intel	O
)	O
,	O
as	O
well	O
as	O
from	O
a	O
growing	O
number	O
of	O
mobile	O
GPU	B-Architecture
and	O
System	B-Architecture
on	I-Architecture
a	I-Architecture
chip	I-Architecture
(	O
SoC	O
)	O
integrators	O
.	O
</s>
<s>
+	O
DRM	O
drivers	O
Driver	O
Since	O
kernel	B-Operating_System
Supported	O
hardware	O
Vendor	O
support	O
Status/Notes	O
radeon	B-Device
2.4.1	O
AMD	O
(	O
formerly	O
ATi	O
)	O
Radeon	B-Device
GPU	B-Architecture
series	O
with	O
the	O
architectures	O
TeraScale	B-Architecture
and	O
GCN	O
1st	O
&	O
2nd	O
gen	O
.	O
</s>
<s>
Including	O
models	O
from	O
R100/200/300/400	O
,	O
Radeon	B-Device
X1000	I-Device
,	O
HD	O
2000/4000/5000/6000/7000/8000	O
,	O
R5/R7/R9	O
200/300	O
series	O
and	O
Kaveri	O
APUs	O
.	O
</s>
<s>
i915	O
2.6.9	O
Intel	B-Device
GMA	I-Device
830M	O
,	O
845G	O
,	O
852GM	O
,	O
855GM	O
,	O
865G	O
,	O
915G	O
,	O
945G	O
,	O
965G	O
,	O
G35	O
,	O
G41	O
,	O
G43	O
,	O
G45	O
chipsets	O
.	O
</s>
<s>
Intel	B-Application
HD	I-Application
and	I-Application
Iris	I-Application
Graphics	I-Application
HD	O
Graphics	O
2000/3000/2500/4000/4200/4400/4600/P4600/P4700/5000	O
,	O
Iris	B-Application
Graphics	I-Application
5100	O
,	O
Iris	B-Application
Pro	I-Application
Graphics	I-Application
5200	O
integrated	O
GPUs	B-Architecture
.	O
</s>
<s>
nouveau	B-Application
2.6.33	O
NVIDIA	O
Tesla	B-Operating_System
,	O
Fermi	B-General_Concept
,	O
Kepler	B-General_Concept
,	O
Maxwell	B-General_Concept
based	O
GeForce	B-Application
GPUs	B-Architecture
,	O
Tegra	B-Operating_System
K1	O
,	O
X1	O
SoC	O
exynos	O
3.2	O
Samsung	O
ARM-based	O
Exynos	O
SoCs	O
vmwgfx	O
3.2	O
(	O
from	O
staging	O
)	O
Virtual	O
GPU	B-Architecture
for	O
the	O
VMware	B-Operating_System
SVGA2	O
virtual	O
driver	O
gma500	O
3.3	O
(	O
from	O
staging	O
)	O
Intel	B-Device
GMA	I-Device
500	B-Device
and	O
other	O
Imagination	O
Technologies	O
(	O
PowerVR	B-Device
)	O
based	O
graphics	O
GPUs	B-Architecture
experimental	O
2D	O
KMS-only	O
driver	O
ast	O
3.5	O
ASpeed	O
Technologies	O
2000	O
series	O
experimental	O
mgag200	O
3.5	O
Matrox	B-Application
MGA-G200	O
server	O
display	O
enginesKMS-only	O
shmobile	O
3.7	O
Renesas	O
SH	O
Mobile	O
tegra	B-Operating_System
3.8	O
Nvidia	O
Tegra20	O
,	O
Tegra30	O
SoCs	O
omapdrm	O
3.9	O
Texas	O
Instruments	O
OMAP5	O
SoCs	O
rcar-du	O
3.11	O
Renesas	O
R-Car	O
SoC	O
Display	O
Units	O
msm	O
3.12	O
Qualcomm	O
's	O
Adreno	B-General_Concept
A2xx/A3xx/A4xx	O
GPU	B-Architecture
families	O
(	O
Snapdragon	B-Architecture
SOCs	I-Architecture
)	O
armada	O
3.13	O
Marvell	O
Armada	O
510	O
SoCs	O
bochs	B-Language
3.14	O
Virtual	O
VGA	B-Protocol
cards	I-Protocol
using	O
the	O
Bochs	B-Language
dispi	O
vga	B-Protocol
interface	O
(	O
such	O
as	O
QEMU	B-Application
stdvga	O
)	O
virtual	O
driver	O
sti	O
3.17	O
STMicroelectronics	O
SoC	O
stiH41x	O
series	O
imx	O
3.19	O
(	O
from	O
staging	O
)	O
Freescale	B-Architecture
i.MX	I-Architecture
SoCs	O
rockchip	B-Architecture
3.19	O
Rockchip	B-Architecture
SoC-based	O
GPUs	B-Architecture
KMS-only	O
amdgpu	O
4.2	O
AMD	B-Device
Radeon	I-Device
GPU	B-Architecture
series	O
with	O
the	O
architectures	O
GCN	O
3rd	O
&	O
4th	O
gen	O
.	O
</s>
<s>
Including	O
models	O
from	O
Radeon	B-Device
Rx	O
200/300/400/500	O
series	O
and	O
Carrizo	O
and	O
Bristol	O
&	O
Stoney	O
Ridge	O
APUs	O
.	O
</s>
<s>
virtio	B-Application
4.2	O
Virtual	O
GPU	B-Architecture
driver	O
for	O
QEMU	B-Application
based	O
virtual	O
machine	O
managers	O
(	O
like	O
KVM	B-Application
or	O
Xen	B-Operating_System
)	O
virtual	O
driver	O
vc4	O
4.4	O
Raspberry	B-Operating_System
Pi	I-Operating_System
's	O
Broadcom	O
BCM2835	B-Operating_System
and	O
BCM2836	O
SoCs	O
(	O
VideoCore	B-General_Concept
IV	O
GPU	B-Architecture
)	O
etnaviv	O
4.5	O
Vivante	O
GPU	B-Architecture
cores	O
found	O
in	O
several	O
SoCs	O
such	O
as	O
Marvell	O
ARMADA	O
and	O
Freescale	O
i.MX6	O
Series	O
sun4i	O
4.7	O
Allwinner	B-Architecture
SoCs	O
(	O
ARM	O
Mali-400	O
GPU	B-Architecture
)	O
kirin	B-Architecture
4.7	O
HiSilicon	B-Architecture
Kirin	B-Architecture
hi6220	O
SoC	O
(	O
ARM	B-General_Concept
Mali	I-General_Concept
450-MP4	O
GPU	B-Architecture
)	O
mediatek	B-Architecture
4.7	O
MediaTek	B-Architecture
MT8173	O
SoC	O
(	O
Imagination	O
PowerVR	B-Device
GX6250	O
GPU	B-Architecture
)	O
hibmc	O
4.10	O
HiSilicon	B-Architecture
hi1710	O
Huawei	O
iBMC	B-Device
SoC	O
(	O
Silicon	O
Image	O
SM750	O
GPU	B-Architecture
core	O
)	O
KMS-only	O
vkms	O
4.19	O
Software-only	O
model	O
of	O
a	O
KMS	O
driver	O
that	O
is	O
useful	O
for	O
testing	O
and	O
for	O
running	O
X	B-Operating_System
(	O
or	O
similar	O
)	O
on	O
headless	B-Application
machines	I-Application
.	O
</s>
<s>
Some	O
of	O
them	O
still	O
remain	O
in	O
the	O
kernel	B-Operating_System
code	O
,	O
but	O
most	O
have	O
been	O
already	O
removed	O
.	O
</s>
<s>
The	O
Direct	O
Rendering	O
Manager	O
is	O
developed	O
within	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
,	O
and	O
its	O
source	O
code	O
resides	O
in	O
the	O
/drivers/gpu/drm	O
directory	O
of	O
the	O
Linux	B-Operating_System
source	O
code	O
.	O
</s>
<s>
As	O
usual	O
in	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
development	O
,	O
DRM	O
submaintainers	O
and	O
contributors	O
send	O
their	O
patches	B-Application
with	O
new	O
features	O
and	O
bug	B-Error_Name
fixes	O
to	O
the	O
main	O
DRM	O
maintainer	O
which	O
integrates	O
them	O
into	O
its	O
own	O
Linux	B-Operating_System
repository	B-General_Concept
.	O
</s>
<s>
The	O
DRM	O
maintainer	O
in	O
turn	O
submits	O
all	O
of	O
these	O
patches	B-Application
that	O
are	O
ready	O
to	O
be	O
mainlined	O
to	O
Linus	O
Torvalds	O
whenever	O
a	O
new	O
Linux	B-Operating_System
version	O
is	O
going	O
to	O
be	O
released	O
.	O
</s>
<s>
Torvalds	O
,	O
as	O
top	O
maintainer	O
of	O
the	O
whole	O
kernel	B-Operating_System
,	O
holds	O
the	O
last	O
word	O
on	O
whether	O
a	O
patch	B-Application
is	O
suitable	O
or	O
not	O
for	O
inclusion	O
in	O
the	O
kernel	B-Operating_System
.	O
</s>
<s>
For	O
historical	O
reasons	O
,	O
the	O
source	O
code	O
of	O
the	O
libdrm	B-Application
library	B-Library
is	O
maintained	O
under	O
the	O
umbrella	O
of	O
the	O
Mesa	B-Application
project	O
.	O
</s>
<s>
In	O
1999	O
,	O
while	O
developing	O
DRI	B-Application
for	O
XFree86	B-Device
,	O
Precision	O
Insight	O
created	O
the	O
first	O
version	O
of	O
DRM	O
for	O
the	O
3dfx	O
video	B-Device
cards	I-Device
,	O
as	O
a	O
Linux	B-Operating_System
kernel	I-Operating_System
patch	B-Application
included	O
within	O
the	O
Mesa	B-Application
source	O
code	O
.	O
</s>
<s>
Later	O
that	O
year	O
,	O
the	O
DRM	O
code	O
was	O
mainlined	O
in	O
Linux	B-Operating_System
kernel	I-Operating_System
2.3.18	O
under	O
the	O
/drivers/char/drm/	O
directory	O
for	O
character	O
devices	O
.	O
</s>
<s>
During	O
the	O
following	O
years	O
the	O
number	O
of	O
supported	O
video	B-Device
cards	I-Device
grew	O
.	O
</s>
<s>
When	O
Linux	O
2.4.0	O
was	O
released	O
in	O
January	O
2001	O
there	O
was	O
already	O
support	O
for	O
Creative	O
Labs	O
GMX	O
2000	O
,	O
Intel	B-Device
i810	I-Device
,	O
Matrox	O
G200/G400	O
and	O
ATI	B-Device
Rage	I-Device
128	I-Device
,	O
in	O
addition	O
to	O
3dfx	O
Voodoo3	B-Device
cards	O
,	O
and	O
that	O
list	O
expanded	O
during	O
the	O
2.4.x	O
series	O
,	O
with	O
drivers	O
for	O
ATI	B-Device
Radeon	I-Device
cards	O
,	O
some	O
SiS	O
video	B-Device
cards	I-Device
and	O
Intel	O
830M	O
and	O
subsequent	O
integrated	O
GPUs	B-Architecture
.	O
</s>
<s>
The	O
split	O
of	O
DRM	O
into	O
two	O
components	O
,	O
DRM	O
core	O
and	O
DRM	O
driver	O
,	O
called	O
DRM	O
core/personality	O
split	O
was	O
done	O
during	O
the	O
second	O
half	O
of	O
2004	O
,	O
and	O
merged	O
into	O
kernel	B-Operating_System
version	O
2.6.11	O
.	O
</s>
<s>
This	O
split	O
allowed	O
multiple	O
DRM	O
drivers	O
for	O
multiple	O
devices	O
to	O
work	O
simultaneously	O
,	O
opening	O
the	O
way	O
to	O
multi-GPU	O
support	O
.	O
</s>
<s>
The	O
idea	O
of	O
putting	O
all	O
the	O
video	O
mode	B-Operating_System
setting	I-Operating_System
code	O
in	O
one	O
place	O
inside	O
the	O
kernel	B-Operating_System
had	O
been	O
acknowledged	O
for	O
years	O
,	O
but	O
the	O
graphics	B-Device
card	I-Device
manufacturers	O
had	O
argued	O
that	O
the	O
only	O
way	O
to	O
do	O
the	O
mode-setting	B-Operating_System
was	O
to	O
use	O
the	O
routines	O
provided	O
by	O
themselves	O
and	O
contained	O
in	O
the	O
Video	B-Device
BIOS	I-Device
of	O
each	O
graphics	B-Device
card	I-Device
.	O
</s>
<s>
Such	O
code	O
had	O
to	O
be	O
executed	O
using	O
x86	O
real	B-Application
mode	I-Application
,	O
which	O
prevented	O
it	O
from	O
being	O
invoked	O
by	O
a	O
kernel	B-Operating_System
running	O
in	O
protected	B-Application
mode	I-Application
.	O
</s>
<s>
The	O
situation	O
changed	O
when	O
Luc	O
Verhaegen	O
and	O
other	O
developers	O
found	O
a	O
way	O
to	O
do	O
the	O
mode-setting	B-Operating_System
natively	O
instead	O
of	O
BIOS-based	O
,	O
showing	O
that	O
it	O
was	O
possible	O
to	O
do	O
it	O
using	O
normal	O
kernel	B-Operating_System
code	O
and	O
laying	O
the	O
groundwork	O
for	O
what	O
would	O
become	O
Kernel	B-Operating_System
Mode	B-Operating_System
Setting	I-Operating_System
.	O
</s>
<s>
In	O
May	O
2007	O
Jesse	O
Barnes	O
(	O
Intel	O
)	O
published	O
the	O
first	O
proposal	O
for	O
a	O
drm-modesetting	O
API	B-Application
and	O
a	O
working	O
native	O
implementation	O
of	O
mode-setting	B-Operating_System
for	O
Intel	O
GPUs	B-Architecture
within	O
the	O
i915	O
DRM	O
driver	O
.	O
</s>
<s>
In	O
December	O
2007	O
Jerome	O
Glisse	O
started	O
to	O
add	O
the	O
native	O
mode-setting	B-Operating_System
code	O
for	O
ATI	O
cards	O
to	O
the	O
radeon	B-Device
DRM	O
driver	O
.	O
</s>
<s>
Work	O
on	O
both	O
the	O
API	B-Application
and	O
drivers	O
continued	O
during	O
2008	O
,	O
but	O
got	O
delayed	O
by	O
the	O
necessity	O
of	O
a	O
memory	O
manager	O
also	O
in	O
kernel	B-Operating_System
space	I-Operating_System
to	O
handle	O
the	O
framebuffers	B-Algorithm
.	O
</s>
<s>
The	O
DRM	O
source	O
code	O
tree	O
was	O
moved	O
to	O
its	O
own	O
source	O
directory	O
/drivers/gpu/drm/	O
and	O
the	O
different	O
drivers	O
were	O
moved	O
into	O
their	O
own	O
subdirectories	O
.	O
</s>
<s>
The	O
increasing	O
complexity	O
of	O
video	O
memory	B-General_Concept
management	I-General_Concept
led	O
to	O
several	O
approaches	O
to	O
solving	O
this	O
issue	O
.	O
</s>
<s>
TTM	O
was	O
proposed	O
for	O
inclusion	O
into	O
mainline	O
kernel	B-Operating_System
2.6.25	O
in	O
November	O
2007	O
,	O
and	O
again	O
in	O
May	O
2008	O
,	O
but	O
was	O
ditched	O
in	O
favor	O
of	O
a	O
new	O
approach	O
called	O
Graphics	O
Execution	O
Manager	O
(	O
GEM	O
)	O
.	O
</s>
<s>
GEM	O
was	O
first	O
developed	O
by	O
Keith	O
Packard	O
and	O
Emma	O
Anholt	O
from	O
Intel	O
as	O
simpler	O
solution	O
for	O
memory	B-General_Concept
management	I-General_Concept
for	O
their	O
i915	O
driver	O
.	O
</s>
<s>
GEM	O
was	O
well	O
received	O
and	O
merged	O
into	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
version	O
2.6.28	O
released	O
in	O
December	O
2008	O
.	O
</s>
<s>
Meanwhile	O
,	O
TTM	O
had	O
to	O
wait	O
until	O
September	O
2009	O
to	O
be	O
finally	O
merged	O
into	O
Linux	O
2.6.31	O
as	O
a	O
requirement	O
of	O
the	O
new	O
Radeon	B-Device
KMS	O
DRM	O
driver	O
.	O
</s>
<s>
With	O
memory	B-General_Concept
management	I-General_Concept
in	O
place	O
to	O
handle	O
buffer	B-General_Concept
objects	O
,	O
DRM	O
developers	O
could	O
finally	O
add	O
to	O
the	O
kernel	B-Operating_System
the	O
already	O
finished	O
API	B-Application
and	O
code	O
to	O
do	O
mode	B-Operating_System
setting	I-Operating_System
.	O
</s>
<s>
This	O
expanded	O
API	B-Application
is	O
what	O
is	O
called	O
Kernel	B-Operating_System
Mode-setting	I-Operating_System
(	O
KMS	O
)	O
and	O
the	O
drivers	O
which	O
implement	O
it	O
are	O
often	O
referred	O
to	O
as	O
KMS	O
drivers	O
.	O
</s>
<s>
In	O
March	O
2009	O
,	O
KMS	O
was	O
merged	O
into	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
version	O
2.6.29	O
,	O
along	O
with	O
KMS	O
support	O
for	O
the	O
i915	O
driver	O
.	O
</s>
<s>
The	O
KMS	O
API	B-Application
have	O
been	O
exposed	O
to	O
user	B-Operating_System
space	I-Operating_System
programs	O
since	O
libdrm	B-Application
2.4.3	O
.	O
</s>
<s>
The	O
userspace	B-Operating_System
X.Org	B-Operating_System
DDX	I-Operating_System
driver	O
for	O
Intel	O
graphics	B-Device
cards	I-Device
was	O
also	O
the	O
first	O
to	O
use	O
the	O
new	O
GEM	O
and	O
KMS	O
APIs	B-Application
.	O
</s>
<s>
KMS	O
support	O
for	O
the	O
radeon	B-Device
DRM	O
driver	O
was	O
added	O
to	O
Linux	O
2.6.31	O
release	O
of	O
September	O
2009	O
.	O
</s>
<s>
The	O
new	O
radeon	B-Device
KMS	O
driver	O
used	O
the	O
TTM	O
memory	O
manager	O
but	O
exposed	O
GEM-compatible	O
interfaces	O
and	O
ioctls	B-Operating_System
instead	O
of	O
TTM	O
ones	O
.	O
</s>
<s>
Since	O
2006	O
the	O
nouveau	B-Application
project	I-Application
had	O
been	O
developing	O
a	O
free	B-Application
software	I-Application
DRM	O
driver	O
for	O
NVIDIA	O
GPUs	B-Architecture
outside	O
of	O
the	O
official	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
In	O
2010	O
the	O
nouveau	B-Application
source	O
code	O
was	O
merged	O
into	O
Linux	O
2.6.33	O
as	O
an	O
experimental	O
driver	O
.	O
</s>
<s>
At	O
the	O
time	O
of	O
merging	O
,	O
the	O
driver	O
had	O
been	O
already	O
converted	O
to	O
KMS	O
,	O
and	O
behind	O
the	O
GEM	O
API	B-Application
it	O
used	O
TTM	O
as	O
its	O
memory	O
manager	O
.	O
</s>
<s>
The	O
new	O
KMS	O
APIincluding	O
the	O
GEM	O
APIwas	O
a	O
big	O
milestone	O
in	O
the	O
development	O
of	O
DRM	O
,	O
but	O
it	O
did	O
n't	O
stop	O
the	O
API	B-Application
for	O
being	O
enhanced	O
in	O
the	O
following	O
years	O
.	O
</s>
<s>
KMS	O
gained	O
support	O
for	O
page	O
flips	O
in	O
conjunction	O
with	O
asynchronous	O
VBLANK	O
notifications	O
in	O
Linux	O
2.6.33only	O
for	O
the	O
i915	O
driver	O
,	O
radeon	B-Device
and	O
nouveau	B-Application
added	O
it	O
later	O
during	O
Linux	O
2.6.38	O
release	O
.	O
</s>
<s>
The	O
new	O
page	O
flip	O
interface	O
was	O
added	O
to	O
libdrm	B-Application
2.4.17	O
.	O
</s>
<s>
In	O
early	O
2011	O
,	O
during	O
the	O
Linux	O
2.6.39	O
release	O
cycle	O
,	O
the	O
so-called	O
dumb	O
buffersa	O
hardware-independent	O
non-accelerated	O
way	O
to	O
handle	O
simple	O
buffers	B-General_Concept
suitable	O
for	O
use	O
as	O
framebufferswere	O
added	O
to	O
the	O
KMS	O
API	B-Application
.	O
</s>
<s>
The	O
goal	O
was	O
to	O
reduce	O
the	O
complexity	O
of	O
applications	O
such	O
as	O
Plymouth	B-Application
that	O
do	O
n't	O
need	O
to	O
use	O
special	O
accelerated	O
operations	O
provided	O
by	O
driver-specific	O
ioctls	B-Operating_System
.	O
</s>
<s>
The	O
feature	O
was	O
exposed	O
by	O
libdrm	B-Application
from	O
version	O
2.4.25	O
onwards	O
.	O
</s>
<s>
Planes	O
were	O
developed	O
to	O
represent	O
hardware	B-Architecture
overlays	I-Architecture
supported	O
by	O
the	O
scanout	O
engine	O
.	O
</s>
<s>
Plane	O
support	O
was	O
merged	O
into	O
Linux	B-Operating_System
3.3	O
.	O
and	O
libdrm	B-Application
2.4.30	O
.	O
</s>
<s>
Another	O
concept	O
added	O
to	O
the	O
APIduring	O
Linux	B-Operating_System
3.5	O
and	O
libdrm	B-Application
2.4.36	O
releaseswere	O
generic	O
object	O
properties	O
,	O
a	O
method	O
to	O
add	O
generic	O
values	O
to	O
any	O
KMS	O
object	O
.	O
</s>
<s>
An	O
early	O
proof	O
of	O
concept	O
to	O
provide	O
GPU	B-Architecture
offloading	O
between	O
DRM	O
drivers	O
was	O
developed	O
by	O
Dave	O
Airlie	O
in	O
2010	O
.	O
</s>
<s>
Since	O
Airlie	O
was	O
trying	O
to	O
mimic	O
the	O
NVIDIA	B-Application
Optimus	I-Application
technology	O
,	O
he	O
decided	O
to	O
name	O
it	O
"	O
PRIME	O
"	O
.	O
</s>
<s>
Airlie	O
resumed	O
his	O
work	O
on	O
PRIME	O
in	O
late	O
2011	O
,	O
but	O
based	O
on	O
the	O
new	O
DMA-BUF	O
buffer	B-General_Concept
sharing	O
mechanism	O
introduced	O
by	O
Linux	B-Operating_System
kernel	I-Operating_System
3.3	O
.	O
</s>
<s>
The	O
basic	O
DMA-BUF	O
PRIME	O
infrastructure	O
was	O
finished	O
in	O
March	O
2012	O
and	O
merged	O
into	O
the	O
Linux	B-Operating_System
3.4	O
release	O
,	O
as	O
well	O
as	O
into	O
libdrm	B-Application
2.4.34	O
.	O
</s>
<s>
Later	O
during	O
the	O
Linux	B-Operating_System
3.5	O
release	O
,	O
several	O
DRM	O
drivers	O
implemented	O
PRIME	O
support	O
,	O
including	O
i915	O
for	O
Intel	O
cards	O
,	O
radeon	B-Device
for	O
AMD	O
cards	O
and	O
nouveau	B-Application
for	O
NVIDIA	O
cards	O
.	O
</s>
<s>
In	O
recent	O
years	O
,	O
the	O
DRM	O
API	B-Application
has	O
incrementally	O
expanded	O
with	O
new	O
and	O
improved	O
features	O
.	O
</s>
<s>
In	O
2013	O
,	O
as	O
part	O
of	O
GSoC	B-Application
,	O
David	O
Herrmann	O
developed	O
the	O
multiple	O
render	O
nodes	O
feature	O
.	O
</s>
<s>
His	O
code	O
was	O
added	O
to	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
version	O
3.12	O
as	O
an	O
experimental	O
feature	O
supported	O
by	O
i915	O
,	O
radeon	B-Device
and	O
nouveau	B-Application
drivers	I-Application
,	O
and	O
enabled	O
by	O
default	O
since	O
Linux	B-Operating_System
3.17	O
.	O
</s>
<s>
In	O
2014	O
Matt	O
Roper	O
(	O
Intel	O
)	O
developed	O
the	O
universal	O
planes	O
(	O
or	O
unified	O
planes	O
)	O
concept	O
by	O
which	O
framebuffers	B-Algorithm
(	O
primary	O
planes	O
)	O
,	O
overlays	O
(	O
secondary	O
planes	O
)	O
and	O
cursors	O
(	O
cursor	O
planes	O
)	O
are	O
all	O
treated	O
as	O
a	O
single	O
type	O
of	O
object	O
with	O
an	O
unified	O
API	B-Application
.	O
</s>
<s>
Universal	O
planes	O
support	O
provides	O
a	O
more	O
consistent	O
DRM	O
API	B-Application
with	O
fewer	O
,	O
more	O
generic	O
ioctls	B-Operating_System
.	O
</s>
<s>
In	O
order	O
to	O
maintain	O
the	O
API	B-Application
backwards	B-General_Concept
compatible	I-General_Concept
,	O
the	O
feature	O
is	O
exposed	O
by	O
DRM	O
core	O
as	O
an	O
additional	O
capability	O
that	O
a	O
DRM	O
driver	O
can	O
provide	O
.	O
</s>
<s>
Universal	O
plane	O
support	O
debuted	O
in	O
Linux	B-Operating_System
3.15	O
and	O
libdrm	B-Application
2.4.55	O
.	O
</s>
<s>
The	O
most	O
recent	O
DRM	O
API	B-Application
enhancement	O
is	O
the	O
atomic	O
mode-setting	B-Operating_System
API	B-Application
,	O
which	O
brings	O
atomicity	B-General_Concept
to	O
the	O
mode-setting	B-Operating_System
and	O
page	O
flipping	O
operations	O
on	O
a	O
DRM	O
device	O
.	O
</s>
<s>
The	O
idea	O
of	O
an	O
atomic	O
API	B-Application
for	O
mode-setting	B-Operating_System
was	O
first	O
proposed	O
in	O
early	O
2012	O
.	O
</s>
<s>
Ville	O
Syrjälä	O
(	O
Intel	O
)	O
took	O
over	O
the	O
task	O
of	O
designing	O
and	O
implementing	O
such	O
atomic	O
API	B-Application
.	O
</s>
<s>
Later	O
in	O
2013	O
both	O
proposed	O
features	O
were	O
reunited	O
in	O
a	O
single	O
one	O
using	O
a	O
single	O
ioctl	B-Operating_System
for	O
both	O
tasks	O
.	O
</s>
<s>
All	O
of	O
this	O
work	O
was	O
finally	O
merged	O
into	O
Linux	B-Operating_System
3.19	O
and	O
Linux	B-Operating_System
4.0	O
releases	O
,	O
and	O
enabled	O
by	O
default	O
since	O
Linux	B-Operating_System
4.2	O
.	O
libdrm	B-Application
exposed	O
the	O
new	O
atomic	O
API	B-Application
since	O
version	O
2.4.62	O
.	O
</s>
<s>
Multiple	O
drivers	O
have	O
already	O
been	O
converted	O
to	O
the	O
new	O
atomic	O
API	B-Application
.	O
</s>
<s>
By	O
2018	O
ten	O
new	O
DRM	O
drivers	O
based	O
on	O
this	O
new	O
atomic	O
model	O
had	O
been	O
added	O
to	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
The	O
Direct	O
Rendering	O
Manager	O
kernel	B-Operating_System
subsystem	O
was	O
initially	O
developed	O
to	O
be	O
used	O
with	O
the	O
new	O
Direct	B-Application
Rendering	I-Application
Infrastructure	I-Application
of	O
the	O
XFree86	B-Device
4.0	O
display	O
server	O
,	O
later	O
inherited	O
by	O
its	O
successor	O
,	O
the	O
X.Org	B-Operating_System
Server	I-Operating_System
.	O
</s>
<s>
Therefore	O
,	O
the	O
main	O
users	O
of	O
DRM	O
were	O
DRI	B-Application
clients	O
that	O
link	O
to	O
the	O
hardware-accelerated	B-General_Concept
OpenGL	B-Application
implementation	O
that	O
lives	O
in	O
the	O
Mesa	B-Application
3D	I-Application
library	B-Library
,	O
as	O
well	O
as	O
the	O
X	B-Operating_System
Server	I-Operating_System
itself	O
.	O
</s>
<s>
Nowadays	O
DRM	O
is	O
also	O
used	O
by	O
several	O
Wayland	B-Language
compositors	I-Language
,	O
including	O
Weston	O
reference	O
compositor	O
.	O
</s>
<s>
kmscon	B-Application
is	O
a	O
virtual	B-Application
console	I-Application
implementation	O
that	O
runs	O
in	O
user	B-Operating_System
space	I-Operating_System
using	O
DRM	O
KMS	O
facilities	O
.	O
</s>
<s>
In	O
2015	O
,	O
version	O
358.09	O
(	O
beta	O
)	O
of	O
the	O
proprietary	O
Nvidia	B-Application
GeForce	I-Application
driver	I-Application
received	O
support	O
for	O
the	O
DRM	O
mode-setting	B-Operating_System
interface	O
implemented	O
as	O
a	O
new	O
kernel	B-Operating_System
blob	O
called	O
nvidia-modeset.ko	O
.	O
</s>
<s>
This	O
new	O
driver	O
component	O
works	O
in	O
conjunction	O
with	O
the	O
nvidia.ko	O
kernel	B-Application
module	I-Application
to	O
program	O
the	O
display	O
engine	O
(	O
i.e.	O
</s>
<s>
display	O
controller	O
)	O
of	O
the	O
GPU	B-Architecture
.	O
</s>
