adreno_snapshot.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013-2015,2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_SNAPSHOT_H
  7. #define __ADRENO_SNAPSHOT_H
  8. #include "kgsl_snapshot.h"
  9. #define CP_CRASH_DUMPER_TIMEOUT 500
  10. #define DEBUG_SECTION_SZ(_dwords) (((_dwords) * sizeof(unsigned int)) \
  11. + sizeof(struct kgsl_snapshot_debug))
  12. #define SHADER_SECTION_SZ(_dwords) (((_dwords) * sizeof(unsigned int)) \
  13. + sizeof(struct kgsl_snapshot_shader))
  14. /* Macro to make it super easy to dump registers */
  15. #define SNAPSHOT_REGISTERS(_d, _s, _r) \
  16. adreno_snapshot_registers((_d), (_s), \
  17. (unsigned int *) _r, ARRAY_SIZE(_r) / 2)
  18. #define REG_COUNT(_ptr) ((_ptr[1] - _ptr[0]) + 1)
  19. void adreno_snapshot_registers(struct kgsl_device *device,
  20. struct kgsl_snapshot *snapshot,
  21. const unsigned int *regs, unsigned int count);
  22. /**
  23. * adreno_snapshot_regs_count - Helper function to calculate register and
  24. * header size
  25. * @ptr: Pointer to the register array
  26. *
  27. * Return: Number of registers in the array
  28. *
  29. * Helper function to count the total number of regsiters
  30. * in a given array plus the header space needed for each group.
  31. */
  32. int adreno_snapshot_regs_count(const u32 *ptr);
  33. /**
  34. * adreno_snapshot_registers_v2 - Dump a series of registers
  35. * @device: Pointer to the kgsl device
  36. * @buf: The snapshot buffer
  37. * @remain: The size remaining in the snapshot buffer
  38. * @priv: Pointer to the register array to be dumped
  39. *
  40. * Return: Number of bytes written to the snapshot
  41. *
  42. * This function dumps the registers in a way that we need to
  43. * only dump the start address and count for each pair of register
  44. * in the array. This helps us save some memory in snapshot.
  45. */
  46. size_t adreno_snapshot_registers_v2(struct kgsl_device *device,
  47. u8 *buf, size_t remain, void *priv);
  48. /**
  49. * adreno_snapshot_registers_v2 - Dump a series of CX_MISC registers
  50. * @device: Pointer to the kgsl device
  51. * @buf: The snapshot buffer
  52. * @remain: The size remaining in the snapshot buffer
  53. * @priv: Pointer to the CX_MISC register array to be dumped
  54. *
  55. * Return: Number of bytes written to the snapshot
  56. *
  57. * This function dumps the CX_MISC registers in a way that we need to
  58. * only dump the start address and count for each pair of register
  59. * in the array. This helps us save some memory in snapshot.
  60. */
  61. size_t adreno_snapshot_cx_misc_registers(struct kgsl_device *device,
  62. u8 *buf, size_t remain, void *priv);
  63. /**
  64. * adreno_parse_ib - Parse the given IB
  65. * @device: Pointer to the kgsl device
  66. * @snapshot: Pointer to the snapshot structure
  67. * @process: Process to which this IB belongs
  68. * @gpuaddr: Gpu address of the IB
  69. * @dwords: Size in dwords of the IB
  70. *
  71. * We want to store the last executed IB1 and IB2 in the static region to ensure
  72. * that we get at least some information out of the snapshot even if we can't
  73. * access the dynamic data from the sysfs file. Push all other IBs on the
  74. * dynamic list
  75. */
  76. void adreno_parse_ib(struct kgsl_device *device,
  77. struct kgsl_snapshot *snapshot,
  78. struct kgsl_process_private *process,
  79. u64 gpuaddr, u64 dwords);
  80. /**
  81. * adreno_parse_ib_lpac - Parse the given LPAC IB
  82. * @device: Pointer to the kgsl device
  83. * @snapshot: Pointer to the snapshot structure
  84. * @process: Process to which this LPAC IB belongs
  85. * @gpuaddr: Gpu address of the LPAC IB
  86. * @dwords: Size in dwords of the LPAC IB
  87. *
  88. * We want to store the last executed LPAC IB1 and IB2 in the static region to ensure
  89. * that we get at least some information out of the snapshot even if we can't
  90. * access the dynamic data from the sysfs file. Push all other IBs on the
  91. * dynamic list
  92. */
  93. void adreno_parse_ib_lpac(struct kgsl_device *device,
  94. struct kgsl_snapshot *snapshot,
  95. struct kgsl_process_private *process,
  96. u64 gpuaddr, u64 dwords);
  97. /**
  98. * adreno_snapshot_global - Add global buffer to snapshot
  99. * @device: Pointer to the kgsl device
  100. * @buf: Where the global buffer section is to be written
  101. * @remain: Remaining bytes in snapshot buffer
  102. * @priv: Opaque data
  103. *
  104. * Return: Number of bytes written to the snapshot buffer
  105. */
  106. size_t adreno_snapshot_global(struct kgsl_device *device, u8 *buf,
  107. size_t remain, void *priv);
  108. /**
  109. * adreno_snapshot_dump_all_ibs - To dump all ibs from ringbuffer
  110. * @device: Pointer to the kgsl device
  111. * @rbptr: Ringbuffer host pointer
  112. * @snapshot: Pointer to the snapshot structure
  113. *
  114. * Parse all IBs from the ringbuffer and add to IB dump list.
  115. */
  116. void adreno_snapshot_dump_all_ibs(struct kgsl_device *device,
  117. unsigned int *rbptr,
  118. struct kgsl_snapshot *snapshot);
  119. #endif /*__ADRENO_SNAPSHOT_H */