1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 2. DRM Internals</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux GPU Driver Developer's Guide"><link rel="up" href="drmCore.html" title="Part I. DRM Core"><link rel="prev" href="drmIntroduction.html" title="Chapter 1. Introduction"><link rel="next" href="API-drm-put-dev.html" title="drm_put_dev"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2. DRM Internals</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="drmIntroduction.html">Prev</a> </td><th width="60%" align="center">Part I. DRM Core</th><td width="20%" align="right"> <a accesskey="n" href="API-drm-put-dev.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="drmInternals"></a>Chapter 2. DRM Internals</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="drmInternals.html#id-1.3.4.5">Driver Initialization</a></span></dt><dd><dl><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.4">Driver Information</a></span></dt><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.5">Device Instance and Driver Handling</a></span></dt><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.6">Driver Load</a></span></dt><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.7">Bus-specific Device Registration and PCI Support</a></span></dt></dl></dd><dt><span class="sect1"><a href="drm-memory-management.html">Memory management</a></span></dt><dd><dl><dt><span class="sect2"><a href="drm-memory-management.html#id-1.3.4.6.5">The Translation Table Manager (TTM)</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#drm-gem">The Graphics Execution Manager (GEM)</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#id-1.3.4.6.7">VMA Offset Manager</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#drm-prime-support">PRIME Buffer Sharing</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#id-1.3.4.6.9">PRIME Function References</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#id-1.3.4.6.10">DRM MM Range Allocator</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#id-1.3.4.6.11">DRM MM Range Allocator Function References</a></span></dt><dt><span class="sect2"><a href="drm-memory-management.html#id-1.3.4.6.12">CMA Helper Functions Reference</a></span></dt></dl></dd><dt><span class="sect1"><a href="drm-mode-setting.html">Mode Setting</a></span></dt><dd><dl><dt><span class="sect2"><a href="drm-mode-setting.html#id-1.3.4.7.4">Display Modes Function Reference</a></span></dt><dt><span class="sect2"><a href="drm-mode-setting.html#id-1.3.4.7.5">Atomic Mode Setting Function Reference</a></span></dt><dt><span class="sect2"><a href="drm-mode-setting.html#id-1.3.4.7.6">Frame Buffer Creation</a></span></dt><dt><span class="sect2"><a href="drm-mode-setting.html#id-1.3.4.7.7">Dumb Buffer Objects</a></span></dt><dt><span class="sect2"><a href="drm-mode-setting.html#id-1.3.4.7.8">Output Polling</a></span></dt><dt><span class="sect2"><a href="drm-mode-setting.html#id-1.3.4.7.9">Locking</a></span></dt></dl></dd><dt><span class="sect1"><a href="drm-kms-init.html">KMS Initialization and Cleanup</a></span></dt><dd><dl><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.3">CRTCs (struct drm_crtc)</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.4">Planes (struct drm_plane)</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.5">Encoders (struct drm_encoder)</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.6">Connectors (struct drm_connector)</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.7">Cleanup</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.8">Output discovery and initialization example</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.9">KMS API Functions</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.10">KMS Data Structures</a></span></dt><dt><span class="sect2"><a href="drm-kms-init.html#id-1.3.4.8.11">KMS Locking</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch02s05.html">Mode Setting Helper Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.6">Helper Functions</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.7">CRTC Helper Operations</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.8">Encoder Helper Operations</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.9">Connector Helper Operations</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.10">Atomic Modeset Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.11">Modeset Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.12">Output Probing Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.13">fbdev Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.14">Display Port Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.15">Display Port MST Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.16">MIPI DSI Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.17">EDID Helper Functions Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.18">Rectangle Utilities Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.19">Flip-work Helper Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.20">HDMI Infoframes Helper Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.21">Plane Helper Reference</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.22">Tile group</a></span></dt><dt><span class="sect2"><a href="ch02s05.html#id-1.3.4.9.23">Bridges</a></span></dt></dl></dd><dt><span class="sect1"><a href="drm-kms-properties.html">KMS Properties</a></span></dt><dd><dl><dt><span class="sect2"><a href="drm-kms-properties.html#id-1.3.4.10.10">Existing KMS Properties</a></span></dt></dl></dd><dt><span class="sect1"><a href="drm-vertical-blank.html">Vertical Blanking</a></span></dt><dd><dl><dt><span class="sect2"><a href="drm-vertical-blank.html#id-1.3.4.11.10">Vertical Blanking and Interrupt Handling Functions Reference</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch02s08.html">Open/Close, File Operations and IOCTLs</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch02s08.html#id-1.3.4.12.2">Open and Close</a></span></dt><dt><span class="sect2"><a href="ch02s08.html#id-1.3.4.12.3">File Operations</a></span></dt><dt><span class="sect2"><a href="ch02s08.html#id-1.3.4.12.4">IOCTLs</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch02s09.html">Legacy Support Code</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch02s09.html#id-1.3.4.13.3">Legacy Suspend/Resume</a></span></dt><dt><span class="sect2"><a href="ch02s09.html#id-1.3.4.13.4">Legacy DMA Services</a></span></dt></dl></dd></dl></div><p> 2 This chapter documents DRM internals relevant to driver authors 3 and developers working to add support for the latest features to 4 existing drivers. 5 </p><p> 6 First, we go over some typical driver initialization 7 requirements, like setting up command buffers, creating an 8 initial output configuration, and initializing core services. 9 Subsequent sections cover core internals in more detail, 10 providing implementation notes and examples. 11 </p><p> 12 The DRM layer provides several services to graphics drivers, 13 many of them driven by the application interfaces it provides 14 through libdrm, the library that wraps most of the DRM ioctls. 15 These include vblank event handling, memory 16 management, output management, framebuffer management, command 17 submission & fencing, suspend/resume support, and DMA 18 services. 19 </p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id-1.3.4.5"></a>Driver Initialization</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.4">Driver Information</a></span></dt><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.5">Device Instance and Driver Handling</a></span></dt><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.6">Driver Load</a></span></dt><dt><span class="sect2"><a href="drmInternals.html#id-1.3.4.5.7">Bus-specific Device Registration and PCI Support</a></span></dt></dl></div><p> 20 At the core of every DRM driver is a <span class="structname">drm_driver</span> 21 structure. Drivers typically statically initialize a drm_driver structure, 22 and then pass it to <code class="function">drm_dev_alloc()</code> to allocate a 23 device instance. After the device instance is fully initialized it can be 24 registered (which makes it accessible from userspace) using 25 <code class="function">drm_dev_register()</code>. 26 </p><p> 27 The <span class="structname">drm_driver</span> structure contains static 28 information that describes the driver and features it supports, and 29 pointers to methods that the DRM core will call to implement the DRM API. 30 We will first go through the <span class="structname">drm_driver</span> static 31 information fields, and will then describe individual operations in 32 details as they get used in later sections. 33 </p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id-1.3.4.5.4"></a>Driver Information</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect3"><a href="drmInternals.html#id-1.3.4.5.4.2">Driver Features</a></span></dt><dt><span class="sect3"><a href="drmInternals.html#id-1.3.4.5.4.3">Major, Minor and Patchlevel</a></span></dt><dt><span class="sect3"><a href="drmInternals.html#id-1.3.4.5.4.4">Name, Description and Date</a></span></dt></dl></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id-1.3.4.5.4.2"></a>Driver Features</h4></div></div></div><p> 34 Drivers inform the DRM core about their requirements and supported 35 features by setting appropriate flags in the 36 <em class="structfield"><code>driver_features</code></em> field. Since those flags 37 influence the DRM core behaviour since registration time, most of them 38 must be set to registering the <span class="structname">drm_driver</span> 39 instance. 40 </p><pre class="synopsis">u32 driver_features;</pre><div class="variablelist"><p class="title"><b>Driver Feature Flags</b></p><dl class="variablelist"><dt><span class="term">DRIVER_USE_AGP</span></dt><dd><p> 41 Driver uses AGP interface, the DRM core will manage AGP resources. 42 </p></dd><dt><span class="term">DRIVER_REQUIRE_AGP</span></dt><dd><p> 43 Driver needs AGP interface to function. AGP initialization failure 44 will become a fatal error. 45 </p></dd><dt><span class="term">DRIVER_PCI_DMA</span></dt><dd><p> 46 Driver is capable of PCI DMA, mapping of PCI DMA buffers to 47 userspace will be enabled. Deprecated. 48 </p></dd><dt><span class="term">DRIVER_SG</span></dt><dd><p> 49 Driver can perform scatter/gather DMA, allocation and mapping of 50 scatter/gather buffers will be enabled. Deprecated. 51 </p></dd><dt><span class="term">DRIVER_HAVE_DMA</span></dt><dd><p> 52 Driver supports DMA, the userspace DMA API will be supported. 53 Deprecated. 54 </p></dd><dt><span class="term">DRIVER_HAVE_IRQ, </span><span class="term">DRIVER_IRQ_SHARED</span></dt><dd><p> 55 DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler 56 managed by the DRM Core. The core will support simple IRQ handler 57 installation when the flag is set. The installation process is 58 described in <a class="xref" href="drmInternals.html#drm-irq-registration" title="IRQ Registration">the section called “IRQ Registration”</a>.</p><p>DRIVER_IRQ_SHARED indicates whether the device & handler 59 support shared IRQs (note that this is required of PCI drivers). 60 </p></dd><dt><span class="term">DRIVER_GEM</span></dt><dd><p> 61 Driver use the GEM memory manager. 62 </p></dd><dt><span class="term">DRIVER_MODESET</span></dt><dd><p> 63 Driver supports mode setting interfaces (KMS). 64 </p></dd><dt><span class="term">DRIVER_PRIME</span></dt><dd><p> 65 Driver implements DRM PRIME buffer sharing. 66 </p></dd><dt><span class="term">DRIVER_RENDER</span></dt><dd><p> 67 Driver supports dedicated render nodes. 68 </p></dd><dt><span class="term">DRIVER_ATOMIC</span></dt><dd><p> 69 Driver supports atomic properties. In this case the driver 70 must implement appropriate obj->atomic_get_property() vfuncs 71 for any modeset objects with driver specific properties. 72 </p></dd></dl></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id-1.3.4.5.4.3"></a>Major, Minor and Patchlevel</h4></div></div></div><pre class="synopsis">int major; 73int minor; 74int patchlevel;</pre><p> 75 The DRM core identifies driver versions by a major, minor and patch 76 level triplet. The information is printed to the kernel log at 77 initialization time and passed to userspace through the 78 DRM_IOCTL_VERSION ioctl. 79 </p><p> 80 The major and minor numbers are also used to verify the requested driver 81 API version passed to DRM_IOCTL_SET_VERSION. When the driver API changes 82 between minor versions, applications can call DRM_IOCTL_SET_VERSION to 83 select a specific version of the API. If the requested major isn't equal 84 to the driver major, or the requested minor is larger than the driver 85 minor, the DRM_IOCTL_SET_VERSION call will return an error. Otherwise 86 the driver's set_version() method will be called with the requested 87 version. 88 </p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id-1.3.4.5.4.4"></a>Name, Description and Date</h4></div></div></div><pre class="synopsis">char *name; 89char *desc; 90char *date;</pre><p> 91 The driver name is printed to the kernel log at initialization time, 92 used for IRQ registration and passed to userspace through 93 DRM_IOCTL_VERSION. 94 </p><p> 95 The driver description is a purely informative string passed to 96 userspace through the DRM_IOCTL_VERSION ioctl and otherwise unused by 97 the kernel. 98 </p><p> 99 The driver date, formatted as YYYYMMDD, is meant to identify the date of 100 the latest modification to the driver. However, as most drivers fail to 101 update it, its value is mostly useless. The DRM core prints it to the 102 kernel log at initialization time and passes it to userspace through the 103 DRM_IOCTL_VERSION ioctl. 104 </p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id-1.3.4.5.5"></a>Device Instance and Driver Handling</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="refentrytitle"><a href="API-drm-put-dev.html"><span class="phrase">drm_put_dev</span></a></span><span class="refpurpose"> — 105 Unregister and release a DRM device 106 </span></dt><dt><span class="refentrytitle"><a href="API-drm-dev-alloc.html"><span class="phrase">drm_dev_alloc</span></a></span><span class="refpurpose"> — 107 Allocate new DRM device 108 </span></dt><dt><span class="refentrytitle"><a href="API-drm-dev-ref.html"><span class="phrase">drm_dev_ref</span></a></span><span class="refpurpose"> — 109 Take reference of a DRM device 110 </span></dt><dt><span class="refentrytitle"><a href="API-drm-dev-unref.html"><span class="phrase">drm_dev_unref</span></a></span><span class="refpurpose"> — 111 Drop reference of a DRM device 112 </span></dt><dt><span class="refentrytitle"><a href="API-drm-dev-register.html"><span class="phrase">drm_dev_register</span></a></span><span class="refpurpose"> — 113 Register DRM device 114 </span></dt><dt><span class="refentrytitle"><a href="API-drm-dev-unregister.html"><span class="phrase">drm_dev_unregister</span></a></span><span class="refpurpose"> — 115 Unregister DRM device 116 </span></dt><dt><span class="refentrytitle"><a href="API-drm-dev-set-unique.html"><span class="phrase">drm_dev_set_unique</span></a></span><span class="refpurpose"> — 117 Set the unique name of a DRM device 118 </span></dt></dl></div><p> 119 </p><p> 120 A device instance for a drm driver is represented by struct <span class="structname">drm_device</span>. This 121 is allocated with <code class="function"><a class="link" href="API-drm-dev-alloc.html" title="drm_dev_alloc">drm_dev_alloc</a></code>, usually from bus-specific -><code class="function">probe</code> 122 callbacks implemented by the driver. The driver then needs to initialize all 123 the various subsystems for the drm device like memory management, vblank 124 handling, modesetting support and intial output configuration plus obviously 125 initialize all the corresponding hardware bits. An important part of this is 126 also calling <code class="function"><a class="link" href="API-drm-dev-set-unique.html" title="drm_dev_set_unique">drm_dev_set_unique</a></code> to set the userspace-visible unique name of 127 this device instance. Finally when everything is up and running and ready for 128 userspace the device instance can be published using <code class="function"><a class="link" href="API-drm-dev-register.html" title="drm_dev_register">drm_dev_register</a></code>. 129 </p><p> 130 There is also deprecated support for initalizing device instances using 131 bus-specific helpers and the -><code class="function">load</code> callback. But due to 132 backwards-compatibility needs the device instance have to be published too 133 early, which requires unpretty global locking to make safe and is therefore 134 only support for existing drivers not yet converted to the new scheme. 135 </p><p> 136 When cleaning up a device instance everything needs to be done in reverse: 137 First unpublish the device instance with <code class="function"><a class="link" href="API-drm-dev-unregister.html" title="drm_dev_unregister">drm_dev_unregister</a></code>. Then clean up 138 any other resources allocated at device initialization and drop the driver's 139 reference to <span class="structname">drm_device</span> using <code class="function"><a class="link" href="API-drm-dev-unref.html" title="drm_dev_unref">drm_dev_unref</a></code>. 140 </p><p> 141 Note that the lifetime rules for <span class="structname">drm_device</span> instance has still a lot of 142 historical baggage. Hence use the reference counting provided by 143 <code class="function"><a class="link" href="API-drm-dev-ref.html" title="drm_dev_ref">drm_dev_ref</a></code> and <code class="function"><a class="link" href="API-drm-dev-unref.html" title="drm_dev_unref">drm_dev_unref</a></code> only carefully. 144 </p><p> 145 Also note that embedding of <span class="structname">drm_device</span> is currently not (yet) supported (but 146 it would be easy to add). Drivers can store driver-private data in the 147 dev_priv field of <span class="structname">drm_device</span>. 148</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id-1.3.4.5.6"></a>Driver Load</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect3"><a href="drmInternals.html#drm-irq-registration">IRQ Registration</a></span></dt><dt><span class="sect3"><a href="drmInternals.html#id-1.3.4.5.6.3">Memory Manager Initialization</a></span></dt><dt><span class="sect3"><a href="drmInternals.html#id-1.3.4.5.6.4">Miscellaneous Device Configuration</a></span></dt></dl></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="drm-irq-registration"></a>IRQ Registration</h4></div></div></div><p> 149 The DRM core tries to facilitate IRQ handler registration and 150 unregistration by providing <code class="function"><a class="link" href="API-drm-irq-install.html" title="drm_irq_install">drm_irq_install</a></code> and 151 <code class="function"><a class="link" href="API-drm-irq-uninstall.html" title="drm_irq_uninstall">drm_irq_uninstall</a></code> functions. Those functions only 152 support a single interrupt per device, devices that use more than one 153 IRQs need to be handled manually. 154 </p><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="id-1.3.4.5.6.2.3"></a>Managed IRQ Registration</h5></div></div></div><p> 155 <code class="function"><a class="link" href="API-drm-irq-install.html" title="drm_irq_install">drm_irq_install</a></code> starts by calling the 156 <code class="methodname">irq_preinstall</code> driver operation. The operation 157 is optional and must make sure that the interrupt will not get fired by 158 clearing all pending interrupt flags or disabling the interrupt. 159 </p><p> 160 The passed-in IRQ will then be requested by a call to 161 <code class="function">request_irq</code>. If the DRIVER_IRQ_SHARED driver 162 feature flag is set, a shared (IRQF_SHARED) IRQ handler will be 163 requested. 164 </p><p> 165 The IRQ handler function must be provided as the mandatory irq_handler 166 driver operation. It will get passed directly to 167 <code class="function">request_irq</code> and thus has the same prototype as all 168 IRQ handlers. It will get called with a pointer to the DRM device as the 169 second argument. 170 </p><p> 171 Finally the function calls the optional 172 <code class="methodname">irq_postinstall</code> driver operation. The operation 173 usually enables interrupts (excluding the vblank interrupt, which is 174 enabled separately), but drivers may choose to enable/disable interrupts 175 at a different time. 176 </p><p> 177 <code class="function"><a class="link" href="API-drm-irq-uninstall.html" title="drm_irq_uninstall">drm_irq_uninstall</a></code> is similarly used to uninstall an 178 IRQ handler. It starts by waking up all processes waiting on a vblank 179 interrupt to make sure they don't hang, and then calls the optional 180 <code class="methodname">irq_uninstall</code> driver operation. The operation 181 must disable all hardware interrupts. Finally the function frees the IRQ 182 by calling <code class="function">free_irq</code>. 183 </p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="id-1.3.4.5.6.2.4"></a>Manual IRQ Registration</h5></div></div></div><p> 184 Drivers that require multiple interrupt handlers can't use the managed 185 IRQ registration functions. In that case IRQs must be registered and 186 unregistered manually (usually with the <code class="function">request_irq</code> 187 and <code class="function">free_irq</code> functions, or their devm_* equivalent). 188 </p><p> 189 When manually registering IRQs, drivers must not set the DRIVER_HAVE_IRQ 190 driver feature flag, and must not provide the 191 <code class="methodname">irq_handler</code> driver operation. They must set the 192 <span class="structname">drm_device</span> <em class="structfield"><code>irq_enabled</code></em> 193 field to 1 upon registration of the IRQs, and clear it to 0 after 194 unregistering the IRQs. 195 </p></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id-1.3.4.5.6.3"></a>Memory Manager Initialization</h4></div></div></div><p> 196 Every DRM driver requires a memory manager which must be initialized at 197 load time. DRM currently contains two memory managers, the Translation 198 Table Manager (TTM) and the Graphics Execution Manager (GEM). 199 This document describes the use of the GEM memory manager only. See 200 <a class="xref" href="drm-memory-management.html" title="Memory management">the section called “Memory management”</a> for details. 201 </p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="id-1.3.4.5.6.4"></a>Miscellaneous Device Configuration</h4></div></div></div><p> 202 Another task that may be necessary for PCI devices during configuration 203 is mapping the video BIOS. On many devices, the VBIOS describes device 204 configuration, LCD panel timings (if any), and contains flags indicating 205 device state. Mapping the BIOS can be done using the pci_map_rom() call, 206 a convenience function that takes care of mapping the actual ROM, 207 whether it has been shadowed into memory (typically at address 0xc0000) 208 or exists on the PCI device in the ROM BAR. Note that after the ROM has 209 been mapped and any necessary information has been extracted, it should 210 be unmapped; on many devices, the ROM address decoder is shared with 211 other BARs, so leaving it mapped could cause undesired behaviour like 212 hangs or memory corruption. 213 214 </p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="id-1.3.4.5.7"></a>Bus-specific Device Registration and PCI Support</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="refentrytitle"><a href="API-drm-pci-alloc.html"><span class="phrase">drm_pci_alloc</span></a></span><span class="refpurpose"> — 215 Allocate a PCI consistent memory block, for DMA. 216 </span></dt><dt><span class="refentrytitle"><a href="API-drm-pci-free.html"><span class="phrase">drm_pci_free</span></a></span><span class="refpurpose"> — 217 Free a PCI consistent memory block 218 </span></dt><dt><span class="refentrytitle"><a href="API-drm-get-pci-dev.html"><span class="phrase">drm_get_pci_dev</span></a></span><span class="refpurpose"> — 219 Register a PCI device with the DRM subsystem 220 </span></dt><dt><span class="refentrytitle"><a href="API-drm-pci-init.html"><span class="phrase">drm_pci_init</span></a></span><span class="refpurpose"> — 221 Register matching PCI devices with the DRM subsystem 222 </span></dt><dt><span class="refentrytitle"><a href="API-drm-pci-exit.html"><span class="phrase">drm_pci_exit</span></a></span><span class="refpurpose"> — 223 Unregister matching PCI devices from the DRM subsystem 224 </span></dt><dt><span class="refentrytitle"><a href="API-drm-platform-init.html"><span class="phrase">drm_platform_init</span></a></span><span class="refpurpose"> — 225 Register a platform device with the DRM subsystem 226 </span></dt></dl></div><p> 227 A number of functions are provided to help with device registration. 228 The functions deal with PCI and platform devices respectively and are 229 only provided for historical reasons. These are all deprecated and 230 shouldn't be used in new drivers. Besides that there's a few 231 helpers for pci drivers. 232 </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="drmIntroduction.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="drmCore.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-drm-put-dev.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 1. Introduction </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">drm_put_dev</span></td></tr></table></div></body></html> 233