msm_vidc_debug.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021,, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __MSM_VIDC_DEBUG__
  6. #define __MSM_VIDC_DEBUG__
  7. #include <linux/errno.h>
  8. #include <linux/debugfs.h>
  9. #include <linux/delay.h>
  10. #include <linux/types.h>
  11. #include <linux/module.h>
  12. #include <linux/moduleparam.h>
  13. #ifndef VIDC_DBG_LABEL
  14. #define VIDC_DBG_LABEL "msm_vidc"
  15. #endif
  16. /* Allow only 6 prints/sec */
  17. #define VIDC_DBG_SESSION_RATELIMIT_INTERVAL (1 * HZ)
  18. #define VIDC_DBG_SESSION_RATELIMIT_BURST 6
  19. #define VIDC_DBG_TAG_INST VIDC_DBG_LABEL ": %4s: %s: "
  20. #define VIDC_DBG_TAG_CORE VIDC_DBG_LABEL ": %4s: %08x: %s: "
  21. #define FW_DBG_TAG VIDC_DBG_LABEL ": %6s: "
  22. #define DEFAULT_SID ((u32)-1)
  23. #ifndef MSM_VIDC_EMPTY_BRACE
  24. #define MSM_VIDC_EMPTY_BRACE {},
  25. #endif
  26. extern unsigned int msm_vidc_debug;
  27. extern bool msm_vidc_lossless_encode;
  28. extern bool msm_vidc_syscache_disable;
  29. extern int msm_vidc_clock_voting;
  30. extern int msm_vidc_ddr_bw;
  31. extern int msm_vidc_llc_bw;
  32. extern bool msm_vidc_fw_dump;
  33. extern unsigned int msm_vidc_enable_bugon;
  34. /* do not modify the log message as it is used in test scripts */
  35. #define FMT_STRING_SET_CTRL \
  36. "%s: state %s, name %s, id 0x%x value %d\n"
  37. #define FMT_STRING_STATE_CHANGE \
  38. "%s: state changed to %s from %s\n"
  39. #define FMT_STRING_MSG_SFR \
  40. "SFR Message from FW: %s\n"
  41. #define FMT_STRING_FAULT_HANDLER \
  42. "%s: faulting address: %lx\n"
  43. #define FMT_STRING_SET_CAP \
  44. "set cap: name: %24s, cap value: %#10x, hfi: %#10x\n"
  45. /* To enable messages OR these values and
  46. * echo the result to debugfs file.
  47. *
  48. * To enable all messages set msm_vidc_debug = 0x101F
  49. */
  50. enum vidc_msg_prio {
  51. VIDC_ERR = 0x00000001,
  52. VIDC_HIGH = 0x00000002,
  53. VIDC_LOW = 0x00000004,
  54. VIDC_PERF = 0x00000008,
  55. VIDC_PKT = 0x00000010,
  56. VIDC_BUS = 0x00000020,
  57. VIDC_STAT = 0x00000040,
  58. VIDC_ENCODER = 0x00000100,
  59. VIDC_DECODER = 0x00000200,
  60. VIDC_PRINTK = 0x00001000,
  61. VIDC_FTRACE = 0x00002000,
  62. FW_LOW = 0x00010000,
  63. FW_MED = 0x00020000,
  64. FW_HIGH = 0x00040000,
  65. FW_ERROR = 0x00080000,
  66. FW_FATAL = 0x00100000,
  67. FW_PERF = 0x00200000,
  68. FW_PRINTK = 0x10000000,
  69. FW_FTRACE = 0x20000000,
  70. };
  71. #define FW_LOGSHIFT 16
  72. #define FW_LOGMASK 0x0FFF0000
  73. #define dprintk_inst(__level, __level_str, inst, __fmt, ...) \
  74. do { \
  75. if (inst && (msm_vidc_debug & (__level))) { \
  76. pr_info(VIDC_DBG_TAG_INST __fmt, \
  77. __level_str, \
  78. inst->debug_str, \
  79. ##__VA_ARGS__); \
  80. } \
  81. } while (0)
  82. #define i_vpr_e(inst, __fmt, ...) dprintk_inst(VIDC_ERR, "err ", inst, __fmt, ##__VA_ARGS__)
  83. #define i_vpr_i(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, "high", inst, __fmt, ##__VA_ARGS__)
  84. #define i_vpr_h(inst, __fmt, ...) dprintk_inst(VIDC_HIGH, "high", inst, __fmt, ##__VA_ARGS__)
  85. #define i_vpr_l(inst, __fmt, ...) dprintk_inst(VIDC_LOW, "low ", inst, __fmt, ##__VA_ARGS__)
  86. #define i_vpr_p(inst, __fmt, ...) dprintk_inst(VIDC_PERF, "perf", inst, __fmt, ##__VA_ARGS__)
  87. #define i_vpr_t(inst, __fmt, ...) dprintk_inst(VIDC_PKT, "pkt ", inst, __fmt, ##__VA_ARGS__)
  88. #define i_vpr_b(inst, __fmt, ...) dprintk_inst(VIDC_BUS, "bus ", inst, __fmt, ##__VA_ARGS__)
  89. #define i_vpr_s(inst, __fmt, ...) dprintk_inst(VIDC_STAT, "stat", inst, __fmt, ##__VA_ARGS__)
  90. #define i_vpr_hp(inst, __fmt, ...) \
  91. dprintk_inst(VIDC_HIGH | VIDC_PERF, "high", inst, __fmt, ##__VA_ARGS__)
  92. #define i_vpr_hs(inst, __fmt, ...) \
  93. dprintk_inst(VIDC_HIGH | VIDC_STAT, "high", inst, __fmt, ##__VA_ARGS__)
  94. #define dprintk_core(__level, __level_str, __fmt, ...) \
  95. do { \
  96. if (msm_vidc_debug & (__level)) { \
  97. pr_info(VIDC_DBG_TAG_CORE __fmt, \
  98. __level_str, \
  99. DEFAULT_SID, \
  100. "codec", \
  101. ##__VA_ARGS__); \
  102. } \
  103. } while (0)
  104. #define d_vpr_e(__fmt, ...) dprintk_core(VIDC_ERR, "err ", __fmt, ##__VA_ARGS__)
  105. #define d_vpr_h(__fmt, ...) dprintk_core(VIDC_HIGH, "high", __fmt, ##__VA_ARGS__)
  106. #define d_vpr_l(__fmt, ...) dprintk_core(VIDC_LOW, "low ", __fmt, ##__VA_ARGS__)
  107. #define d_vpr_p(__fmt, ...) dprintk_core(VIDC_PERF, "perf", __fmt, ##__VA_ARGS__)
  108. #define d_vpr_t(__fmt, ...) dprintk_core(VIDC_PKT, "pkt ", __fmt, ##__VA_ARGS__)
  109. #define d_vpr_b(__fmt, ...) dprintk_core(VIDC_BUS, "bus ", __fmt, ##__VA_ARGS__)
  110. #define d_vpr_s(__fmt, ...) dprintk_core(VIDC_STAT, "stat", __fmt, ##__VA_ARGS__)
  111. #define dprintk_ratelimit(__level, __level_str, __fmt, ...) \
  112. do { \
  113. if (msm_vidc_check_ratelimit()) { \
  114. dprintk_core(__level, __level_str, __fmt, ##__VA_ARGS__); \
  115. } \
  116. } while (0)
  117. #define dprintk_firmware(__level, __fmt, ...) \
  118. do { \
  119. if (__level & FW_PRINTK) { \
  120. pr_info(FW_DBG_TAG __fmt, \
  121. "fw", \
  122. ##__VA_ARGS__); \
  123. } \
  124. } while (0)
  125. #define MSM_VIDC_FATAL(value) \
  126. do { \
  127. if (value) { \
  128. d_vpr_e("bug on\n"); \
  129. BUG_ON(value); \
  130. } \
  131. } while (0)
  132. enum msm_vidc_debugfs_event {
  133. MSM_VIDC_DEBUGFS_EVENT_ETB,
  134. MSM_VIDC_DEBUGFS_EVENT_EBD,
  135. MSM_VIDC_DEBUGFS_EVENT_FTB,
  136. MSM_VIDC_DEBUGFS_EVENT_FBD,
  137. };
  138. enum msm_vidc_bug_on_error {
  139. MSM_VIDC_BUG_ON_FATAL = BIT(0),
  140. MSM_VIDC_BUG_ON_NOC = BIT(1),
  141. MSM_VIDC_BUG_ON_WD_TIMEOUT = BIT(2),
  142. };
  143. struct dentry *msm_vidc_debugfs_init_drv(void);
  144. struct dentry *msm_vidc_debugfs_init_core(void *core);
  145. struct dentry *msm_vidc_debugfs_init_inst(void *inst,
  146. struct dentry *parent);
  147. void msm_vidc_debugfs_deinit_inst(void *inst);
  148. void msm_vidc_debugfs_update(void *inst,
  149. enum msm_vidc_debugfs_event e);
  150. int msm_vidc_check_ratelimit(void);
  151. void msm_vidc_show_stats(void *inst);
  152. #endif