mali_osk_profiling.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2010-2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. #ifndef __MALI_OSK_PROFILING_H__
  11. #define __MALI_OSK_PROFILING_H__
  12. #if defined(CONFIG_MALI400_PROFILING) && defined (CONFIG_TRACEPOINTS)
  13. #include "mali_linux_trace.h"
  14. #include "mali_profiling_events.h"
  15. #include "mali_profiling_gator_api.h"
  16. #define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576
  17. #define MALI_PROFILING_NO_HW_COUNTER = ((u32)-1)
  18. /** @defgroup _mali_osk_profiling External profiling connectivity
  19. * @{ */
  20. /**
  21. * Initialize the profiling module.
  22. * @return _MALI_OSK_ERR_OK on success, otherwise failure.
  23. */
  24. _mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start);
  25. /*
  26. * Terminate the profiling module.
  27. */
  28. void _mali_osk_profiling_term(void);
  29. /**
  30. * Start recording profiling data
  31. *
  32. * The specified limit will determine how large the capture buffer is.
  33. * MALI_PROFILING_MAX_BUFFER_ENTRIES determines the maximum size allowed by the device driver.
  34. *
  35. * @param limit The desired maximum number of events to record on input, the actual maximum on output.
  36. * @return _MALI_OSK_ERR_OK on success, otherwise failure.
  37. */
  38. _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit);
  39. /**
  40. * Add an profiling event
  41. *
  42. * @param event_id The event identificator.
  43. * @param data0 First data parameter, depending on event_id specified.
  44. * @param data1 Second data parameter, depending on event_id specified.
  45. * @param data2 Third data parameter, depending on event_id specified.
  46. * @param data3 Fourth data parameter, depending on event_id specified.
  47. * @param data4 Fifth data parameter, depending on event_id specified.
  48. * @return _MALI_OSK_ERR_OK on success, otherwise failure.
  49. */
  50. /* Call Linux tracepoint directly */
  51. #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) trace_mali_timeline_event((event_id), (data0), (data1), (data2), (data3), (data4))
  52. /**
  53. * Report a hardware counter event.
  54. *
  55. * @param counter_id The ID of the counter.
  56. * @param value The value of the counter.
  57. */
  58. /* Call Linux tracepoint directly */
  59. #define _mali_osk_profiling_report_hw_counter(counter_id, value) trace_mali_hw_counter(counter_id, value)
  60. /**
  61. * Report SW counters
  62. *
  63. * @param counters array of counter values
  64. */
  65. void _mali_osk_profiling_report_sw_counters(u32 *counters);
  66. /**
  67. * Stop recording profiling data
  68. *
  69. * @param count Returns the number of recorded events.
  70. * @return _MALI_OSK_ERR_OK on success, otherwise failure.
  71. */
  72. _mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count);
  73. /**
  74. * Retrieves the number of events that can be retrieved
  75. *
  76. * @return The number of recorded events that can be retrieved.
  77. */
  78. u32 _mali_osk_profiling_get_count(void);
  79. /**
  80. * Retrieve an event
  81. *
  82. * @param index Event index (start with 0 and continue until this function fails to retrieve all events)
  83. * @param timestamp The timestamp for the retrieved event will be stored here.
  84. * @param event_id The event ID for the retrieved event will be stored here.
  85. * @param data The 5 data values for the retrieved event will be stored here.
  86. * @return _MALI_OSK_ERR_OK on success, otherwise failure.
  87. */
  88. _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]);
  89. /**
  90. * Clear the recorded buffer.
  91. *
  92. * This is needed in order to start another recording.
  93. *
  94. * @return _MALI_OSK_ERR_OK on success, otherwise failure.
  95. */
  96. _mali_osk_errcode_t _mali_osk_profiling_clear(void);
  97. /**
  98. * Checks if a recording of profiling data is in progress
  99. *
  100. * @return MALI_TRUE if recording of profiling data is in progress, MALI_FALSE if not
  101. */
  102. mali_bool _mali_osk_profiling_is_recording(void);
  103. /**
  104. * Checks if profiling data is available for retrival
  105. *
  106. * @return MALI_TRUE if profiling data is avaiable, MALI_FALSE if not
  107. */
  108. mali_bool _mali_osk_profiling_have_recording(void);
  109. /** @} */ /* end group _mali_osk_profiling */
  110. #else /* defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_TRACEPOINTS) */
  111. /* Dummy add_event, for when profiling is disabled. */
  112. #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4)
  113. #endif /* defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_TRACEPOINTS) */
  114. #endif /* __MALI_OSK_PROFILING_H__ */