adreno_gen7_snapshot.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_GEN7_SNAPSHOT_H
  7. #define __ADRENO_GEN7_SNAPSHOT_H
  8. #include "adreno.h"
  9. #include "adreno_gen7.h"
  10. #include "kgsl_regmap.h"
  11. #define CLUSTER_NONE 0
  12. #define CLUSTER_FE 1
  13. #define CLUSTER_SP_VS 2
  14. #define CLUSTER_PC_VS 3
  15. #define CLUSTER_GRAS 4
  16. #define CLUSTER_SP_PS 5
  17. #define CLUSTER_VPC_PS 6
  18. #define CLUSTER_PS 7
  19. #define HLSQ_STATE 0
  20. #define HLSQ_DP 1
  21. #define SP_TOP 2
  22. #define USPTP 3
  23. #define HLSQ_DP_STR 4
  24. #define STATE_NON_CONTEXT 0
  25. #define STATE_TOGGLE_CTXT 1
  26. #define STATE_FORCE_CTXT_0 2
  27. #define STATE_FORCE_CTXT_1 3
  28. #define GEN7_DEBUGBUS_BLOCK_SIZE 0x100
  29. /* Number of dword to dump in snapshot for CP SQE */
  30. #define GEN7_SQE_FW_SNAPSHOT_DWORDS 5
  31. struct gen7_sel_reg {
  32. unsigned int host_reg;
  33. unsigned int cd_reg;
  34. unsigned int val;
  35. };
  36. struct gen7_sptp_cluster_registers {
  37. /* cluster_id: Cluster identifier */
  38. int cluster_id;
  39. /* statetype: SP block state type for the cluster */
  40. int statetype;
  41. /* pipe_id: Pipe identifier */
  42. int pipe_id;
  43. /* context_id: Context identifier */
  44. int context_id;
  45. /* location_id: Location identifier */
  46. int location_id;
  47. /* regs: Pointer to the list of register pairs to read */
  48. const u32 *regs;
  49. /* regbase: Dword offset of the register block in the GPu register space */
  50. unsigned int regbase;
  51. /* offset: Internal variable used to track the crashdump state */
  52. unsigned int offset;
  53. };
  54. struct gen7_shader_block {
  55. /* statetype: Type identifer for the block */
  56. u32 statetype;
  57. /* size: Size of the block (in dwords) */
  58. u32 size;
  59. /* num_sps: The SP id to dump */
  60. u32 num_sps;
  61. /* num_usptps: The number of USPTPs to dump */;
  62. u32 num_usptps;
  63. /* pipe_id: Pipe identifier for the block data */
  64. u32 pipeid;
  65. /* location: Location identifer for the block data */
  66. u32 location;
  67. /* offset: The offset in the snasphot dump */
  68. u64 offset;
  69. };
  70. struct gen7_shader_block_info {
  71. struct gen7_shader_block *block;
  72. unsigned int sp_id;
  73. unsigned int usptp;
  74. u32 bank;
  75. u64 offset;
  76. };
  77. struct gen7_reg_list {
  78. const u32 *regs;
  79. const struct gen7_sel_reg *sel;
  80. u64 offset;
  81. };
  82. struct gen7_cp_indexed_reg {
  83. u32 addr;
  84. u32 data;
  85. u32 size;
  86. };
  87. struct gen7_cluster_registers {
  88. /* cluster_id: Cluster identifier */
  89. int cluster_id;
  90. /* pipe_id: Pipe Identifier */
  91. int pipe_id;
  92. /* context_id: one of STATE_ that identifies the context to dump */
  93. int context_id;
  94. /* regs: Pointer to an array of register pairs */
  95. const u32 *regs;
  96. /* sel: Pointer to a selector register to write before reading */
  97. const struct gen7_sel_reg *sel;
  98. /* offset: Internal variable to track the state of the crashdump */
  99. unsigned int offset;
  100. };
  101. struct gen7_snapshot_block_list {
  102. /* pre_crashdumper_regs : Registers which need to be dumped before CD runs */
  103. const u32 *pre_crashdumper_regs;
  104. /* debugbus_blocks : List of debugbus blocks */
  105. const u32 *debugbus_blocks;
  106. /* debugbus_blocks_len : Length of the debugbus list */
  107. size_t debugbus_blocks_len;
  108. /* gbif_debugbus_blocks : List of GBIF debugbus blocks */
  109. const u32 *gbif_debugbus_blocks;
  110. /* gbif_debugbus_blocks_len : Length of GBIF debugbus list */
  111. size_t gbif_debugbus_blocks_len;
  112. /* cx_debugbus_blocks : List of CX debugbus blocks */
  113. const u32 *cx_debugbus_blocks;
  114. /* cx_debugbus_blocks_len : Length of the CX debugbus list */
  115. size_t cx_debugbus_blocks_len;
  116. /* external_core_regs : List of external core registers */
  117. const u32 **external_core_regs;
  118. /* num_external_core_regs : length of external core registers list */
  119. size_t num_external_core_regs;
  120. /* gmu_regs : List of GMU registers */
  121. const u32 *gmu_regs;
  122. /* gmu_gx_regs : List of GMU GX registers */
  123. const u32 *gmu_gx_regs;
  124. /* rscc_regs : List of RSCC registers */
  125. const u32 *rscc_regs;
  126. /* reg_list : List of GPU internal registers */
  127. struct gen7_reg_list *reg_list;
  128. /* reg_list : List of cx_misc registers */
  129. const u32 *cx_misc_regs;
  130. /* shader_blocks : List of GPU shader memory */
  131. struct gen7_shader_block *shader_blocks;
  132. /* num_shader_blocks : Length of the shader memory list */
  133. size_t num_shader_blocks;
  134. /* cluster_registers : List of GPU cluster registers */
  135. struct gen7_cluster_registers *clusters;
  136. /* num_clusters : Length of GPU cluster registers list */
  137. size_t num_clusters;
  138. /* spstp_cluster_registers : List of GPU SPTP cluster registers */
  139. struct gen7_sptp_cluster_registers *sptp_clusters;
  140. /* num_sptp_clusters : Length of GPU SPTP cluster registers list */
  141. size_t num_sptp_clusters;
  142. /* post_crashdumper_regs : Registers which need to be dumped after CD runs */
  143. const u32 *post_crashdumper_regs;
  144. /* index_registers : List of index_registers */
  145. struct gen7_cp_indexed_reg *index_registers;
  146. /* index_registers_len : Length of the index registers */
  147. size_t index_registers_len;
  148. };
  149. struct gen7_trace_buffer_info {
  150. u16 dbgc_ctrl;
  151. u16 segment;
  152. u16 granularity;
  153. u16 ping_blk[TRACE_BUF_NUM_SIG];
  154. u16 ping_idx[TRACE_BUF_NUM_SIG];
  155. };
  156. enum gen7_debugbus_ids {
  157. DEBUGBUS_CP_0_0 = 1,
  158. DEBUGBUS_CP_0_1 = 2,
  159. DEBUGBUS_RBBM = 3,
  160. DEBUGBUS_GBIF_GX = 5,
  161. DEBUGBUS_GBIF_CX = 6,
  162. DEBUGBUS_HLSQ = 7,
  163. DEBUGBUS_UCHE_0 = 9,
  164. DEBUGBUS_UCHE_1 = 10,
  165. DEBUGBUS_TESS_BR = 13,
  166. DEBUGBUS_TESS_BV = 14,
  167. DEBUGBUS_PC_BR = 17,
  168. DEBUGBUS_PC_BV = 18,
  169. DEBUGBUS_VFDP_BR = 21,
  170. DEBUGBUS_VFDP_BV = 22,
  171. DEBUGBUS_VPC_BR = 25,
  172. DEBUGBUS_VPC_BV = 26,
  173. DEBUGBUS_TSE_BR = 29,
  174. DEBUGBUS_TSE_BV = 30,
  175. DEBUGBUS_RAS_BR = 33,
  176. DEBUGBUS_RAS_BV = 34,
  177. DEBUGBUS_VSC = 37,
  178. DEBUGBUS_COM_0 = 39,
  179. DEBUGBUS_LRZ_BR = 43,
  180. DEBUGBUS_LRZ_BV = 44,
  181. DEBUGBUS_UFC_0 = 47,
  182. DEBUGBUS_UFC_1 = 48,
  183. DEBUGBUS_GMU_GX = 55,
  184. DEBUGBUS_DBGC = 59,
  185. DEBUGBUS_CX = 60,
  186. DEBUGBUS_GMU_CX = 61,
  187. DEBUGBUS_GPC_BR = 62,
  188. DEBUGBUS_GPC_BV = 63,
  189. DEBUGBUS_LARC = 66,
  190. DEBUGBUS_HLSQ_SPTP = 68,
  191. DEBUGBUS_RB_0 = 70,
  192. DEBUGBUS_RB_1 = 71,
  193. DEBUGBUS_RB_2 = 72,
  194. DEBUGBUS_RB_3 = 73,
  195. DEBUGBUS_RB_4 = 74,
  196. DEBUGBUS_RB_5 = 75,
  197. DEBUGBUS_UCHE_WRAPPER = 102,
  198. DEBUGBUS_CCU_0 = 106,
  199. DEBUGBUS_CCU_1 = 107,
  200. DEBUGBUS_CCU_2 = 108,
  201. DEBUGBUS_CCU_3 = 109,
  202. DEBUGBUS_CCU_4 = 110,
  203. DEBUGBUS_CCU_5 = 111,
  204. DEBUGBUS_VFD_BR_0 = 138,
  205. DEBUGBUS_VFD_BR_1 = 139,
  206. DEBUGBUS_VFD_BR_2 = 140,
  207. DEBUGBUS_VFD_BR_3 = 141,
  208. DEBUGBUS_VFD_BR_4 = 142,
  209. DEBUGBUS_VFD_BR_5 = 143,
  210. DEBUGBUS_VFD_BR_6 = 144,
  211. DEBUGBUS_VFD_BR_7 = 145,
  212. DEBUGBUS_VFD_BV_0 = 202,
  213. DEBUGBUS_VFD_BV_1 = 203,
  214. DEBUGBUS_VFD_BV_2 = 204,
  215. DEBUGBUS_VFD_BV_3 = 205,
  216. DEBUGBUS_USP_0 = 234,
  217. DEBUGBUS_USP_1 = 235,
  218. DEBUGBUS_USP_2 = 236,
  219. DEBUGBUS_USP_3 = 237,
  220. DEBUGBUS_USP_4 = 238,
  221. DEBUGBUS_USP_5 = 239,
  222. DEBUGBUS_TP_0 = 266,
  223. DEBUGBUS_TP_1 = 267,
  224. DEBUGBUS_TP_2 = 268,
  225. DEBUGBUS_TP_3 = 269,
  226. DEBUGBUS_TP_4 = 270,
  227. DEBUGBUS_TP_5 = 271,
  228. DEBUGBUS_TP_6 = 272,
  229. DEBUGBUS_TP_7 = 273,
  230. DEBUGBUS_TP_8 = 274,
  231. DEBUGBUS_TP_9 = 275,
  232. DEBUGBUS_TP_10 = 276,
  233. DEBUGBUS_TP_11 = 277,
  234. DEBUGBUS_USPTP_0 = 330,
  235. DEBUGBUS_USPTP_1 = 331,
  236. DEBUGBUS_USPTP_2 = 332,
  237. DEBUGBUS_USPTP_3 = 333,
  238. DEBUGBUS_USPTP_4 = 334,
  239. DEBUGBUS_USPTP_5 = 335,
  240. DEBUGBUS_USPTP_6 = 336,
  241. DEBUGBUS_USPTP_7 = 337,
  242. DEBUGBUS_USPTP_8 = 338,
  243. DEBUGBUS_USPTP_9 = 339,
  244. DEBUGBUS_USPTP_10 = 340,
  245. DEBUGBUS_USPTP_11 = 341,
  246. DEBUGBUS_CCHE_0 = 396,
  247. DEBUGBUS_CCHE_1 = 397,
  248. DEBUGBUS_CCHE_2 = 398,
  249. DEBUGBUS_VPC_DSTR_0 = 408,
  250. DEBUGBUS_VPC_DSTR_1 = 409,
  251. DEBUGBUS_VPC_DSTR_2 = 410,
  252. DEBUGBUS_HLSQ_DP_STR_0 = 411,
  253. DEBUGBUS_HLSQ_DP_STR_1 = 412,
  254. DEBUGBUS_HLSQ_DP_STR_2 = 413,
  255. DEBUGBUS_HLSQ_DP_STR_3 = 414,
  256. DEBUGBUS_HLSQ_DP_STR_4 = 415,
  257. DEBUGBUS_HLSQ_DP_STR_5 = 416,
  258. DEBUGBUS_UFC_DSTR_0 = 443,
  259. DEBUGBUS_UFC_DSTR_1 = 444,
  260. DEBUGBUS_UFC_DSTR_2 = 445,
  261. DEBUGBUS_CGC_SUBCORE = 446,
  262. DEBUGBUS_CGC_CORE = 447,
  263. };
  264. static const u32 gen7_gbif_debugbus_blocks[] = {
  265. DEBUGBUS_GBIF_CX,
  266. DEBUGBUS_GBIF_GX,
  267. };
  268. static const u32 gen7_cx_dbgc_debugbus_blocks[] = {
  269. DEBUGBUS_GMU_CX,
  270. DEBUGBUS_CX,
  271. DEBUGBUS_GBIF_CX,
  272. };
  273. enum gen7_statetype_ids {
  274. TP0_NCTX_REG = 0,
  275. TP0_CTX0_3D_CVS_REG = 1,
  276. TP0_CTX0_3D_CPS_REG = 2,
  277. TP0_CTX1_3D_CVS_REG = 3,
  278. TP0_CTX1_3D_CPS_REG = 4,
  279. TP0_CTX2_3D_CPS_REG = 5,
  280. TP0_CTX3_3D_CPS_REG = 6,
  281. TP0_TMO_DATA = 9,
  282. TP0_SMO_DATA = 10,
  283. TP0_MIPMAP_BASE_DATA = 11,
  284. SP_NCTX_REG = 32,
  285. SP_CTX0_3D_CVS_REG = 33,
  286. SP_CTX0_3D_CPS_REG = 34,
  287. SP_CTX1_3D_CVS_REG = 35,
  288. SP_CTX1_3D_CPS_REG = 36,
  289. SP_CTX2_3D_CPS_REG = 37,
  290. SP_CTX3_3D_CPS_REG = 38,
  291. SP_INST_DATA = 39,
  292. SP_INST_DATA_1 = 40,
  293. SP_LB_0_DATA = 41,
  294. SP_LB_1_DATA = 42,
  295. SP_LB_2_DATA = 43,
  296. SP_LB_3_DATA = 44,
  297. SP_LB_4_DATA = 45,
  298. SP_LB_5_DATA = 46,
  299. SP_LB_6_DATA = 47,
  300. SP_LB_7_DATA = 48,
  301. SP_CB_RAM = 49,
  302. SP_LB_13_DATA = 50,
  303. SP_LB_14_DATA = 51,
  304. SP_INST_TAG = 52,
  305. SP_INST_DATA_2 = 53,
  306. SP_TMO_TAG = 54,
  307. SP_SMO_TAG = 55,
  308. SP_STATE_DATA = 56,
  309. SP_HWAVE_RAM = 57,
  310. SP_L0_INST_BUF = 58,
  311. SP_LB_8_DATA = 59,
  312. SP_LB_9_DATA = 60,
  313. SP_LB_10_DATA = 61,
  314. SP_LB_11_DATA = 62,
  315. SP_LB_12_DATA = 63,
  316. HLSQ_DATAPATH_DSTR_META = 64,
  317. HLSQ_L2STC_TAG_RAM = 67,
  318. HLSQ_L2STC_INFO_CMD = 68,
  319. HLSQ_CVS_BE_CTXT_BUF_RAM_TAG = 69,
  320. HLSQ_CPS_BE_CTXT_BUF_RAM_TAG = 70,
  321. HLSQ_GFX_CVS_BE_CTXT_BUF_RAM = 71,
  322. HLSQ_GFX_CPS_BE_CTXT_BUF_RAM = 72,
  323. HLSQ_CHUNK_CVS_RAM = 73,
  324. HLSQ_CHUNK_CPS_RAM = 74,
  325. HLSQ_CHUNK_CVS_RAM_TAG = 75,
  326. HLSQ_CHUNK_CPS_RAM_TAG = 76,
  327. HLSQ_ICB_CVS_CB_BASE_TAG = 77,
  328. HLSQ_ICB_CPS_CB_BASE_TAG = 78,
  329. HLSQ_CVS_MISC_RAM = 79,
  330. HLSQ_CPS_MISC_RAM = 80,
  331. HLSQ_CPS_MISC_RAM_1 = 81,
  332. HLSQ_INST_RAM = 82,
  333. HLSQ_GFX_CVS_CONST_RAM = 83,
  334. HLSQ_GFX_CPS_CONST_RAM = 84,
  335. HLSQ_CVS_MISC_RAM_TAG = 85,
  336. HLSQ_CPS_MISC_RAM_TAG = 86,
  337. HLSQ_INST_RAM_TAG = 87,
  338. HLSQ_GFX_CVS_CONST_RAM_TAG = 88,
  339. HLSQ_GFX_CPS_CONST_RAM_TAG = 89,
  340. HLSQ_GFX_LOCAL_MISC_RAM = 90,
  341. HLSQ_GFX_LOCAL_MISC_RAM_TAG = 91,
  342. HLSQ_INST_RAM_1 = 92,
  343. HLSQ_STPROC_META = 93,
  344. HLSQ_BV_BE_META = 94,
  345. HLSQ_INST_RAM_2 = 95,
  346. HLSQ_DATAPATH_META = 96,
  347. HLSQ_FRONTEND_META = 97,
  348. HLSQ_INDIRECT_META = 98,
  349. HLSQ_BACKEND_META = 99,
  350. };
  351. static struct gen7_cp_indexed_reg gen7_cp_indexed_reg_list[] = {
  352. { GEN7_CP_SQE_STAT_ADDR, GEN7_CP_SQE_STAT_DATA, 0x40},
  353. { GEN7_CP_DRAW_STATE_ADDR, GEN7_CP_DRAW_STATE_DATA, 0x100},
  354. { GEN7_CP_SQE_UCODE_DBG_ADDR, GEN7_CP_SQE_UCODE_DBG_DATA, 0x8000},
  355. { GEN7_CP_BV_SQE_STAT_ADDR, GEN7_CP_BV_SQE_STAT_DATA, 0x40},
  356. { GEN7_CP_BV_DRAW_STATE_ADDR, GEN7_CP_BV_DRAW_STATE_DATA, 0x100},
  357. { GEN7_CP_BV_SQE_UCODE_DBG_ADDR, GEN7_CP_BV_SQE_UCODE_DBG_DATA, 0x8000},
  358. { GEN7_CP_SQE_AC_STAT_ADDR, GEN7_CP_SQE_AC_STAT_DATA, 0x40},
  359. { GEN7_CP_LPAC_DRAW_STATE_ADDR, GEN7_CP_LPAC_DRAW_STATE_DATA, 0x100},
  360. { GEN7_CP_SQE_AC_UCODE_DBG_ADDR, GEN7_CP_SQE_AC_UCODE_DBG_DATA, 0x8000},
  361. { GEN7_CP_LPAC_FIFO_DBG_ADDR, GEN7_CP_LPAC_FIFO_DBG_DATA, 0x40},
  362. };
  363. #endif /*_ADRENO_GEN7_SNAPSHOT_H */