msm_cvp_debug.h 4.0 KB

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