dcn-overview.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. .. _dcn_overview:
  2. =======================
  3. Display Core Next (DCN)
  4. =======================
  5. To equip our readers with the basic knowledge of how AMD Display Core Next
  6. (DCN) works, we need to start with an overview of the hardware pipeline. Below
  7. you can see a picture that provides a DCN overview, keep in mind that this is a
  8. generic diagram, and we have variations per ASIC.
  9. .. kernel-figure:: dc_pipeline_overview.svg
  10. Based on this diagram, we can pass through each block and briefly describe
  11. them:
  12. * **Display Controller Hub (DCHUB)**: This is the gateway between the Scalable
  13. Data Port (SDP) and DCN. This component has multiple features, such as memory
  14. arbitration, rotation, and cursor manipulation.
  15. * **Display Pipe and Plane (DPP)**: This block provides pre-blend pixel
  16. processing such as color space conversion, linearization of pixel data, tone
  17. mapping, and gamut mapping.
  18. * **Multiple Pipe/Plane Combined (MPC)**: This component performs blending of
  19. multiple planes, using global or per-pixel alpha.
  20. * **Output Pixel Processing (OPP)**: Process and format pixels to be sent to
  21. the display.
  22. * **Output Pipe Timing Combiner (OPTC)**: It generates time output to combine
  23. streams or divide capabilities. CRC values are generated in this block.
  24. * **Display Output (DIO)**: Codify the output to the display connected to our
  25. GPU.
  26. * **Display Writeback (DWB)**: It provides the ability to write the output of
  27. the display pipe back to memory as video frames.
  28. * **Multi-Media HUB (MMHUBBUB)**: Memory controller interface for DMCUB and DWB
  29. (Note that DWB is not hooked yet).
  30. * **DCN Management Unit (DMU)**: It provides registers with access control and
  31. interrupts the controller to the SOC host interrupt unit. This block includes
  32. the Display Micro-Controller Unit - version B (DMCUB), which is handled via
  33. firmware.
  34. * **DCN Clock Generator Block (DCCG)**: It provides the clocks and resets
  35. for all of the display controller clock domains.
  36. * **Azalia (AZ)**: Audio engine.
  37. The above diagram is an architecture generalization of DCN, which means that
  38. every ASIC has variations around this base model. Notice that the display
  39. pipeline is connected to the Scalable Data Port (SDP) via DCHUB; you can see
  40. the SDP as the element from our Data Fabric that feeds the display pipe.
  41. Always approach the DCN architecture as something flexible that can be
  42. configured and reconfigured in multiple ways; in other words, each block can be
  43. setup or ignored accordingly with userspace demands. For example, if we
  44. want to drive an 8k@60Hz with a DSC enabled, our DCN may require 4 DPP and 2
  45. OPP. It is DC's responsibility to drive the best configuration for each
  46. specific scenario. Orchestrate all of these components together requires a
  47. sophisticated communication interface which is highlighted in the diagram by
  48. the edges that connect each block; from the chart, each connection between
  49. these blocks represents:
  50. 1. Pixel data interface (red): Represents the pixel data flow;
  51. 2. Global sync signals (green): It is a set of synchronization signals composed
  52. by VStartup, VUpdate, and VReady;
  53. 3. Config interface: Responsible to configure blocks;
  54. 4. Sideband signals: All other signals that do not fit the previous one.
  55. These signals are essential and play an important role in DCN. Nevertheless,
  56. the Global Sync deserves an extra level of detail described in the next
  57. section.
  58. All of these components are represented by a data structure named dc_state.
  59. From DCHUB to MPC, we have a representation called dc_plane; from MPC to OPTC,
  60. we have dc_stream, and the output (DIO) is handled by dc_link. Keep in mind
  61. that HUBP accesses a surface using a specific format read from memory, and our
  62. dc_plane should work to convert all pixels in the plane to something that can
  63. be sent to the display via dc_stream and dc_link.
  64. Front End and Back End
  65. ----------------------
  66. Display pipeline can be broken down into two components that are usually
  67. referred as **Front End (FE)** and **Back End (BE)**, where FE consists of:
  68. * DCHUB (Mainly referring to a subcomponent named HUBP)
  69. * DPP
  70. * MPC
  71. On the other hand, BE consist of
  72. * OPP
  73. * OPTC
  74. * DIO (DP/HDMI stream encoder and link encoder)
  75. OPP and OPTC are two joining blocks between FE and BE. On a side note, this is
  76. a one-to-one mapping of the link encoder to PHY, but we can configure the DCN
  77. to choose which link encoder to connect to which PHY. FE's main responsibility
  78. is to change, blend and compose pixel data, while BE's job is to frame a
  79. generic pixel stream to a specific display's pixel stream.
  80. Data Flow
  81. ---------
  82. Initially, data is passed in from VRAM through Data Fabric (DF) in native pixel
  83. formats. Such data format stays through till HUBP in DCHUB, where HUBP unpacks
  84. different pixel formats and outputs them to DPP in uniform streams through 4
  85. channels (1 for alpha + 3 for colors).
  86. The Converter and Cursor (CNVC) in DPP would then normalize the data
  87. representation and convert them to a DCN specific floating-point format (i.e.,
  88. different from the IEEE floating-point format). In the process, CNVC also
  89. applies a degamma function to transform the data from non-linear to linear
  90. space to relax the floating-point calculations following. Data would stay in
  91. this floating-point format from DPP to OPP.
  92. Starting OPP, because color transformation and blending have been completed
  93. (i.e alpha can be dropped), and the end sinks do not require the precision and
  94. dynamic range that floating points provide (i.e. all displays are in integer
  95. depth format), bit-depth reduction/dithering would kick in. In OPP, we would
  96. also apply a regamma function to introduce the gamma removed earlier back.
  97. Eventually, we output data in integer format at DIO.
  98. AMD Hardware Pipeline
  99. ---------------------
  100. When discussing graphics on Linux, the **pipeline** term can sometimes be
  101. overloaded with multiple meanings, so it is important to define what we mean
  102. when we say **pipeline**. In the DCN driver, we use the term **hardware
  103. pipeline** or **pipeline** or just **pipe** as an abstraction to indicate a
  104. sequence of DCN blocks instantiated to address some specific configuration. DC
  105. core treats DCN blocks as individual resources, meaning we can build a pipeline
  106. by taking resources for all individual hardware blocks to compose one pipeline.
  107. In actuality, we can't connect an arbitrary block from one pipe to a block from
  108. another pipe; they are routed linearly, except for DSC, which can be
  109. arbitrarily assigned as needed. We have this pipeline concept for trying to
  110. optimize bandwidth utilization.
  111. .. kernel-figure:: pipeline_4k_no_split.svg
  112. Additionally, let's take a look at parts of the DTN log (see
  113. 'Documentation/gpu/amdgpu/display/dc-debug.rst' for more information) since
  114. this log can help us to see part of this pipeline behavior in real-time::
  115. HUBP: format addr_hi width height ...
  116. [ 0]: 8h 81h 3840 2160
  117. [ 1]: 0h 0h 0 0
  118. [ 2]: 0h 0h 0 0
  119. [ 3]: 0h 0h 0 0
  120. [ 4]: 0h 0h 0 0
  121. ...
  122. MPCC: OPP DPP ...
  123. [ 0]: 0h 0h ...
  124. The first thing to notice from the diagram and DTN log it is the fact that we
  125. have different clock domains for each part of the DCN blocks. In this example,
  126. we have just a single **pipeline** where the data flows from DCHUB to DIO, as
  127. we intuitively expect. Nonetheless, DCN is flexible, as mentioned before, and
  128. we can split this single pipe differently, as described in the below diagram:
  129. .. kernel-figure:: pipeline_4k_split.svg
  130. Now, if we inspect the DTN log again we can see some interesting changes::
  131. HUBP: format addr_hi width height ...
  132. [ 0]: 8h 81h 1920 2160 ...
  133. ...
  134. [ 4]: 0h 0h 0 0 ...
  135. [ 5]: 8h 81h 1920 2160 ...
  136. ...
  137. MPCC: OPP DPP ...
  138. [ 0]: 0h 0h ...
  139. [ 5]: 0h 5h ...
  140. From the above example, we now split the display pipeline into two vertical
  141. parts of 1920x2160 (i.e., 3440x2160), and as a result, we could reduce the
  142. clock frequency in the DPP part. This is not only useful for saving power but
  143. also to better handle the required throughput. The idea to keep in mind here is
  144. that the pipe configuration can vary a lot according to the display
  145. configuration, and it is the DML's responsibility to set up all required
  146. configuration parameters for multiple scenarios supported by our hardware.
  147. Global Sync
  148. -----------
  149. Many DCN registers are double buffered, most importantly the surface address.
  150. This allows us to update DCN hardware atomically for page flips, as well as
  151. for most other updates that don't require enabling or disabling of new pipes.
  152. (Note: There are many scenarios when DC will decide to reserve extra pipes
  153. in order to support outputs that need a very high pixel clock, or for
  154. power saving purposes.)
  155. These atomic register updates are driven by global sync signals in DCN. In
  156. order to understand how atomic updates interact with DCN hardware, and how DCN
  157. signals page flip and vblank events it is helpful to understand how global sync
  158. is programmed.
  159. Global sync consists of three signals, VSTARTUP, VUPDATE, and VREADY. These are
  160. calculated by the Display Mode Library - DML (drivers/gpu/drm/amd/display/dc/dml)
  161. based on a large number of parameters and ensure our hardware is able to feed
  162. the DCN pipeline without underflows or hangs in any given system configuration.
  163. The global sync signals always happen during VBlank, are independent from the
  164. VSync signal, and do not overlap each other.
  165. VUPDATE is the only signal that is of interest to the rest of the driver stack
  166. or userspace clients as it signals the point at which hardware latches to
  167. atomically programmed (i.e. double buffered) registers. Even though it is
  168. independent of the VSync signal we use VUPDATE to signal the VSync event as it
  169. provides the best indication of how atomic commits and hardware interact.
  170. Since DCN hardware is double-buffered the DC driver is able to program the
  171. hardware at any point during the frame.
  172. The below picture illustrates the global sync signals:
  173. .. kernel-figure:: global_sync_vblank.svg
  174. These signals affect core DCN behavior. Programming them incorrectly will lead
  175. to a number of negative consequences, most of them quite catastrophic.
  176. The following picture shows how global sync allows for a mailbox style of
  177. updates, i.e. it allows for multiple re-configurations between VUpdate
  178. events where only the last configuration programmed before the VUpdate signal
  179. becomes effective.
  180. .. kernel-figure:: config_example.svg