1 /*************************************************************************/ /*!
3 @Title RGX HW Performance header file
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Header for the RGX HWPerf functions
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
47 #include "img_types.h"
49 #include "pvrsrv_error.h"
52 #include "connection_server.h"
53 #include "rgxdevice.h"
54 #include "rgx_hwperf_km.h"
57 /******************************************************************************
58 * RGX HW Performance Data Transport Routines
59 *****************************************************************************/
61 PVRSRV_ERROR RGXHWPerfDataStoreCB(PVRSRV_DEVICE_NODE* psDevInfo);
63 PVRSRV_ERROR RGXHWPerfInit(PVRSRV_DEVICE_NODE *psRgxDevInfo);
64 PVRSRV_ERROR RGXHWPerfInitOnDemandResources(void);
65 void RGXHWPerfDeinit(void);
66 void RGXHWPerfInitAppHintCallbacks(const PVRSRV_DEVICE_NODE *psDeviceNode);
68 /******************************************************************************
69 * RGX HW Performance Profiling API(s)
70 *****************************************************************************/
72 PVRSRV_ERROR PVRSRVRGXCtrlHWPerfKM(
73 CONNECTION_DATA * psConnection,
74 PVRSRV_DEVICE_NODE * psDeviceNode,
75 RGX_HWPERF_STREAM_ID eStreamId,
80 PVRSRV_ERROR PVRSRVRGXConfigEnableHWPerfCountersKM(
81 CONNECTION_DATA * psConnection,
82 PVRSRV_DEVICE_NODE * psDeviceNode,
83 IMG_UINT32 ui32ArrayLen,
84 RGX_HWPERF_CONFIG_CNTBLK * psBlockConfigs);
86 PVRSRV_ERROR PVRSRVRGXCtrlHWPerfCountersKM(
87 CONNECTION_DATA * psConnection,
88 PVRSRV_DEVICE_NODE * psDeviceNode,
90 IMG_UINT32 ui32ArrayLen,
91 IMG_UINT16 * psBlockIDs);
93 PVRSRV_ERROR PVRSRVRGXConfigCustomCountersKM(
94 CONNECTION_DATA * psConnection,
95 PVRSRV_DEVICE_NODE * psDeviceNode,
96 IMG_UINT16 ui16CustomBlockID,
97 IMG_UINT16 ui16NumCustomCounters,
98 IMG_UINT32 * pui32CustomCounterIDs);
100 /******************************************************************************
101 * RGX HW Performance Host Stream API
102 *****************************************************************************/
104 PVRSRV_ERROR RGXHWPerfHostInit(IMG_UINT32 ui32BufSizeKB);
105 PVRSRV_ERROR RGXHWPerfHostInitOnDemandResources(void);
106 void RGXHWPerfHostDeInit(void);
108 void RGXHWPerfHostSetEventFilter(IMG_UINT32 ui32Filter);
110 void RGXHWPerfHostPostCtrlEvent(RGX_HWPERF_HOST_CTRL_TYPE eEvType,
113 void RGXHWPerfHostPostEnqEvent(RGX_HWPERF_KICK_TYPE eEnqType,
115 IMG_UINT32 ui32FWDMContext,
116 IMG_UINT32 ui32ExtJobRef,
117 IMG_UINT32 ui32IntJobRef);
119 void RGXHWPerfHostPostAllocEvent(RGX_HWPERF_HOST_RESOURCE_TYPE eAllocType,
120 IMG_UINT32 ui32FWAddr,
121 const IMG_CHAR *psName,
122 IMG_UINT32 ui32NameSize);
124 void RGXHWPerfHostPostFreeEvent(RGX_HWPERF_HOST_RESOURCE_TYPE eFreeType,
125 IMG_UINT32 ui32FWAddr);
127 void RGXHWPerfHostPostUfoEvent(RGX_HWPERF_UFO_EV eUfoType,
128 RGX_HWPERF_UFO_DATA_ELEMENT psUFOData[],
129 IMG_UINT uiNoOfUFOs);
131 void RGXHWPerfHostPostClkSyncEvent(void);
133 IMG_BOOL RGXHWPerfHostIsEventEnabled(RGX_HWPERF_HOST_EVENT_TYPE eEvent);
135 #define _RGX_HWPERF_HOST_FILTER(CTX, EV) \
136 (((PVRSRV_RGXDEV_INFO *)CTX->psDeviceNode->pvDevice)->ui32HWPerfHostFilter \
137 & RGX_HWPERF_EVENT_MASK_VALUE(EV))
140 * This macro checks if HWPerfHost and the event are enabled and if they are
141 * it posts event to the HWPerfHost stream.
144 * @param P process id (PID)
145 * @param X firmware context
150 #if defined(PVRSRV_GPUVIRT_GUESTDRV)
151 #define RGX_HWPERF_HOST_CTRL(E, P) \
153 PVR_UNREFERENCED_PARAMETER(P); \
156 #define RGX_HWPERF_HOST_ENQ(C, P, X, E, I, K) \
158 PVR_UNREFERENCED_PARAMETER(X); \
159 PVR_UNREFERENCED_PARAMETER(E); \
160 PVR_UNREFERENCED_PARAMETER(I); \
163 #define RGX_HWPERF_HOST_UFO(T, D, N) \
165 PVR_UNREFERENCED_PARAMETER(T); \
166 PVR_UNREFERENCED_PARAMETER(D); \
167 PVR_UNREFERENCED_PARAMETER(N); \
170 #define RGX_HWPERF_HOST_ALLOC(T, F, N, Z) \
172 PVR_UNREFERENCED_PARAMETER(RGX_HWPERF_HOST_RESOURCE_TYPE_##T); \
173 PVR_UNREFERENCED_PARAMETER(F); \
174 PVR_UNREFERENCED_PARAMETER(N); \
175 PVR_UNREFERENCED_PARAMETER(Z); \
178 #define RGX_HWPERF_HOST_FREE(T, F) \
180 PVR_UNREFERENCED_PARAMETER(RGX_HWPERF_HOST_RESOURCE_TYPE_##T); \
181 PVR_UNREFERENCED_PARAMETER(F); \
184 #define RGX_HWPERF_HOST_CLK_SYNC()
187 * @param E event type
190 #define RGX_HWPERF_HOST_CTRL(E, P) \
192 if (RGXHWPerfHostIsEventEnabled(RGX_HWPERF_HOST_CTRL)) \
194 RGXHWPerfHostPostCtrlEvent(RGX_HWPERF_CTRL_TYPE_##E, (P)); \
198 #define RGX_HWPERF_HOST_ENQ(C, P, X, E, I, K) \
200 if (_RGX_HWPERF_HOST_FILTER(C, RGX_HWPERF_HOST_ENQ)) \
202 RGXHWPerfHostPostEnqEvent((K), (P), (X), (E), (I)); \
207 * This macro checks if HWPerfHost and the event are enabled and if they are
208 * it posts event to the HWPerfHost stream.
210 * @param T Host UFO event type
211 * @param D UFO data array
212 * @param N number of syncs in data array
214 #define RGX_HWPERF_HOST_UFO(T, D, N) \
216 if (RGXHWPerfHostIsEventEnabled(RGX_HWPERF_HOST_UFO)) \
218 RGXHWPerfHostPostUfoEvent((T), (D), (N)); \
223 * This macro checks if HWPerfHost and the event are enabled and if they are
224 * it posts event to the HWPerfHost stream.
226 * @param F sync firmware address
227 * @param S boolean value telling if this is a server sync
228 * @param N string containing sync name
229 * @param Z string size including null terminating character
231 #define RGX_HWPERF_HOST_ALLOC(T, F, N, Z) \
233 if (RGXHWPerfHostIsEventEnabled(RGX_HWPERF_HOST_ALLOC)) \
235 RGXHWPerfHostPostAllocEvent(RGX_HWPERF_HOST_RESOURCE_TYPE_##T, \
241 * This macro checks if HWPerfHost and the event are enabled and if they are
242 * it posts event to the HWPerfHost stream.
244 * @param F sync firmware address
246 #define RGX_HWPERF_HOST_FREE(T, F) \
248 if (RGXHWPerfHostIsEventEnabled(RGX_HWPERF_HOST_FREE)) \
250 RGXHWPerfHostPostFreeEvent(RGX_HWPERF_HOST_RESOURCE_TYPE_##T, \
256 * This macro checks if HWPerfHost and the event are enabled and if they are
257 * it posts event to the HWPerfHost stream.
259 #define RGX_HWPERF_HOST_CLK_SYNC() \
261 if (RGXHWPerfHostIsEventEnabled(RGX_HWPERF_HOST_CLK_SYNC)) \
263 RGXHWPerfHostPostClkSyncEvent(); \
268 /******************************************************************************
269 * RGX HW Performance To FTrace Profiling API(s)
270 *****************************************************************************/
272 #if defined(SUPPORT_GPUTRACE_EVENTS)
274 PVRSRV_ERROR RGXHWPerfFTraceGPUInit(PVRSRV_DEVICE_NODE *psDeviceNode);
275 void RGXHWPerfFTraceGPUDeInit(PVRSRV_DEVICE_NODE *psDeviceNode);
277 void RGXHWPerfFTraceGPUEnqueueEvent(PVRSRV_RGXDEV_INFO *psDevInfo,
278 IMG_UINT32 ui32ExternalJobRef, IMG_UINT32 ui32InternalJobRef,
279 RGX_HWPERF_KICK_TYPE eKickType);
281 PVRSRV_ERROR RGXHWPerfFTraceGPUEventsEnabledSet(IMG_BOOL bNewValue);
283 void RGXHWPerfFTraceGPUThread(void *pvData);
287 /******************************************************************************
288 * RGX HW utils functions
289 *****************************************************************************/
291 const IMG_CHAR *RGXHWPerfKickTypeToStr(RGX_HWPERF_KICK_TYPE eKickType);
293 #endif /* RGXHWPERF_H_ */