import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / common / mali_osk_profiling.h
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
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 * Start recording profiling data
40 *
41 * The specified limit will determine how large the capture buffer is.
42 * MALI_PROFILING_MAX_BUFFER_ENTRIES determines the maximum size allowed by the device driver.
43 *
44 * @param limit The desired maximum number of events to record on input, the actual maximum on output.
45 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
46 */
47 _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit);
48
49 /**
50 * Add an profiling event
51 *
52 * @param event_id The event identificator.
53 * @param data0 First data parameter, depending on event_id specified.
54 * @param data1 Second data parameter, depending on event_id specified.
55 * @param data2 Third data parameter, depending on event_id specified.
56 * @param data3 Fourth data parameter, depending on event_id specified.
57 * @param data4 Fifth data parameter, depending on event_id specified.
58 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
59 */
60 /* Call Linux tracepoint directly */
61 #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) trace_mali_timeline_event((event_id), (data0), (data1), (data2), (data3), (data4))
62
63 /**
64 * Report a hardware counter event.
65 *
66 * @param counter_id The ID of the counter.
67 * @param value The value of the counter.
68 */
69
70 /* Call Linux tracepoint directly */
71 #define _mali_osk_profiling_report_hw_counter(counter_id, value) trace_mali_hw_counter(counter_id, value)
72
73 /**
74 * Report SW counters
75 *
76 * @param counters array of counter values
77 */
78 void _mali_osk_profiling_report_sw_counters(u32 *counters);
79
80 /**
81 * Stop recording profiling data
82 *
83 * @param count Returns the number of recorded events.
84 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
85 */
86 _mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count);
87
88 /**
89 * Retrieves the number of events that can be retrieved
90 *
91 * @return The number of recorded events that can be retrieved.
92 */
93 u32 _mali_osk_profiling_get_count(void);
94
95 /**
96 * Retrieve an event
97 *
98 * @param index Event index (start with 0 and continue until this function fails to retrieve all events)
99 * @param timestamp The timestamp for the retrieved event will be stored here.
100 * @param event_id The event ID for the retrieved event will be stored here.
101 * @param data The 5 data values for the retrieved event will be stored here.
102 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
103 */
104 _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]);
105
106 /**
107 * Clear the recorded buffer.
108 *
109 * This is needed in order to start another recording.
110 *
111 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
112 */
113 _mali_osk_errcode_t _mali_osk_profiling_clear(void);
114
115 /**
116 * Checks if a recording of profiling data is in progress
117 *
118 * @return MALI_TRUE if recording of profiling data is in progress, MALI_FALSE if not
119 */
120 mali_bool _mali_osk_profiling_is_recording(void);
121
122 /**
123 * Checks if profiling data is available for retrival
124 *
125 * @return MALI_TRUE if profiling data is avaiable, MALI_FALSE if not
126 */
127 mali_bool _mali_osk_profiling_have_recording(void);
128
129 /** @} */ /* end group _mali_osk_profiling */
130
131 #else /* defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_TRACEPOINTS) */
132
133 /* Dummy add_event, for when profiling is disabled. */
134
135 #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4)
136
137 #endif /* defined(CONFIG_MALI400_PROFILING) && defined(CONFIG_TRACEPOINTS) */
138
139 #endif /* __MALI_OSK_PROFILING_H__ */
140
141