xref: /linux/Documentation/gpu/amdgpu/driver-core.rst (revision a08d75927f99e57c793f3a5d11260c22893fc0e9)
1c08d2f8bSYann Dirson============================
2c08d2f8bSYann Dirson Core Driver Infrastructure
3c08d2f8bSYann Dirson============================
4c08d2f8bSYann Dirson
5d59f1774SYann DirsonGPU Hardware Structure
6d59f1774SYann Dirson======================
7d59f1774SYann Dirson
8d59f1774SYann DirsonEach ASIC is a collection of hardware blocks.  We refer to them as
9d59f1774SYann Dirson"IPs" (Intellectual Property blocks).  Each IP encapsulates certain
10d59f1774SYann Dirsonfunctionality. IPs are versioned and can also be mixed and matched.
11d59f1774SYann DirsonE.g., you might have two different ASICs that both have System DMA (SDMA) 5.x IPs.
12d59f1774SYann DirsonThe driver is arranged by IPs.  There are driver components to handle
13d59f1774SYann Dirsonthe initialization and operation of each IP.  There are also a bunch
14d59f1774SYann Dirsonof smaller IPs that don't really need much if any driver interaction.
15d59f1774SYann DirsonThose end up getting lumped into the common stuff in the soc files.
16d59f1774SYann DirsonThe soc files (e.g., vi.c, soc15.c nv.c) contain code for aspects of
17d59f1774SYann Dirsonthe SoC itself rather than specific IPs.  E.g., things like GPU resets
18d59f1774SYann Dirsonand register access functions are SoC dependent.
19d59f1774SYann Dirson
20d59f1774SYann DirsonAn APU contains more than just CPU and GPU, it also contains all of
21d59f1774SYann Dirsonthe platform stuff (audio, usb, gpio, etc.).  Also, a lot of
22d59f1774SYann Dirsoncomponents are shared between the CPU, platform, and the GPU (e.g.,
23d59f1774SYann DirsonSMU, PSP, etc.).  Specific components (CPU, GPU, etc.) usually have
24d59f1774SYann Dirsontheir interface to interact with those common components.  For things
25d59f1774SYann Dirsonlike S0i3 there is a ton of coordination required across all the
26d59f1774SYann Dirsoncomponents, but that is probably a bit beyond the scope of this
27d59f1774SYann Dirsonsection.
28d59f1774SYann Dirson
29d59f1774SYann DirsonWith respect to the GPU, we have the following major IPs:
30d59f1774SYann Dirson
31d59f1774SYann DirsonGMC (Graphics Memory Controller)
32d59f1774SYann Dirson    This was a dedicated IP on older pre-vega chips, but has since
33d59f1774SYann Dirson    become somewhat decentralized on vega and newer chips.  They now
34d59f1774SYann Dirson    have dedicated memory hubs for specific IPs or groups of IPs.  We
35d59f1774SYann Dirson    still treat it as a single component in the driver however since
36d59f1774SYann Dirson    the programming model is still pretty similar.  This is how the
37d59f1774SYann Dirson    different IPs on the GPU get the memory (VRAM or system memory).
38d59f1774SYann Dirson    It also provides the support for per process GPU virtual address
39d59f1774SYann Dirson    spaces.
40d59f1774SYann Dirson
41d59f1774SYann DirsonIH (Interrupt Handler)
42d59f1774SYann Dirson    This is the interrupt controller on the GPU.  All of the IPs feed
43d59f1774SYann Dirson    their interrupts into this IP and it aggregates them into a set of
44d59f1774SYann Dirson    ring buffers that the driver can parse to handle interrupts from
45d59f1774SYann Dirson    different IPs.
46d59f1774SYann Dirson
47d59f1774SYann DirsonPSP (Platform Security Processor)
48d59f1774SYann Dirson    This handles security policy for the SoC and executes trusted
49d59f1774SYann Dirson    applications, and validates and loads firmwares for other blocks.
50d59f1774SYann Dirson
51d59f1774SYann DirsonSMU (System Management Unit)
52d59f1774SYann Dirson    This is the power management microcontroller.  It manages the entire
53d59f1774SYann Dirson    SoC.  The driver interacts with it to control power management
54d59f1774SYann Dirson    features like clocks, voltages, power rails, etc.
55d59f1774SYann Dirson
56d59f1774SYann DirsonDCN (Display Controller Next)
57d59f1774SYann Dirson    This is the display controller.  It handles the display hardware.
58d59f1774SYann Dirson    It is described in more details in :ref:`Display Core <amdgpu-display-core>`.
59d59f1774SYann Dirson
60d59f1774SYann DirsonSDMA (System DMA)
61d59f1774SYann Dirson    This is a multi-purpose DMA engine.  The kernel driver uses it for
62d59f1774SYann Dirson    various things including paging and GPU page table updates.  It's also
63d59f1774SYann Dirson    exposed to userspace for use by user mode drivers (OpenGL, Vulkan,
64d59f1774SYann Dirson    etc.)
65d59f1774SYann Dirson
66d59f1774SYann DirsonGC (Graphics and Compute)
67d59f1774SYann Dirson    This is the graphics and compute engine, i.e., the block that
68d59f1774SYann Dirson    encompasses the 3D pipeline and and shader blocks.  This is by far the
69d59f1774SYann Dirson    largest block on the GPU.  The 3D pipeline has tons of sub-blocks.  In
70d59f1774SYann Dirson    addition to that, it also contains the CP microcontrollers (ME, PFP,
71d59f1774SYann Dirson    CE, MEC) and the RLC microcontroller.  It's exposed to userspace for
72d59f1774SYann Dirson    user mode drivers (OpenGL, Vulkan, OpenCL, etc.)
73d59f1774SYann Dirson
74d59f1774SYann DirsonVCN (Video Core Next)
75d59f1774SYann Dirson    This is the multi-media engine.  It handles video and image encode and
76d59f1774SYann Dirson    decode.  It's exposed to userspace for user mode drivers (VA-API,
77d59f1774SYann Dirson    OpenMAX, etc.)
78d59f1774SYann Dirson
7919cd8c8bSYann DirsonGraphics and Compute Microcontrollers
8019cd8c8bSYann Dirson-------------------------------------
8119cd8c8bSYann Dirson
8219cd8c8bSYann DirsonCP (Command Processor)
8319cd8c8bSYann Dirson    The name for the hardware block that encompasses the front end of the
8419cd8c8bSYann Dirson    GFX/Compute pipeline.  Consists mainly of a bunch of microcontrollers
8519cd8c8bSYann Dirson    (PFP, ME, CE, MEC).  The firmware that runs on these microcontrollers
8619cd8c8bSYann Dirson    provides the driver interface to interact with the GFX/Compute engine.
8719cd8c8bSYann Dirson
8819cd8c8bSYann Dirson    MEC (MicroEngine Compute)
8919cd8c8bSYann Dirson        This is the microcontroller that controls the compute queues on the
9019cd8c8bSYann Dirson        GFX/compute engine.
9119cd8c8bSYann Dirson
9219cd8c8bSYann Dirson    MES (MicroEngine Scheduler)
9319cd8c8bSYann Dirson        This is a new engine for managing queues.  This is currently unused.
9419cd8c8bSYann Dirson
9519cd8c8bSYann DirsonRLC (RunList Controller)
9619cd8c8bSYann Dirson    This is another microcontroller in the GFX/Compute engine.  It handles
9719cd8c8bSYann Dirson    power management related functionality within the GFX/Compute engine.
9819cd8c8bSYann Dirson    The name is a vestige of old hardware where it was originally added
9919cd8c8bSYann Dirson    and doesn't really have much relation to what the engine does now.
10019cd8c8bSYann Dirson
101d59f1774SYann DirsonDriver Structure
102d59f1774SYann Dirson================
103d59f1774SYann Dirson
104d59f1774SYann DirsonIn general, the driver has a list of all of the IPs on a particular
105d59f1774SYann DirsonSoC and for things like init/fini/suspend/resume, more or less just
106d59f1774SYann Dirsonwalks the list and handles each IP.
107d59f1774SYann Dirson
10819cd8c8bSYann DirsonSome useful constructs:
10919cd8c8bSYann Dirson
11019cd8c8bSYann DirsonKIQ (Kernel Interface Queue)
11119cd8c8bSYann Dirson    This is a control queue used by the kernel driver to manage other gfx
11219cd8c8bSYann Dirson    and compute queues on the GFX/compute engine.  You can use it to
11319cd8c8bSYann Dirson    map/unmap additional queues, etc.
11419cd8c8bSYann Dirson
11519cd8c8bSYann DirsonIB (Indirect Buffer)
11619cd8c8bSYann Dirson    A command buffer for a particular engine.  Rather than writing
11719cd8c8bSYann Dirson    commands directly to the queue, you can write the commands into a
11819cd8c8bSYann Dirson    piece of memory and then put a pointer to the memory into the queue.
11919cd8c8bSYann Dirson    The hardware will then follow the pointer and execute the commands in
12019cd8c8bSYann Dirson    the memory, then returning to the rest of the commands in the ring.
121d59f1774SYann Dirson
122c08d2f8bSYann Dirson.. _amdgpu_memory_domains:
123c08d2f8bSYann Dirson
124c08d2f8bSYann DirsonMemory Domains
125c08d2f8bSYann Dirson==============
126c08d2f8bSYann Dirson
127c08d2f8bSYann Dirson.. kernel-doc:: include/uapi/drm/amdgpu_drm.h
128c08d2f8bSYann Dirson   :doc: memory domains
129c08d2f8bSYann Dirson
130c08d2f8bSYann DirsonBuffer Objects
131c08d2f8bSYann Dirson==============
132c08d2f8bSYann Dirson
133c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
134c08d2f8bSYann Dirson   :doc: amdgpu_object
135c08d2f8bSYann Dirson
136c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
137c08d2f8bSYann Dirson   :internal:
138c08d2f8bSYann Dirson
139c08d2f8bSYann DirsonPRIME Buffer Sharing
140c08d2f8bSYann Dirson====================
141c08d2f8bSYann Dirson
142c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
143c08d2f8bSYann Dirson   :doc: PRIME Buffer Sharing
144c08d2f8bSYann Dirson
145c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
146c08d2f8bSYann Dirson   :internal:
147c08d2f8bSYann Dirson
148c08d2f8bSYann DirsonMMU Notifier
149c08d2f8bSYann Dirson============
150c08d2f8bSYann Dirson
1513d271e2eSRandy Dunlap.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
152c08d2f8bSYann Dirson   :doc: MMU Notifier
153c08d2f8bSYann Dirson
1543d271e2eSRandy Dunlap.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
155c08d2f8bSYann Dirson   :internal:
156c08d2f8bSYann Dirson
157c08d2f8bSYann DirsonAMDGPU Virtual Memory
158c08d2f8bSYann Dirson=====================
159c08d2f8bSYann Dirson
160c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
161c08d2f8bSYann Dirson   :doc: GPUVM
162c08d2f8bSYann Dirson
163c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
164c08d2f8bSYann Dirson   :internal:
165c08d2f8bSYann Dirson
166c08d2f8bSYann DirsonInterrupt Handling
167c08d2f8bSYann Dirson==================
168c08d2f8bSYann Dirson
169c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
170c08d2f8bSYann Dirson   :doc: Interrupt Handling
171c08d2f8bSYann Dirson
172c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
173c08d2f8bSYann Dirson   :internal:
174c08d2f8bSYann Dirson
175c08d2f8bSYann DirsonIP Blocks
176c08d2f8bSYann Dirson=========
177c08d2f8bSYann Dirson
178c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/include/amd_shared.h
179c08d2f8bSYann Dirson   :doc: IP Blocks
180c08d2f8bSYann Dirson
181c08d2f8bSYann Dirson.. kernel-doc:: drivers/gpu/drm/amd/include/amd_shared.h
182*a08d7592SLeo Li   :identifiers: amd_ip_block_type amd_ip_funcs DC_DEBUG_MASK
183