msm_performance.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __MSM_PERFORMANCE_H
  7. #define __MSM_PERFORMANCE_H
  8. enum gfx_evt_t {
  9. MSM_PERF_INVAL,
  10. MSM_PERF_QUEUE,
  11. MSM_PERF_SUBMIT,
  12. MSM_PERF_RETIRED
  13. };
  14. enum evt_update_t {
  15. MSM_PERF_GFX,
  16. };
  17. #if IS_ENABLED(CONFIG_MSM_PERFORMANCE)
  18. void msm_perf_events_update(enum evt_update_t update_typ,
  19. enum gfx_evt_t evt_typ, pid_t pid,
  20. uint32_t ctx_id, uint32_t timestamp, bool end_of_frame);
  21. #else
  22. static inline void msm_perf_events_update(enum evt_update_t update_typ,
  23. enum gfx_evt_t evt_typ, pid_t pid,
  24. uint32_t ctx_id, uint32_t timestamp, bool end_of_frame)
  25. {
  26. }
  27. #endif
  28. #if IS_ENABLED(CONFIG_QTI_SCMI_VENDOR_PROTOCOL)
  29. #define SCMI_SPLH_ALGO_STR (0x53504C48414C474F)
  30. #define SCMI_LPLH_ALGO_STR (0x4C504C48414C474F)
  31. enum scmi_vendor_plh_param_ids {
  32. PLH_INIT_IPC_FREQ_TBL = 1,
  33. PLH_SET_SAMPLE_PERIOD_MS,
  34. PLH_SET_LOG_LEVEL,
  35. PLH_ACTIVITY_START,
  36. PLH_ACTIVITY_STOP,
  37. };
  38. #define splh_start_activity(splh_notif) ({\
  39. uint32_t temp, *msg = &temp;\
  40. *msg = cpu_to_le32(splh_notif); \
  41. plh_ops->start_activity(plh_handle, msg, SCMI_SPLH_ALGO_STR,\
  42. PLH_ACTIVITY_START, sizeof(*msg));\
  43. })
  44. #define splh_stop_activity ({\
  45. uint32_t temp, *msg = &temp;\
  46. *msg = cpu_to_le32(0); \
  47. plh_ops->stop_activity(plh_handle, msg, SCMI_SPLH_ALGO_STR,\
  48. PLH_ACTIVITY_STOP, sizeof(*msg));\
  49. })
  50. #define lplh_start_activity(lplh_notif) ({\
  51. uint32_t temp, *msg = &temp;\
  52. *msg = cpu_to_le32(lplh_notif); \
  53. plh_ops->start_activity(plh_handle, msg, SCMI_LPLH_ALGO_STR,\
  54. PLH_ACTIVITY_START, sizeof(*msg));\
  55. })
  56. #define lplh_stop_activity ({\
  57. uint32_t temp, *msg = &temp;\
  58. *msg = cpu_to_le32(0); \
  59. plh_ops->stop_activity(plh_handle, msg, SCMI_LPLH_ALGO_STR,\
  60. PLH_ACTIVITY_STOP, sizeof(*msg));\
  61. })
  62. #define splh_set_sample_ms(sample_ms) ({\
  63. uint32_t temp, *msg = &temp;\
  64. *msg = cpu_to_le32(sample_ms);\
  65. plh_ops->set_param(plh_handle, msg, SCMI_SPLH_ALGO_STR,\
  66. PLH_SET_SAMPLE_PERIOD_MS, sizeof(*msg));\
  67. })
  68. #define lplh_set_sample_ms(sample_ms) ({\
  69. uint32_t temp, *msg = &temp;\
  70. *msg = cpu_to_le32(sample_ms);\
  71. plh_ops->set_param(plh_handle, msg, SCMI_LPLH_ALGO_STR,\
  72. PLH_SET_SAMPLE_PERIOD_MS, sizeof(*msg));\
  73. })
  74. #define splh_set_log_level(log_level) ({\
  75. uint32_t temp, *msg = &temp;\
  76. *msg = cpu_to_le32(log_level);\
  77. plh_ops->set_param(plh_handle, msg, SCMI_SPLH_ALGO_STR,\
  78. PLH_SET_LOG_LEVEL, sizeof(*msg));\
  79. })
  80. #define lplh_set_log_level(log_level) ({\
  81. uint32_t temp, *msg = &temp;\
  82. *msg = cpu_to_le32(log_level);\
  83. ret = plh_ops->set_param(plh_handle, msg, SCMI_LPLH_ALGO_STR,\
  84. PLH_SET_LOG_LEVEL, sizeof(*msg));\
  85. })
  86. #define splh_init_ipc_freq_tbl(tmp, tmp_valid_len) ({\
  87. int idx = 0;\
  88. u16 tmp1[PLH_INIT_IPC_FREQ_TBL_PARAMS];\
  89. uint32_t *msg = (uint32_t *)tmp1, *tmsg = msg, msg_size, msg_val, \
  90. align_init_len = tmp_valid_len;\
  91. if (tmp_valid_len % 2) \
  92. align_init_len += 1; \
  93. msg_size = align_init_len * sizeof(*tmp); \
  94. for (i = 0; i < tmp_valid_len/2 ; i++) { \
  95. msg_val = tmp[idx++]; \
  96. msg_val |= ((tmp[idx++]) << 16); \
  97. *msg++ = cpu_to_le32(msg_val); \
  98. } \
  99. if (tmp_valid_len % 2) \
  100. *msg = cpu_to_le32(tmp[idx]); \
  101. plh_ops->set_param(plh_handle, tmsg, SCMI_SPLH_ALGO_STR,\
  102. PLH_INIT_IPC_FREQ_TBL, msg_size);\
  103. })
  104. #define lplh_init_ipc_freq_tbl(tmp, total_tokens) ({\
  105. int idx = 0; \
  106. u16 tmp1[LPLH_INIT_IPC_FREQ_TBL_PARAMS]; \
  107. uint32_t *msg = (uint32_t *)tmp1, *tmsg = msg, msg_size, msg_val, \
  108. align_init_len = total_tokens; \
  109. if (total_tokens % 2) \
  110. align_init_len += 1; \
  111. msg_size = align_init_len * sizeof(*tmp); \
  112. for (i = 0; i < total_tokens/2 ; i++) { \
  113. msg_val = tmp[idx++]; \
  114. msg_val |= ((tmp[idx++]) << 16); \
  115. *msg++ = cpu_to_le32(msg_val); \
  116. } \
  117. if (total_tokens % 2) \
  118. *msg = cpu_to_le32(tmp[idx]); \
  119. plh_ops->set_param(plh_handle, tmsg, SCMI_LPLH_ALGO_STR, \
  120. PLH_INIT_IPC_FREQ_TBL, msg_size); \
  121. })
  122. #else
  123. #define splh_start_activity(splh_notif) ({\
  124. plh_ops->start_plh(plh_handle,\
  125. splh_notif, PERF_LOCK_SCROLL);\
  126. })
  127. #define splh_stop_activity ({\
  128. plh_ops->stop_plh(plh_handle, PERF_LOCK_SCROLL);\
  129. })
  130. #define lplh_start_activity(lplh_notif) ({\
  131. plh_ops->start_plh(plh_handle,\
  132. lplh_notif, PERF_LOCK_LAUNCH);\
  133. })
  134. #define lplh_stop_activity ({\
  135. plh_ops->stop_plh(plh_handle, PERF_LOCK_LAUNCH);\
  136. })
  137. #define splh_set_sample_ms(sample_ms) ({\
  138. plh_ops->set_plh_sample_ms(plh_handle, sample_ms, PERF_LOCK_SCROLL);\
  139. })
  140. #define lplh_set_sample_ms(sample_ms) ({\
  141. plh_ops->set_plh_sample_ms(plh_handle, sample_ms, PERF_LOCK_LAUNCH);\
  142. })
  143. #define splh_set_log_level(log_level) ({\
  144. plh_ops->set_plh_log_level(plh_handle, log_level, PERF_LOCK_SCROLL);\
  145. })
  146. #define lplh_set_log_level(log_level) ({\
  147. plh_ops->set_plh_log_level(plh_handle, log_level, PERF_LOCK_LAUNCH);\
  148. })
  149. #define splh_init_ipc_freq_tbl(tmp, tmp_valid_len) ({\
  150. plh_ops->init_plh_ipc_freq_tbl(plh_handle, tmp, tmp_valid_len, PERF_LOCK_SCROLL);\
  151. })
  152. #define lplh_init_ipc_freq_tbl(tmp, total_tokens) ({\
  153. plh_ops->init_plh_ipc_freq_tbl(plh_handle, tmp, total_tokens, PERF_LOCK_LAUNCH); \
  154. })
  155. #endif
  156. #endif