1 /* 2 * Copyright (C) 2010-2017 ARM Limited. All rights reserved. 3 * 4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2 5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence. 6 * 7 * A copy of the licence is included with the program, and can also be obtained from Free Software 8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 9 */ 10 11 #ifndef __MALI_OSK_PROFILING_H__ 12 #define __MALI_OSK_PROFILING_H__ 13 14 #if defined(CONFIG_MALI400_PROFILING) && defined (CONFIG_TRACEPOINTS) 15 16 #include "mali_linux_trace.h" 17 #include "mali_profiling_events.h" 18 #include "mali_profiling_gator_api.h" 19 20 #define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576 21 22 #define MALI_PROFILING_NO_HW_COUNTER = ((u32)-1) 23 24 /** @defgroup _mali_osk_profiling External profiling connectivity 25 * @{ */ 26 27 /** 28 * Initialize the profiling module. 29 * @return _MALI_OSK_ERR_OK on success, otherwise failure. 30 */ 31 _mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start); 32 33 /* 34 * Terminate the profiling module. 35 */ 36 void _mali_osk_profiling_term(void); 37 38 /** 39 * Stop the profile sampling operation. 40 */ 41 void _mali_osk_profiling_stop_sampling(u32 pid); 42 43 /** 44 * Start recording profiling data 45 * 46 * The specified limit will determine how large the capture buffer is. 47 * MALI_PROFILING_MAX_BUFFER_ENTRIES determines the maximum size allowed by the device driver. 48 * 49 * @param limit The desired maximum number of events to record on input, the actual maximum on output. 50 * @return _MALI_OSK_ERR_OK on success, otherwise failure. 51 */ 52 _mali_osk_errcode_t _mali_osk_profiling_start(u32 *limit); 53 54 /** 55 * Add an profiling event 56 * 57 * @param event_id The event identificator. 58 * @param data0 First data parameter, depending on event_id specified. 59 * @param data1 Second data parameter, depending on event_id specified. 60 * @param data2 Third data parameter, depending on event_id specified. 61 * @param data3 Fourth data parameter, depending on event_id specified. 62 * @param data4 Fifth data parameter, depending on event_id specified. 63 */ 64 void _mali_osk_profiling_add_event(u32 event_id, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4); 65 66 /** 67 * Report a hardware counter event. 68 * 69 * @param counter_id The ID of the counter. 70 * @param value The value of the counter. 71 */ 72 73 /* Call Linux tracepoint directly */ 74 #define _mali_osk_profiling_report_hw_counter(counter_id, value) trace_mali_hw_counter(counter_id, value) 75 76 /** 77 * Report SW counters 78 * 79 * @param counters array of counter values 80 */ 81 void _mali_osk_profiling_report_sw_counters(u32 *counters); 82 83 void _mali_osk_profiling_record_global_counters(int counter_id, u32 value); 84 85 /** 86 * Stop recording profiling data 87 * 88 * @param count Returns the number of recorded events. 89 * @return _MALI_OSK_ERR_OK on success, otherwise failure. 90 */ 91 _mali_osk_errcode_t _mali_osk_profiling_stop(u32 *count); 92 93 /** 94 * Retrieves the number of events that can be retrieved 95 * 96 * @return The number of recorded events that can be retrieved. 97 */ 98 u32 _mali_osk_profiling_get_count(void); 99 100 /** 101 * Retrieve an event 102 * 103 * @param index Event index (start with 0 and continue until this function fails to retrieve all events) 104 * @param timestamp The timestamp for the retrieved event will be stored here. 105 * @param event_id The event ID for the retrieved event will be stored here. 106 * @param data The 5 data values for the retrieved event will be stored here. 107 * @return _MALI_OSK_ERR_OK on success, otherwise failure. 108 */ 109 _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64 *timestamp, u32 *event_id, u32 data[5]); 110 111 /** 112 * Clear the recorded buffer. 113 * 114 * This is needed in order to start another recording. 115 * 116 * @return _MALI_OSK_ERR_OK on success, otherwise failure. 117 */ 118 _mali_osk_errcode_t _mali_osk_profiling_clear(void); 119 120 /** 121 * Checks if a recording of profiling data is in progress 122 * 123 * @return MALI_TRUE if recording of profiling data is in progress, MALI_FALSE if not 124 */ 125 mali_bool _mali_osk_profiling_is_recording(void); 126 127 /** 128 * Checks if profiling data is available for retrival 129 * 130 * @return MALI_TRUE if profiling data is avaiable, MALI_FALSE if not 131 */ 132 mali_bool _mali_osk_profiling_have_recording(void); 133 134 /** @} */ /* end group _mali_osk_profiling */ 135 136 #else /* defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_TRACEPOINTS) */ 137 138 /* Dummy add_event, for when profiling is disabled. */ 139 140 #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) 141 142 #endif /* defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_TRACEPOINTS) */ 143 144 #endif /* __MALI_OSK_PROFILING_H__ */ 145 146 147