msm_cvp_debug.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __MSM_CVP_DEBUG__
  6. #define __MSM_CVP_DEBUG__
  7. #include <linux/debugfs.h>
  8. #include <linux/delay.h>
  9. #include "msm_cvp_internal.h"
  10. #include "msm_cvp_events.h"
  11. #ifndef CVP_DBG_LABEL
  12. #define CVP_DBG_LABEL "msm_cvp"
  13. #endif
  14. #define CVP_DBG_TAG CVP_DBG_LABEL ": %4s: "
  15. /* To enable messages OR these values and
  16. * echo the result to debugfs file.
  17. *
  18. * To enable all messages set debug_level = 0x101F
  19. */
  20. enum cvp_msg_prio {
  21. CVP_ERR = 0x000001,
  22. CVP_WARN = 0x000002,
  23. CVP_INFO = 0x000004,
  24. CVP_CMD = 0x000008,
  25. CVP_PROF = 0x000010,
  26. CVP_PKT = 0x000020,
  27. CVP_MEM = 0x000040,
  28. CVP_SYNX = 0x000080,
  29. CVP_CORE = 0x000100,
  30. CVP_REG = 0x000200,
  31. CVP_PWR = 0x000400,
  32. CVP_DSP = 0x000800,
  33. CVP_FW = 0x001000,
  34. CVP_SESS = 0x002000,
  35. CVP_HFI = 0x004000,
  36. CVP_VM = 0x008000,
  37. CVP_DBG = CVP_MEM | CVP_SYNX | CVP_CORE | CVP_REG | CVP_CMD |
  38. CVP_PWR | CVP_DSP | CVP_SESS | CVP_HFI | CVP_PKT | CVP_VM,
  39. };
  40. enum cvp_msg_out {
  41. CVP_OUT_PRINTK = 0,
  42. };
  43. enum msm_cvp_debugfs_event {
  44. MSM_CVP_DEBUGFS_EVENT_ETB,
  45. MSM_CVP_DEBUGFS_EVENT_EBD,
  46. MSM_CVP_DEBUGFS_EVENT_FTB,
  47. MSM_CVP_DEBUGFS_EVENT_FBD,
  48. };
  49. extern int msm_cvp_debug;
  50. extern int msm_cvp_debug_out;
  51. extern int msm_cvp_fw_debug;
  52. extern int msm_cvp_fw_debug_mode;
  53. extern int msm_cvp_fw_low_power_mode;
  54. extern bool msm_cvp_fw_coverage;
  55. extern bool msm_cvp_auto_pil;
  56. extern bool msm_cvp_thermal_mitigation_disabled;
  57. extern bool msm_cvp_cacheop_disabled;
  58. extern int msm_cvp_clock_voting;
  59. extern bool msm_cvp_syscache_disable;
  60. extern bool msm_cvp_dsp_disable;
  61. extern bool msm_cvp_mmrm_enabled;
  62. extern bool msm_cvp_dcvs_disable;
  63. extern int msm_cvp_minidump_enable;
  64. extern bool cvp_kernel_fence_enabled;
  65. #define dprintk(__level, __fmt, arg...) \
  66. do { \
  67. if (msm_cvp_debug & __level) { \
  68. if (msm_cvp_debug_out == CVP_OUT_PRINTK) { \
  69. pr_info(CVP_DBG_TAG __fmt, \
  70. get_debug_level_str(__level), \
  71. ## arg); \
  72. } \
  73. } \
  74. } while (0)
  75. #define MSM_CVP_ERROR(value) \
  76. do { if (value) \
  77. dprintk(CVP_ERR, "BugOn"); \
  78. WARN_ON(value); \
  79. } while (0)
  80. struct dentry *msm_cvp_debugfs_init_drv(void);
  81. struct dentry *msm_cvp_debugfs_init_core(struct msm_cvp_core *core,
  82. struct dentry *parent);
  83. struct dentry *msm_cvp_debugfs_init_inst(struct msm_cvp_inst *inst,
  84. struct dentry *parent);
  85. void msm_cvp_debugfs_deinit_inst(struct msm_cvp_inst *inst);
  86. static inline char *get_debug_level_str(int level)
  87. {
  88. switch (level) {
  89. case CVP_ERR:
  90. return "err";
  91. case CVP_WARN:
  92. return "warn";
  93. case CVP_INFO:
  94. return "info";
  95. case CVP_CMD:
  96. return "cmd";
  97. case CVP_DBG:
  98. return "dbg";
  99. case CVP_PROF:
  100. return "prof";
  101. case CVP_PKT:
  102. return "pkt";
  103. case CVP_MEM:
  104. return "mem";
  105. case CVP_SYNX:
  106. return "synx";
  107. case CVP_CORE:
  108. return "core";
  109. case CVP_REG:
  110. return "reg";
  111. case CVP_PWR:
  112. return "pwr";
  113. case CVP_DSP:
  114. return "dsp";
  115. case CVP_FW:
  116. return "fw";
  117. case CVP_SESS:
  118. return "sess";
  119. case CVP_HFI:
  120. return "hfi";
  121. case CVP_VM:
  122. return "vm";
  123. default:
  124. return "???";
  125. }
  126. }
  127. static inline void show_stats(struct msm_cvp_inst *i)
  128. {
  129. int x;
  130. for (x = 0; x < MAX_PROFILING_POINTS; x++) {
  131. if (i->debug.pdata[x].name[0] &&
  132. (msm_cvp_debug & CVP_PROF)) {
  133. if (i->debug.samples) {
  134. dprintk(CVP_PROF, "%s averaged %d ms/sample\n",
  135. i->debug.pdata[x].name,
  136. i->debug.pdata[x].cumulative /
  137. i->debug.samples);
  138. }
  139. dprintk(CVP_PROF, "%s Samples: %d\n",
  140. i->debug.pdata[x].name,
  141. i->debug.samples);
  142. }
  143. }
  144. }
  145. static inline void msm_cvp_res_handle_fatal_hw_error(
  146. struct msm_cvp_platform_resources *resources,
  147. bool enable_fatal)
  148. {
  149. enable_fatal &= resources->debug_timeout;
  150. MSM_CVP_ERROR(enable_fatal);
  151. }
  152. static inline void msm_cvp_handle_hw_error(struct msm_cvp_core *core)
  153. {
  154. bool enable_fatal = true;
  155. /*
  156. * In current implementation user-initiated SSR triggers
  157. * a fatal error from hardware. However, there is no way
  158. * to know if fatal error is due to SSR or not. Handle
  159. * user SSR as non-fatal.
  160. */
  161. if (core->trigger_ssr) {
  162. core->trigger_ssr = false;
  163. enable_fatal = false;
  164. }
  165. /* CVP driver can decide FATAL handling of HW errors
  166. * based on multiple factors. This condition check will
  167. * be enhanced later.
  168. */
  169. msm_cvp_res_handle_fatal_hw_error(&core->resources, enable_fatal);
  170. }
  171. #endif