dc-debug.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. ========================
  2. Display Core Debug tools
  3. ========================
  4. In this section, you will find helpful information on debugging the amdgpu
  5. driver from the display perspective. This page introduces debug mechanisms and
  6. procedures to help you identify if some issues are related to display code.
  7. Narrow down display issues
  8. ==========================
  9. Since the display is the driver's visual component, it is common to see users
  10. reporting issues as a display when another component causes the problem. This
  11. section equips users to determine if a specific issue was caused by the display
  12. component or another part of the driver.
  13. DC dmesg important messages
  14. ---------------------------
  15. The dmesg log is the first source of information to be checked, and amdgpu
  16. takes advantage of this feature by logging some valuable information. When
  17. looking for the issues associated with amdgpu, remember that each component of
  18. the driver (e.g., smu, PSP, dm, etc.) is loaded one by one, and this
  19. information can be found in the dmesg log. In this sense, look for the part of
  20. the log that looks like the below log snippet::
  21. [ 4.254295] [drm] initializing kernel modesetting (IP DISCOVERY 0x1002:0x744C 0x1002:0x0E3B 0xC8).
  22. [ 4.254718] [drm] register mmio base: 0xFCB00000
  23. [ 4.254918] [drm] register mmio size: 1048576
  24. [ 4.260095] [drm] add ip block number 0 <soc21_common>
  25. [ 4.260318] [drm] add ip block number 1 <gmc_v11_0>
  26. [ 4.260510] [drm] add ip block number 2 <ih_v6_0>
  27. [ 4.260696] [drm] add ip block number 3 <psp>
  28. [ 4.260878] [drm] add ip block number 4 <smu>
  29. [ 4.261057] [drm] add ip block number 5 <dm>
  30. [ 4.261231] [drm] add ip block number 6 <gfx_v11_0>
  31. [ 4.261402] [drm] add ip block number 7 <sdma_v6_0>
  32. [ 4.261568] [drm] add ip block number 8 <vcn_v4_0>
  33. [ 4.261729] [drm] add ip block number 9 <jpeg_v4_0>
  34. [ 4.261887] [drm] add ip block number 10 <mes_v11_0>
  35. From the above example, you can see the line that reports that `<dm>`,
  36. (**Display Manager**), was loaded, which means that display can be part of the
  37. issue. If you do not see that line, something else might have failed before
  38. amdgpu loads the display component, indicating that we don't have a
  39. display issue.
  40. After you identified that the DM was loaded correctly, you can check for the
  41. display version of the hardware in use, which can be retrieved from the dmesg
  42. log with the command::
  43. dmesg | grep -i 'display core'
  44. This command shows a message that looks like this::
  45. [ 4.655828] [drm] Display Core v3.2.285 initialized on DCN 3.2
  46. This message has two key pieces of information:
  47. * **The DC version (e.g., v3.2.285)**: Display developers release a new DC version
  48. every week, and this information can be advantageous in a situation where a
  49. user/developer must find a good point versus a bad point based on a tested
  50. version of the display code. Remember from page :ref:`Display Core <amdgpu-display-core>`,
  51. that every week the new patches for display are heavily tested with IGT and
  52. manual tests.
  53. * **The DCN version (e.g., DCN 3.2)**: The DCN block is associated with the
  54. hardware generation, and the DCN version conveys the hardware generation that
  55. the driver is currently running. This information helps to narrow down the
  56. code debug area since each DCN version has its files in the DC folder per DCN
  57. component (from the example, the developer might want to focus on
  58. files/folders/functions/structs with the dcn32 label might be executed).
  59. However, keep in mind that DC reuses code across different DCN versions; for
  60. example, it is expected to have some callbacks set in one DCN that are the same
  61. as those from another DCN. In summary, use the DCN version just as a guide.
  62. From the dmesg file, it is also possible to get the ATOM bios code by using::
  63. dmesg | grep -i 'ATOM BIOS'
  64. Which generates an output that looks like this::
  65. [ 4.274534] amdgpu: ATOM BIOS: 113-D7020100-102
  66. This type of information is useful to be reported.
  67. Avoid loading display core
  68. --------------------------
  69. Sometimes, it might be hard to figure out which part of the driver is causing
  70. the issue; if you suspect that the display is not part of the problem and your
  71. bug scenario is simple (e.g., some desktop configuration) you can try to remove
  72. the display component from the equation. First, you need to identify `dm` ID
  73. from the dmesg log; for example, search for the following log::
  74. [ 4.254295] [drm] initializing kernel modesetting (IP DISCOVERY 0x1002:0x744C 0x1002:0x0E3B 0xC8).
  75. [..]
  76. [ 4.260095] [drm] add ip block number 0 <soc21_common>
  77. [ 4.260318] [drm] add ip block number 1 <gmc_v11_0>
  78. [..]
  79. [ 4.261057] [drm] add ip block number 5 <dm>
  80. Notice from the above example that the `dm` id is 5 for this specific hardware.
  81. Next, you need to run the following binary operation to identify the IP block
  82. mask::
  83. 0xffffffff & ~(1 << [DM ID])
  84. From our example the IP mask is::
  85. 0xffffffff & ~(1 << 5) = 0xffffffdf
  86. Finally, to disable DC, you just need to set the below parameter in your
  87. bootloader::
  88. amdgpu.ip_block_mask = 0xffffffdf
  89. If you can boot your system with the DC disabled and still see the issue, it
  90. means you can rule DC out of the equation. However, if the bug disappears, you
  91. still need to consider the DC part of the problem and keep narrowing down the
  92. issue. In some scenarios, disabling DC is impossible since it might be
  93. necessary to use the display component to reproduce the issue (e.g., play a
  94. game).
  95. **Note: This will probably lead to the absence of a display output.**
  96. Display flickering
  97. ------------------
  98. Display flickering might have multiple causes; one is the lack of proper power
  99. to the GPU or problems in the DPM switches. A good first generic verification
  100. is to set the GPU to use high voltage::
  101. bash -c "echo high > /sys/class/drm/card0/device/power_dpm_force_performance_level"
  102. The above command sets the GPU/APU to use the maximum power allowed which
  103. disables DPM switches. If forcing DPM levels high does not fix the issue, it
  104. is less likely that the issue is related to power management. If the issue
  105. disappears, there is a good chance that other components might be involved, and
  106. the display should not be ignored since this could be a DPM issues. From the
  107. display side, if the power increase fixes the issue, it is worth debugging the
  108. clock configuration and the pipe split police used in the specific
  109. configuration.
  110. Display artifacts
  111. -----------------
  112. Users may see some screen artifacts that can be categorized into two different
  113. types: localized artifacts and general artifacts. The localized artifacts
  114. happen in some specific areas, such as around the UI window corners; if you see
  115. this type of issue, there is a considerable chance that you have a userspace
  116. problem, likely Mesa or similar. The general artifacts usually happen on the
  117. entire screen. They might be caused by a misconfiguration at the driver level
  118. of the display parameters, but the userspace might also cause this issue. One
  119. way to identify the source of the problem is to take a screenshot or make a
  120. desktop video capture when the problem happens; after checking the
  121. screenshot/video recording, if you don't see any of the artifacts, it means
  122. that the issue is likely on the driver side. If you can still see the
  123. problem in the data collected, it is an issue that probably happened during
  124. rendering, and the display code just got the framebuffer already corrupted.
  125. Disabling/Enabling specific features
  126. ====================================
  127. DC has a struct named `dc_debug_options`, which is statically initialized by
  128. all DCE/DCN components based on the specific hardware characteristic. This
  129. structure usually facilitates the bring-up phase since developers can start
  130. with many disabled features and enable them individually. This is also an
  131. important debug feature since users can change it when debugging specific
  132. issues.
  133. For example, dGPU users sometimes see a problem where a horizontal fillet of
  134. flickering happens in some specific part of the screen. This could be an
  135. indication of Sub-Viewport issues; after the users identified the target DCN,
  136. they can set the `force_disable_subvp` field to true in the statically
  137. initialized version of `dc_debug_options` to see if the issue gets fixed. Along
  138. the same lines, users/developers can also try to turn off `fams2_config` and
  139. `enable_single_display_2to1_odm_policy`. In summary, the `dc_debug_options` is
  140. an interesting form for identifying the problem.
  141. DC Visual Confirmation
  142. ======================
  143. Display core provides a feature named visual confirmation, which is a set of
  144. bars added at the scanout time by the driver to convey some specific
  145. information. In general, you can enable this debug option by using::
  146. echo <N> > /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm
  147. Where `N` is an integer number for some specific scenarios that the developer
  148. wants to enable, you will see some of these debug cases in the following
  149. subsection.
  150. Multiple Planes Debug
  151. ---------------------
  152. If you want to enable or debug multiple planes in a specific user-space
  153. application, you can leverage a debug feature named visual confirm. For
  154. enabling it, you will need::
  155. echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm
  156. You need to reload your GUI to see the visual confirmation. When the plane
  157. configuration changes or a full update occurs there will be a colored bar at
  158. the bottom of each hardware plane being drawn on the screen.
  159. * The color indicates the format - For example, red is AR24 and green is NV12
  160. * The height of the bar indicates the index of the plane
  161. * Pipe split can be observed if there are two bars with a difference in height
  162. covering the same plane
  163. Consider the video playback case in which a video is played in a specific
  164. plane, and the desktop is drawn in another plane. The video plane should
  165. feature one or two green bars at the bottom of the video depending on pipe
  166. split configuration.
  167. * There should **not** be any visual corruption
  168. * There should **not** be any underflow or screen flashes
  169. * There should **not** be any black screens
  170. * There should **not** be any cursor corruption
  171. * Multiple plane **may** be briefly disabled during window transitions or
  172. resizing but should come back after the action has finished
  173. Pipe Split Debug
  174. ----------------
  175. Sometimes we need to debug if DCN is splitting pipes correctly, and visual
  176. confirmation is also handy for this case. Similar to the MPO case, you can use
  177. the below command to enable visual confirmation::
  178. echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_visual_confirm
  179. In this case, if you have a pipe split, you will see one small red bar at the
  180. bottom of the display covering the entire display width and another bar
  181. covering the second pipe. In other words, you will see a bit high bar in the
  182. second pipe.
  183. DTN Debug
  184. =========
  185. DC (DCN) provides an extensive log that dumps multiple details from our
  186. hardware configuration. Via debugfs, you can capture those status values by
  187. using Display Test Next (DTN) log, which can be captured via debugfs by using::
  188. cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
  189. Since this log is updated accordingly with DCN status, you can also follow the
  190. change in real-time by using something like::
  191. sudo watch -d cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
  192. When reporting a bug related to DC, consider attaching this log before and
  193. after you reproduce the bug.
  194. Collect Firmware information
  195. ============================
  196. When reporting issues, it is important to have the firmware information since
  197. it can be helpful for debugging purposes. To get all the firmware information,
  198. use the command::
  199. cat /sys/kernel/debug/dri/0/amdgpu_firmware_info
  200. From the display perspective, pay attention to the firmware of the DMCU and
  201. DMCUB.
  202. DMUB Firmware Debug
  203. ===================
  204. Sometimes, dmesg logs aren't enough. This is especially true if a feature is
  205. implemented primarily in DMUB firmware. In such cases, all we see in dmesg when
  206. an issue arises is some generic timeout error. So, to get more relevant
  207. information, we can trace DMUB commands by enabling the relevant bits in
  208. `amdgpu_dm_dmub_trace_mask`.
  209. Currently, we support the tracing of the following groups:
  210. Trace Groups
  211. ------------
  212. .. csv-table::
  213. :header-rows: 1
  214. :widths: 1, 1
  215. :file: ./trace-groups-table.csv
  216. **Note: Not all ASICs support all of the listed trace groups**
  217. So, to enable just PSR tracing you can use the following command::
  218. # echo 0x8020 > /sys/kernel/debug/dri/0/amdgpu_dm_dmub_trace_mask
  219. Then, you need to enable logging trace events to the buffer, which you can do
  220. using the following::
  221. # echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en
  222. Lastly, after you are able to reproduce the issue you are trying to debug,
  223. you can disable tracing and read the trace log by using the following::
  224. # echo 0 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en
  225. # cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_tracebuffer
  226. So, when reporting bugs related to features such as PSR and ABM, consider
  227. enabling the relevant bits in the mask before reproducing the issue and
  228. attach the log that you obtain from the trace buffer in any bug reports that you
  229. create.