msm_cvp_debug.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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_PROF = 0x000010,
  25. CVP_PKT = 0x000020,
  26. CVP_MEM = 0x000040,
  27. CVP_SYNX = 0x000080,
  28. CVP_CORE = 0x000100,
  29. CVP_REG = 0x000200,
  30. CVP_PWR = 0x000400,
  31. CVP_DSP = 0x000800,
  32. CVP_FW = 0x001000,
  33. CVP_SESS = 0x002000,
  34. CVP_HFI = 0x004000,
  35. CVP_DBG = CVP_MEM | CVP_SYNX | CVP_CORE | CVP_REG |
  36. CVP_PWR | CVP_DSP | CVP_SESS | CVP_HFI | CVP_PKT,
  37. };
  38. enum cvp_msg_out {
  39. CVP_OUT_PRINTK = 0,
  40. };
  41. enum msm_cvp_debugfs_event {
  42. MSM_CVP_DEBUGFS_EVENT_ETB,
  43. MSM_CVP_DEBUGFS_EVENT_EBD,
  44. MSM_CVP_DEBUGFS_EVENT_FTB,
  45. MSM_CVP_DEBUGFS_EVENT_FBD,
  46. };
  47. extern int msm_cvp_debug;
  48. extern int msm_cvp_debug_out;
  49. extern int msm_cvp_fw_debug;
  50. extern int msm_cvp_fw_debug_mode;
  51. extern int msm_cvp_fw_low_power_mode;
  52. extern bool msm_cvp_fw_coverage;
  53. extern bool msm_cvp_auto_pil;
  54. extern bool msm_cvp_thermal_mitigation_disabled;
  55. extern bool msm_cvp_cacheop_disabled;
  56. extern int msm_cvp_clock_voting;
  57. extern bool msm_cvp_syscache_disable;
  58. extern bool msm_cvp_dsp_disable;
  59. extern bool msm_cvp_mmrm_enabled;
  60. extern bool msm_cvp_dcvs_disable;
  61. extern int msm_cvp_minidump_enable;
  62. #define dprintk(__level, __fmt, arg...) \
  63. do { \
  64. if (msm_cvp_debug & __level) { \
  65. if (msm_cvp_debug_out == CVP_OUT_PRINTK) { \
  66. pr_info_ratelimited(CVP_DBG_TAG __fmt, \
  67. get_debug_level_str(__level), \
  68. ## arg); \
  69. } \
  70. } \
  71. } while (0)
  72. #define MSM_CVP_ERROR(value) \
  73. do { if (value) \
  74. dprintk(CVP_ERR, "BugOn"); \
  75. WARN_ON(value); \
  76. } while (0)
  77. struct dentry *msm_cvp_debugfs_init_drv(void);
  78. struct dentry *msm_cvp_debugfs_init_core(struct msm_cvp_core *core,
  79. struct dentry *parent);
  80. struct dentry *msm_cvp_debugfs_init_inst(struct msm_cvp_inst *inst,
  81. struct dentry *parent);
  82. void msm_cvp_debugfs_deinit_inst(struct msm_cvp_inst *inst);
  83. static inline char *get_debug_level_str(int level)
  84. {
  85. switch (level) {
  86. case CVP_ERR:
  87. return "err";
  88. case CVP_WARN:
  89. return "warn";
  90. case CVP_INFO:
  91. return "info";
  92. case CVP_DBG:
  93. return "dbg";
  94. case CVP_PROF:
  95. return "prof";
  96. case CVP_PKT:
  97. return "pkt";
  98. case CVP_MEM:
  99. return "mem";
  100. case CVP_SYNX:
  101. return "synx";
  102. case CVP_CORE:
  103. return "core";
  104. case CVP_REG:
  105. return "reg";
  106. case CVP_PWR:
  107. return "pwr";
  108. case CVP_DSP:
  109. return "dsp";
  110. case CVP_FW:
  111. return "fw";
  112. case CVP_SESS:
  113. return "sess";
  114. case CVP_HFI:
  115. return "hfi";
  116. default:
  117. return "???";
  118. }
  119. }
  120. static inline void show_stats(struct msm_cvp_inst *i)
  121. {
  122. int x;
  123. for (x = 0; x < MAX_PROFILING_POINTS; x++) {
  124. if (i->debug.pdata[x].name[0] &&
  125. (msm_cvp_debug & CVP_PROF)) {
  126. if (i->debug.samples) {
  127. dprintk(CVP_PROF, "%s averaged %d ms/sample\n",
  128. i->debug.pdata[x].name,
  129. i->debug.pdata[x].cumulative /
  130. i->debug.samples);
  131. }
  132. dprintk(CVP_PROF, "%s Samples: %d\n",
  133. i->debug.pdata[x].name,
  134. i->debug.samples);
  135. }
  136. }
  137. }
  138. static inline void msm_cvp_res_handle_fatal_hw_error(
  139. struct msm_cvp_platform_resources *resources,
  140. bool enable_fatal)
  141. {
  142. enable_fatal &= resources->debug_timeout;
  143. MSM_CVP_ERROR(enable_fatal);
  144. }
  145. static inline void msm_cvp_handle_hw_error(struct msm_cvp_core *core)
  146. {
  147. bool enable_fatal = true;
  148. /*
  149. * In current implementation user-initiated SSR triggers
  150. * a fatal error from hardware. However, there is no way
  151. * to know if fatal error is due to SSR or not. Handle
  152. * user SSR as non-fatal.
  153. */
  154. if (core->trigger_ssr) {
  155. core->trigger_ssr = false;
  156. enable_fatal = false;
  157. }
  158. /* CVP driver can decide FATAL handling of HW errors
  159. * based on multiple factors. This condition check will
  160. * be enhanced later.
  161. */
  162. msm_cvp_res_handle_fatal_hw_error(&core->resources, enable_fatal);
  163. }
  164. #endif