mtk_log.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright (C) 2019 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __MTKFB_LOG_H
  14. #define __MTKFB_LOG_H
  15. #include <linux/kernel.h>
  16. extern unsigned long long mutex_time_start;
  17. extern unsigned long long mutex_time_end;
  18. extern long long mutex_time_period;
  19. extern const char *mutex_locker;
  20. enum DPREC_LOGGER_PR_TYPE {
  21. DPREC_LOGGER_ERROR,
  22. DPREC_LOGGER_FENCE,
  23. DPREC_LOGGER_DEBUG,
  24. DPREC_LOGGER_DUMP,
  25. DPREC_LOGGER_STATUS,
  26. DPREC_LOGGER_PR_NUM
  27. };
  28. int mtk_dprec_logger_pr(unsigned int type, char *fmt, ...);
  29. #define DDPINFO(fmt, arg...) \
  30. do { \
  31. mtk_dprec_logger_pr(DPREC_LOGGER_DEBUG, fmt, ##arg); \
  32. if (g_mobile_log) \
  33. pr_info(pr_fmt(fmt), ##arg); \
  34. } while (0)
  35. #define DDPFUNC(fmt, arg...) \
  36. pr_info("[%s line:%d]"pr_fmt(fmt), __func__, __LINE__, ##arg)
  37. #define DDPDBG(fmt, arg...) \
  38. do { \
  39. if (!g_detail_log) \
  40. break; \
  41. mtk_dprec_logger_pr(DPREC_LOGGER_DEBUG, fmt, ##arg); \
  42. if (g_mobile_log) \
  43. pr_info(pr_fmt(fmt), ##arg); \
  44. } while (0)
  45. #define DDPMSG(fmt, arg...) \
  46. do { \
  47. mtk_dprec_logger_pr(DPREC_LOGGER_DEBUG, fmt, ##arg); \
  48. pr_info(pr_fmt(fmt), ##arg); \
  49. } while (0)
  50. #define DDPDUMP(fmt, arg...) \
  51. do { \
  52. mtk_dprec_logger_pr(DPREC_LOGGER_DUMP, fmt, ##arg); \
  53. if (g_mobile_log) \
  54. pr_info(pr_fmt(fmt), ##arg); \
  55. } while (0)
  56. #define DDPFENCE(fmt, arg...) \
  57. do { \
  58. mtk_dprec_logger_pr(DPREC_LOGGER_FENCE, fmt, ##arg); \
  59. if (g_fence_log) \
  60. pr_info(pr_fmt(fmt), ##arg); \
  61. } while (0)
  62. #define DDPPR_ERR(fmt, arg...) \
  63. do { \
  64. mtk_dprec_logger_pr(DPREC_LOGGER_ERROR, fmt, ##arg); \
  65. pr_err(pr_fmt(fmt), ##arg); \
  66. } while (0)
  67. #define DDPIRQ(fmt, arg...) \
  68. do { \
  69. if (g_irq_log) \
  70. mtk_dprec_logger_pr(DPREC_LOGGER_DEBUG, fmt, ##arg); \
  71. } while (0)
  72. #define DDP_MUTEX_LOCK(lock, name, line) \
  73. do { \
  74. DDPINFO("M_LOCK:%s[%d] +\n", name, line); \
  75. DRM_MMP_EVENT_START(mutex_lock, (unsigned long)lock, \
  76. line); \
  77. mutex_lock(lock); \
  78. mutex_time_start = sched_clock(); \
  79. mutex_locker = name; \
  80. } while (0)
  81. #define DDP_MUTEX_UNLOCK(lock, name, line) \
  82. do { \
  83. mutex_locker = NULL; \
  84. mutex_time_end = sched_clock(); \
  85. mutex_time_period = mutex_time_end - mutex_time_start; \
  86. if (mutex_time_period > 1000000000) { \
  87. DDPPR_ERR("M_ULOCK:%s[%d] timeout:<%lld ns>!\n", \
  88. name, line, mutex_time_period); \
  89. DRM_MMP_MARK(mutex_lock, \
  90. (unsigned long)mutex_time_period, 0); \
  91. dump_stack(); \
  92. } \
  93. mutex_unlock(lock); \
  94. DRM_MMP_EVENT_END(mutex_lock, (unsigned long)lock, \
  95. line); \
  96. DDPINFO("M_ULOCK:%s[%d] -\n", name, line); \
  97. } while (0)
  98. #define DDP_MUTEX_LOCK_NESTED(lock, i, name, line) \
  99. do { \
  100. DDPINFO("M_LOCK_NST[%d]:%s[%d] +\n", i, name, line); \
  101. mutex_lock_nested(lock, i); \
  102. } while (0)
  103. #define DDP_MUTEX_UNLOCK_NESTED(lock, i, name, line) \
  104. do { \
  105. mutex_unlock(lock); \
  106. DDPINFO("M_ULOCK_NST[%d]:%s[%d] -\n", i, name, line); \
  107. } while (0)
  108. #ifdef CONFIG_MTK_AEE_FEATURE
  109. #define DDPAEE(string, args...) \
  110. do { \
  111. char str[200]; \
  112. int r; \
  113. r = snprintf(str, 199, "DDP:" string, ##args); \
  114. if (r < 0) { \
  115. pr_err("snprintf error\n"); \
  116. } \
  117. aee_kernel_warning_api(__FILE__, __LINE__, \
  118. DB_OPT_DEFAULT | \
  119. DB_OPT_MMPROFILE_BUFFER, \
  120. str, string, ##args); \
  121. DDPPR_ERR("[DDP Error]" string, ##args); \
  122. } while (0)
  123. #else /* !CONFIG_MTK_AEE_FEATURE */
  124. #define DDPAEE(string, args...) \
  125. do { \
  126. char str[200]; \
  127. int r; \
  128. r = snprintf(str, 199, "DDP:" string, ##args); \
  129. if (r < 0) { \
  130. pr_err("snprintf error\n"); \
  131. } \
  132. pr_err("[DDP Error]" string, ##args); \
  133. } while (0)
  134. #endif /* CONFIG_MTK_AEE_FEATURE */
  135. extern bool g_mobile_log;
  136. extern bool g_fence_log;
  137. extern bool g_irq_log;
  138. extern bool g_detail_log;
  139. #endif