1 /*************************************************************************/ /*!
3 @Title Server bridge for rgxhwperf
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for rgxhwperf
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 */ /**************************************************************************/
45 #include <asm/uaccess.h>
49 #include "rgxhwperf.h"
52 #include "common_rgxhwperf_bridge.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
62 #if defined (SUPPORT_AUTH)
66 #include <linux/slab.h>
71 /* ***************************************************************************
72 * Server-side bridge entry points
76 PVRSRVBridgeRGXCtrlHWPerf(IMG_UINT32 ui32DispatchTableEntry,
77 PVRSRV_BRIDGE_IN_RGXCTRLHWPERF *psRGXCtrlHWPerfIN,
78 PVRSRV_BRIDGE_OUT_RGXCTRLHWPERF *psRGXCtrlHWPerfOUT,
79 CONNECTION_DATA *psConnection)
81 IMG_HANDLE hDevNodeInt = IMG_NULL;
90 /* Look up the address from the handle */
91 psRGXCtrlHWPerfOUT->eError =
92 PVRSRVLookupHandle(psConnection->psHandleBase,
93 (IMG_VOID **) &hDevNodeInt,
94 psRGXCtrlHWPerfIN->hDevNode,
95 PVRSRV_HANDLE_TYPE_DEV_NODE);
96 if(psRGXCtrlHWPerfOUT->eError != PVRSRV_OK)
98 goto RGXCtrlHWPerf_exit;
103 psRGXCtrlHWPerfOUT->eError =
104 PVRSRVRGXCtrlHWPerfKM(
106 psRGXCtrlHWPerfIN->bToggle,
107 psRGXCtrlHWPerfIN->ui64Mask);
118 PVRSRVBridgeRGXConfigEnableHWPerfCounters(IMG_UINT32 ui32DispatchTableEntry,
119 PVRSRV_BRIDGE_IN_RGXCONFIGENABLEHWPERFCOUNTERS *psRGXConfigEnableHWPerfCountersIN,
120 PVRSRV_BRIDGE_OUT_RGXCONFIGENABLEHWPERFCOUNTERS *psRGXConfigEnableHWPerfCountersOUT,
121 CONNECTION_DATA *psConnection)
123 IMG_HANDLE hDevNodeInt = IMG_NULL;
124 RGX_HWPERF_CONFIG_CNTBLK *psBlockConfigsInt = IMG_NULL;
129 if (psRGXConfigEnableHWPerfCountersIN->ui32ArrayLen != 0)
131 psBlockConfigsInt = OSAllocMem(psRGXConfigEnableHWPerfCountersIN->ui32ArrayLen * sizeof(RGX_HWPERF_CONFIG_CNTBLK));
132 if (!psBlockConfigsInt)
134 psRGXConfigEnableHWPerfCountersOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
136 goto RGXConfigEnableHWPerfCounters_exit;
140 /* Copy the data over */
141 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXConfigEnableHWPerfCountersIN->psBlockConfigs, psRGXConfigEnableHWPerfCountersIN->ui32ArrayLen * sizeof(RGX_HWPERF_CONFIG_CNTBLK))
142 || (OSCopyFromUser(NULL, psBlockConfigsInt, psRGXConfigEnableHWPerfCountersIN->psBlockConfigs,
143 psRGXConfigEnableHWPerfCountersIN->ui32ArrayLen * sizeof(RGX_HWPERF_CONFIG_CNTBLK)) != PVRSRV_OK) )
145 psRGXConfigEnableHWPerfCountersOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
147 goto RGXConfigEnableHWPerfCounters_exit;
153 /* Look up the address from the handle */
154 psRGXConfigEnableHWPerfCountersOUT->eError =
155 PVRSRVLookupHandle(psConnection->psHandleBase,
156 (IMG_VOID **) &hDevNodeInt,
157 psRGXConfigEnableHWPerfCountersIN->hDevNode,
158 PVRSRV_HANDLE_TYPE_DEV_NODE);
159 if(psRGXConfigEnableHWPerfCountersOUT->eError != PVRSRV_OK)
161 goto RGXConfigEnableHWPerfCounters_exit;
166 psRGXConfigEnableHWPerfCountersOUT->eError =
167 PVRSRVRGXConfigEnableHWPerfCountersKM(
169 psRGXConfigEnableHWPerfCountersIN->ui32ArrayLen,
175 RGXConfigEnableHWPerfCounters_exit:
176 if (psBlockConfigsInt)
177 OSFreeMem(psBlockConfigsInt);
183 PVRSRVBridgeRGXCtrlHWPerfCounters(IMG_UINT32 ui32DispatchTableEntry,
184 PVRSRV_BRIDGE_IN_RGXCTRLHWPERFCOUNTERS *psRGXCtrlHWPerfCountersIN,
185 PVRSRV_BRIDGE_OUT_RGXCTRLHWPERFCOUNTERS *psRGXCtrlHWPerfCountersOUT,
186 CONNECTION_DATA *psConnection)
188 IMG_HANDLE hDevNodeInt = IMG_NULL;
189 IMG_UINT16 *ui16BlockIDsInt = IMG_NULL;
194 if (psRGXCtrlHWPerfCountersIN->ui32ArrayLen != 0)
196 ui16BlockIDsInt = OSAllocMem(psRGXCtrlHWPerfCountersIN->ui32ArrayLen * sizeof(IMG_UINT16));
197 if (!ui16BlockIDsInt)
199 psRGXCtrlHWPerfCountersOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
201 goto RGXCtrlHWPerfCounters_exit;
205 /* Copy the data over */
206 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXCtrlHWPerfCountersIN->pui16BlockIDs, psRGXCtrlHWPerfCountersIN->ui32ArrayLen * sizeof(IMG_UINT16))
207 || (OSCopyFromUser(NULL, ui16BlockIDsInt, psRGXCtrlHWPerfCountersIN->pui16BlockIDs,
208 psRGXCtrlHWPerfCountersIN->ui32ArrayLen * sizeof(IMG_UINT16)) != PVRSRV_OK) )
210 psRGXCtrlHWPerfCountersOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
212 goto RGXCtrlHWPerfCounters_exit;
218 /* Look up the address from the handle */
219 psRGXCtrlHWPerfCountersOUT->eError =
220 PVRSRVLookupHandle(psConnection->psHandleBase,
221 (IMG_VOID **) &hDevNodeInt,
222 psRGXCtrlHWPerfCountersIN->hDevNode,
223 PVRSRV_HANDLE_TYPE_DEV_NODE);
224 if(psRGXCtrlHWPerfCountersOUT->eError != PVRSRV_OK)
226 goto RGXCtrlHWPerfCounters_exit;
231 psRGXCtrlHWPerfCountersOUT->eError =
232 PVRSRVRGXCtrlHWPerfCountersKM(
234 psRGXCtrlHWPerfCountersIN->bEnable,
235 psRGXCtrlHWPerfCountersIN->ui32ArrayLen,
241 RGXCtrlHWPerfCounters_exit:
243 OSFreeMem(ui16BlockIDsInt);
249 PVRSRVBridgeRGXConfigCustomCounters(IMG_UINT32 ui32DispatchTableEntry,
250 PVRSRV_BRIDGE_IN_RGXCONFIGCUSTOMCOUNTERS *psRGXConfigCustomCountersIN,
251 PVRSRV_BRIDGE_OUT_RGXCONFIGCUSTOMCOUNTERS *psRGXConfigCustomCountersOUT,
252 CONNECTION_DATA *psConnection)
254 IMG_HANDLE hDevNodeInt = IMG_NULL;
255 IMG_UINT32 *ui32CustomCounterIDsInt = IMG_NULL;
260 if (psRGXConfigCustomCountersIN->ui16NumCustomCounters != 0)
262 ui32CustomCounterIDsInt = OSAllocMem(psRGXConfigCustomCountersIN->ui16NumCustomCounters * sizeof(IMG_UINT32));
263 if (!ui32CustomCounterIDsInt)
265 psRGXConfigCustomCountersOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
267 goto RGXConfigCustomCounters_exit;
271 /* Copy the data over */
272 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXConfigCustomCountersIN->pui32CustomCounterIDs, psRGXConfigCustomCountersIN->ui16NumCustomCounters * sizeof(IMG_UINT32))
273 || (OSCopyFromUser(NULL, ui32CustomCounterIDsInt, psRGXConfigCustomCountersIN->pui32CustomCounterIDs,
274 psRGXConfigCustomCountersIN->ui16NumCustomCounters * sizeof(IMG_UINT32)) != PVRSRV_OK) )
276 psRGXConfigCustomCountersOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
278 goto RGXConfigCustomCounters_exit;
284 /* Look up the address from the handle */
285 psRGXConfigCustomCountersOUT->eError =
286 PVRSRVLookupHandle(psConnection->psHandleBase,
287 (IMG_VOID **) &hDevNodeInt,
288 psRGXConfigCustomCountersIN->hDevNode,
289 PVRSRV_HANDLE_TYPE_DEV_NODE);
290 if(psRGXConfigCustomCountersOUT->eError != PVRSRV_OK)
292 goto RGXConfigCustomCounters_exit;
297 psRGXConfigCustomCountersOUT->eError =
298 PVRSRVRGXConfigCustomCountersKM(
300 psRGXConfigCustomCountersIN->ui16CustomBlockID,
301 psRGXConfigCustomCountersIN->ui16NumCustomCounters,
302 ui32CustomCounterIDsInt);
307 RGXConfigCustomCounters_exit:
308 if (ui32CustomCounterIDsInt)
309 OSFreeMem(ui32CustomCounterIDsInt);
316 /* ***************************************************************************
317 * Server bridge dispatch related glue
321 PVRSRV_ERROR InitRGXHWPERFBridge(IMG_VOID);
322 PVRSRV_ERROR DeinitRGXHWPERFBridge(IMG_VOID);
325 * Register all RGXHWPERF functions with services
327 PVRSRV_ERROR InitRGXHWPERFBridge(IMG_VOID)
330 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXHWPERF, PVRSRV_BRIDGE_RGXHWPERF_RGXCTRLHWPERF, PVRSRVBridgeRGXCtrlHWPerf,
334 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXHWPERF, PVRSRV_BRIDGE_RGXHWPERF_RGXCONFIGENABLEHWPERFCOUNTERS, PVRSRVBridgeRGXConfigEnableHWPerfCounters,
338 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXHWPERF, PVRSRV_BRIDGE_RGXHWPERF_RGXCTRLHWPERFCOUNTERS, PVRSRVBridgeRGXCtrlHWPerfCounters,
342 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXHWPERF, PVRSRV_BRIDGE_RGXHWPERF_RGXCONFIGCUSTOMCOUNTERS, PVRSRVBridgeRGXConfigCustomCounters,
351 * Unregister all rgxhwperf functions with services
353 PVRSRV_ERROR DeinitRGXHWPERFBridge(IMG_VOID)