kgsl_log.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright (c) 2002,2008-2011,2013-2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef __KGSL_LOG_H
  14. #define __KGSL_LOG_H
  15. #define KGSL_LOG_INFO(dev, lvl, fmt, args...) \
  16. do { \
  17. if ((lvl) >= 6) \
  18. dev_info(dev, "|%s| " fmt, \
  19. __func__, ##args);\
  20. } while (0)
  21. #define KGSL_LOG_WARN(dev, lvl, fmt, args...) \
  22. do { \
  23. if ((lvl) >= 4) \
  24. dev_warn(dev, "|%s| " fmt, \
  25. __func__, ##args);\
  26. } while (0)
  27. #define KGSL_LOG_ERR(dev, lvl, fmt, args...) \
  28. do { \
  29. if ((lvl) >= 3) \
  30. dev_err(dev, "|%s| " fmt, \
  31. __func__, ##args);\
  32. } while (0)
  33. #define KGSL_LOG_CRIT(dev, lvl, fmt, args...) \
  34. do { \
  35. if ((lvl) >= 2) \
  36. dev_crit(dev, "|%s| " fmt, \
  37. __func__, ##args);\
  38. } while (0)
  39. #define KGSL_LOG_POSTMORTEM_WRITE(_dev, fmt, args...) \
  40. do { dev_crit(_dev->dev, fmt, ##args); } while (0)
  41. #define KGSL_LOG_DUMP(_dev, fmt, args...) dev_err(_dev->dev, fmt, ##args)
  42. #define KGSL_DEV_ERR_ONCE(_dev, fmt, args...) \
  43. ({ \
  44. static bool kgsl_dev_err_once; \
  45. \
  46. if (!kgsl_dev_err_once) { \
  47. kgsl_dev_err_once = true; \
  48. dev_crit(_dev->dev, "|%s| " fmt, __func__, ##args); \
  49. } \
  50. })
  51. #define dev_crit_ratelimited(dev, fmt, ...) \
  52. dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__)
  53. #define dev_level_ratelimited(dev_level, dev, fmt, ...) \
  54. do { \
  55. static DEFINE_RATELIMIT_STATE(_rs, \
  56. DEFAULT_RATELIMIT_INTERVAL, \
  57. DEFAULT_RATELIMIT_BURST); \
  58. if (__ratelimit(&_rs)) \
  59. dev_level(dev, fmt, ##__VA_ARGS__); \
  60. } while (0)
  61. #define KGSL_LOG_CRIT_RATELIMITED(dev, lvl, fmt, args...) \
  62. do { \
  63. if ((lvl) >= 2) \
  64. dev_crit_ratelimited(dev, "|%s| " fmt, \
  65. __func__, ##args);\
  66. } while (0)
  67. #define KGSL_DRV_INFO(_dev, fmt, args...) \
  68. KGSL_LOG_INFO(_dev->dev, _dev->drv_log, fmt, ##args)
  69. #define KGSL_DRV_WARN(_dev, fmt, args...) \
  70. KGSL_LOG_WARN(_dev->dev, _dev->drv_log, fmt, ##args)
  71. #define KGSL_DRV_ERR(_dev, fmt, args...) \
  72. KGSL_LOG_ERR(_dev->dev, _dev->drv_log, fmt, ##args)
  73. #define KGSL_DRV_CRIT(_dev, fmt, args...) \
  74. KGSL_LOG_CRIT(_dev->dev, _dev->drv_log, fmt, ##args)
  75. #define KGSL_DRV_CRIT_RATELIMIT(_dev, fmt, args...) \
  76. KGSL_LOG_CRIT_RATELIMITED(_dev->dev, _dev->drv_log, fmt, ##args)
  77. #define KGSL_CMD_INFO(_dev, fmt, args...) \
  78. KGSL_LOG_INFO(_dev->dev, _dev->cmd_log, fmt, ##args)
  79. #define KGSL_CMD_WARN(_dev, fmt, args...) \
  80. KGSL_LOG_WARN(_dev->dev, _dev->cmd_log, fmt, ##args)
  81. #define KGSL_CMD_ERR(_dev, fmt, args...) \
  82. KGSL_LOG_ERR(_dev->dev, _dev->cmd_log, fmt, ##args)
  83. #define KGSL_CMD_CRIT(_dev, fmt, args...) \
  84. KGSL_LOG_CRIT(_dev->dev, _dev->cmd_log, fmt, ##args)
  85. #define KGSL_CTXT_INFO(_dev, fmt, args...) \
  86. KGSL_LOG_INFO(_dev->dev, _dev->ctxt_log, fmt, ##args)
  87. #define KGSL_CTXT_WARN(_dev, fmt, args...) \
  88. KGSL_LOG_WARN(_dev->dev, _dev->ctxt_log, fmt, ##args)
  89. #define KGSL_CTXT_ERR(_dev, fmt, args...) \
  90. KGSL_LOG_ERR(_dev->dev, _dev->ctxt_log, fmt, ##args)
  91. #define KGSL_CTXT_CRIT(_dev, fmt, args...) \
  92. KGSL_LOG_CRIT(_dev->dev, _dev->ctxt_log, fmt, ##args)
  93. #define KGSL_MEM_INFO(_dev, fmt, args...) \
  94. KGSL_LOG_INFO(_dev->dev, _dev->mem_log, fmt, ##args)
  95. #define KGSL_MEM_WARN(_dev, fmt, args...) \
  96. KGSL_LOG_WARN(_dev->dev, _dev->mem_log, fmt, ##args)
  97. #define KGSL_MEM_ERR(_dev, fmt, args...) \
  98. KGSL_LOG_ERR(_dev->dev, _dev->mem_log, fmt, ##args)
  99. #define KGSL_MEM_CRIT(_dev, fmt, args...) \
  100. KGSL_LOG_CRIT(_dev->dev, _dev->mem_log, fmt, ##args)
  101. #define KGSL_PWR_INFO(_dev, fmt, args...) \
  102. KGSL_LOG_INFO(_dev->dev, _dev->pwr_log, fmt, ##args)
  103. #define KGSL_PWR_WARN(_dev, fmt, args...) \
  104. KGSL_LOG_WARN(_dev->dev, _dev->pwr_log, fmt, ##args)
  105. #define KGSL_PWR_ERR(_dev, fmt, args...) \
  106. KGSL_LOG_ERR(_dev->dev, _dev->pwr_log, fmt, ##args)
  107. #define KGSL_PWR_CRIT(_dev, fmt, args...) \
  108. KGSL_LOG_CRIT(_dev->dev, _dev->pwr_log, fmt, ##args)
  109. /* Core error messages - these are for core KGSL functions that have
  110. no device associated with them (such as memory) */
  111. #define KGSL_CORE_ERR(fmt, args...) \
  112. pr_err("kgsl: %s: " fmt, __func__, ##args)
  113. #endif /* __KGSL_LOG_H */