1 /*************************************************************************/ /*!
3 @Title Server bridge for rgxtq2
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for rgxtq2
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 "rgxtdmtransfer.h"
52 #include "common_rgxtq2_bridge.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
62 #include <linux/slab.h>
65 #include "rgx_bvnc_defs_km.h"
70 /* ***************************************************************************
71 * Server-side bridge entry points
75 PVRSRVBridgeRGXTDMCreateTransferContext(IMG_UINT32 ui32DispatchTableEntry,
76 PVRSRV_BRIDGE_IN_RGXTDMCREATETRANSFERCONTEXT *psRGXTDMCreateTransferContextIN,
77 PVRSRV_BRIDGE_OUT_RGXTDMCREATETRANSFERCONTEXT *psRGXTDMCreateTransferContextOUT,
78 CONNECTION_DATA *psConnection)
80 IMG_BYTE *psFrameworkCmdInt = NULL;
81 IMG_HANDLE hPrivData = psRGXTDMCreateTransferContextIN->hPrivData;
82 IMG_HANDLE hPrivDataInt = NULL;
83 RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
85 IMG_UINT32 ui32NextOffset = 0;
86 IMG_BYTE *pArrayArgsBuffer = NULL;
87 #if !defined(INTEGRITY_OS)
88 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
91 IMG_UINT32 ui32BufferSize =
92 (psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) +
96 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
98 /* Check that device supports the required feature */
99 if ((psDeviceNode->pfnCheckDeviceFeature) &&
100 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
102 psRGXTDMCreateTransferContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
104 goto RGXTDMCreateTransferContext_exit;
111 if (ui32BufferSize != 0)
113 #if !defined(INTEGRITY_OS)
114 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
115 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXTDMCreateTransferContextIN), sizeof(unsigned long));
116 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
117 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
119 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
120 if (bHaveEnoughSpace)
122 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXTDMCreateTransferContextIN;
124 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
128 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
130 if(!pArrayArgsBuffer)
132 psRGXTDMCreateTransferContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
133 goto RGXTDMCreateTransferContext_exit;
138 if (psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize != 0)
140 psFrameworkCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
141 ui32NextOffset += psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE);
144 /* Copy the data over */
145 if (psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE) > 0)
147 if ( OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXTDMCreateTransferContextIN->psFrameworkCmd, psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) != PVRSRV_OK )
149 psRGXTDMCreateTransferContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
151 goto RGXTDMCreateTransferContext_exit;
155 /* Lock over handle lookup. */
163 /* Look up the address from the handle */
164 psRGXTDMCreateTransferContextOUT->eError =
165 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
166 (void **) &hPrivDataInt,
168 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
170 if(psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
173 goto RGXTDMCreateTransferContext_exit;
176 /* Release now we have looked up handles. */
179 psRGXTDMCreateTransferContextOUT->eError =
180 PVRSRVRGXTDMCreateTransferContextKM(psConnection, OSGetDevData(psConnection),
181 psRGXTDMCreateTransferContextIN->ui32Priority,
182 psRGXTDMCreateTransferContextIN->sMCUFenceAddr,
183 psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize,
186 &psTransferContextInt);
187 /* Exit early if bridged call fails */
188 if(psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
190 goto RGXTDMCreateTransferContext_exit;
193 /* Lock over handle creation. */
200 psRGXTDMCreateTransferContextOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
202 &psRGXTDMCreateTransferContextOUT->hTransferContext,
203 (void *) psTransferContextInt,
204 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
205 PVRSRV_HANDLE_ALLOC_FLAG_MULTI
206 ,(PFN_HANDLE_RELEASE)&PVRSRVRGXTDMDestroyTransferContextKM);
207 if (psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
210 goto RGXTDMCreateTransferContext_exit;
213 /* Release now we have created handles. */
218 RGXTDMCreateTransferContext_exit:
220 /* Lock over handle lookup cleanup. */
229 /* Unreference the previously looked up handle */
232 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
234 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
237 /* Release now we have cleaned up look up handles. */
240 if (psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
242 if (psTransferContextInt)
244 PVRSRVRGXTDMDestroyTransferContextKM(psTransferContextInt);
248 /* Allocated space should be equal to the last updated offset */
249 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
251 #if defined(INTEGRITY_OS)
254 if(!bHaveEnoughSpace && pArrayArgsBuffer)
256 OSFreeMemNoStats(pArrayArgsBuffer);
264 PVRSRVBridgeRGXTDMDestroyTransferContext(IMG_UINT32 ui32DispatchTableEntry,
265 PVRSRV_BRIDGE_IN_RGXTDMDESTROYTRANSFERCONTEXT *psRGXTDMDestroyTransferContextIN,
266 PVRSRV_BRIDGE_OUT_RGXTDMDESTROYTRANSFERCONTEXT *psRGXTDMDestroyTransferContextOUT,
267 CONNECTION_DATA *psConnection)
272 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
274 /* Check that device supports the required feature */
275 if ((psDeviceNode->pfnCheckDeviceFeature) &&
276 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
278 psRGXTDMDestroyTransferContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
280 goto RGXTDMDestroyTransferContext_exit;
290 /* Lock over handle destruction. */
297 psRGXTDMDestroyTransferContextOUT->eError =
298 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
299 (IMG_HANDLE) psRGXTDMDestroyTransferContextIN->hTransferContext,
300 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
301 if ((psRGXTDMDestroyTransferContextOUT->eError != PVRSRV_OK) &&
302 (psRGXTDMDestroyTransferContextOUT->eError != PVRSRV_ERROR_RETRY))
304 PVR_DPF((PVR_DBG_ERROR,
305 "PVRSRVBridgeRGXTDMDestroyTransferContext: %s",
306 PVRSRVGetErrorStringKM(psRGXTDMDestroyTransferContextOUT->eError)));
309 goto RGXTDMDestroyTransferContext_exit;
312 /* Release now we have destroyed handles. */
317 RGXTDMDestroyTransferContext_exit:
327 PVRSRVBridgeRGXTDMSubmitTransfer(IMG_UINT32 ui32DispatchTableEntry,
328 PVRSRV_BRIDGE_IN_RGXTDMSUBMITTRANSFER *psRGXTDMSubmitTransferIN,
329 PVRSRV_BRIDGE_OUT_RGXTDMSUBMITTRANSFER *psRGXTDMSubmitTransferOUT,
330 CONNECTION_DATA *psConnection)
332 IMG_HANDLE hTransferContext = psRGXTDMSubmitTransferIN->hTransferContext;
333 RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
334 SYNC_PRIMITIVE_BLOCK * *psFenceUFOSyncPrimBlockInt = NULL;
335 IMG_HANDLE *hFenceUFOSyncPrimBlockInt2 = NULL;
336 IMG_UINT32 *ui32FenceSyncOffsetInt = NULL;
337 IMG_UINT32 *ui32FenceValueInt = NULL;
338 SYNC_PRIMITIVE_BLOCK * *psUpdateUFOSyncPrimBlockInt = NULL;
339 IMG_HANDLE *hUpdateUFOSyncPrimBlockInt2 = NULL;
340 IMG_UINT32 *ui32UpdateSyncOffsetInt = NULL;
341 IMG_UINT32 *ui32UpdateValueInt = NULL;
342 IMG_UINT32 *ui32ServerSyncFlagsInt = NULL;
343 SERVER_SYNC_PRIMITIVE * *psServerSyncInt = NULL;
344 IMG_HANDLE *hServerSyncInt2 = NULL;
345 IMG_CHAR *uiUpdateFenceNameInt = NULL;
346 IMG_UINT8 *ui8FWCommandInt = NULL;
347 IMG_UINT32 *ui32SyncPMRFlagsInt = NULL;
348 PMR * *psSyncPMRsInt = NULL;
349 IMG_HANDLE *hSyncPMRsInt2 = NULL;
351 IMG_UINT32 ui32NextOffset = 0;
352 IMG_BYTE *pArrayArgsBuffer = NULL;
353 #if !defined(INTEGRITY_OS)
354 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
357 IMG_UINT32 ui32BufferSize =
358 (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
359 (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) +
360 (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
361 (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
362 (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
363 (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) +
364 (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
365 (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
366 (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) +
367 (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)) +
368 (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) +
369 (32 * sizeof(IMG_CHAR)) +
370 (psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8)) +
371 (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32)) +
372 (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(PMR *)) +
373 (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE)) +
377 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
379 /* Check that device supports the required feature */
380 if ((psDeviceNode->pfnCheckDeviceFeature) &&
381 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
383 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
385 goto RGXTDMSubmitTransfer_exit;
392 if (ui32BufferSize != 0)
394 #if !defined(INTEGRITY_OS)
395 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
396 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXTDMSubmitTransferIN), sizeof(unsigned long));
397 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
398 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
400 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
401 if (bHaveEnoughSpace)
403 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXTDMSubmitTransferIN;
405 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
409 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
411 if(!pArrayArgsBuffer)
413 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
414 goto RGXTDMSubmitTransfer_exit;
419 if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount != 0)
421 psFenceUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
422 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
423 hFenceUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
424 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE);
427 /* Copy the data over */
428 if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE) > 0)
430 if ( OSCopyFromUser(NULL, hFenceUFOSyncPrimBlockInt2, psRGXTDMSubmitTransferIN->phFenceUFOSyncPrimBlock, psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
432 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
434 goto RGXTDMSubmitTransfer_exit;
437 if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount != 0)
439 ui32FenceSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
440 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
443 /* Copy the data over */
444 if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
446 if ( OSCopyFromUser(NULL, ui32FenceSyncOffsetInt, psRGXTDMSubmitTransferIN->pui32FenceSyncOffset, psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
448 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
450 goto RGXTDMSubmitTransfer_exit;
453 if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount != 0)
455 ui32FenceValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
456 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
459 /* Copy the data over */
460 if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
462 if ( OSCopyFromUser(NULL, ui32FenceValueInt, psRGXTDMSubmitTransferIN->pui32FenceValue, psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
464 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
466 goto RGXTDMSubmitTransfer_exit;
469 if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount != 0)
471 psUpdateUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
472 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
473 hUpdateUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
474 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE);
477 /* Copy the data over */
478 if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE) > 0)
480 if ( OSCopyFromUser(NULL, hUpdateUFOSyncPrimBlockInt2, psRGXTDMSubmitTransferIN->phUpdateUFOSyncPrimBlock, psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
482 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
484 goto RGXTDMSubmitTransfer_exit;
487 if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount != 0)
489 ui32UpdateSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
490 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
493 /* Copy the data over */
494 if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
496 if ( OSCopyFromUser(NULL, ui32UpdateSyncOffsetInt, psRGXTDMSubmitTransferIN->pui32UpdateSyncOffset, psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
498 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
500 goto RGXTDMSubmitTransfer_exit;
503 if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount != 0)
505 ui32UpdateValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
506 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
509 /* Copy the data over */
510 if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
512 if ( OSCopyFromUser(NULL, ui32UpdateValueInt, psRGXTDMSubmitTransferIN->pui32UpdateValue, psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
514 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
516 goto RGXTDMSubmitTransfer_exit;
519 if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount != 0)
521 ui32ServerSyncFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
522 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32);
525 /* Copy the data over */
526 if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32) > 0)
528 if ( OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXTDMSubmitTransferIN->pui32ServerSyncFlags, psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
530 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
532 goto RGXTDMSubmitTransfer_exit;
535 if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount != 0)
537 psServerSyncInt = (SERVER_SYNC_PRIMITIVE **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
538 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *);
539 hServerSyncInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
540 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE);
543 /* Copy the data over */
544 if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE) > 0)
546 if ( OSCopyFromUser(NULL, hServerSyncInt2, psRGXTDMSubmitTransferIN->phServerSync, psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
548 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
550 goto RGXTDMSubmitTransfer_exit;
555 uiUpdateFenceNameInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
556 ui32NextOffset += 32 * sizeof(IMG_CHAR);
559 /* Copy the data over */
560 if (32 * sizeof(IMG_CHAR) > 0)
562 if ( OSCopyFromUser(NULL, uiUpdateFenceNameInt, psRGXTDMSubmitTransferIN->puiUpdateFenceName, 32 * sizeof(IMG_CHAR)) != PVRSRV_OK )
564 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
566 goto RGXTDMSubmitTransfer_exit;
569 if (psRGXTDMSubmitTransferIN->ui32CommandSize != 0)
571 ui8FWCommandInt = (IMG_UINT8*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
572 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8);
575 /* Copy the data over */
576 if (psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8) > 0)
578 if ( OSCopyFromUser(NULL, ui8FWCommandInt, psRGXTDMSubmitTransferIN->pui8FWCommand, psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8)) != PVRSRV_OK )
580 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
582 goto RGXTDMSubmitTransfer_exit;
585 if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount != 0)
587 ui32SyncPMRFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
588 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32);
591 /* Copy the data over */
592 if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32) > 0)
594 if ( OSCopyFromUser(NULL, ui32SyncPMRFlagsInt, psRGXTDMSubmitTransferIN->pui32SyncPMRFlags, psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
596 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
598 goto RGXTDMSubmitTransfer_exit;
601 if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount != 0)
603 psSyncPMRsInt = (PMR **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
604 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(PMR *);
605 hSyncPMRsInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
606 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE);
609 /* Copy the data over */
610 if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE) > 0)
612 if ( OSCopyFromUser(NULL, hSyncPMRsInt2, psRGXTDMSubmitTransferIN->phSyncPMRs, psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
614 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
616 goto RGXTDMSubmitTransfer_exit;
620 /* Lock over handle lookup. */
628 /* Look up the address from the handle */
629 psRGXTDMSubmitTransferOUT->eError =
630 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
631 (void **) &psTransferContextInt,
633 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
635 if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
638 goto RGXTDMSubmitTransfer_exit;
649 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientFenceCount;i++)
652 /* Look up the address from the handle */
653 psRGXTDMSubmitTransferOUT->eError =
654 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
655 (void **) &psFenceUFOSyncPrimBlockInt[i],
656 hFenceUFOSyncPrimBlockInt2[i],
657 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
659 if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
662 goto RGXTDMSubmitTransfer_exit;
675 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientUpdateCount;i++)
678 /* Look up the address from the handle */
679 psRGXTDMSubmitTransferOUT->eError =
680 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
681 (void **) &psUpdateUFOSyncPrimBlockInt[i],
682 hUpdateUFOSyncPrimBlockInt2[i],
683 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
685 if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
688 goto RGXTDMSubmitTransfer_exit;
701 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ServerSyncCount;i++)
704 /* Look up the address from the handle */
705 psRGXTDMSubmitTransferOUT->eError =
706 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
707 (void **) &psServerSyncInt[i],
709 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
711 if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
714 goto RGXTDMSubmitTransfer_exit;
727 for (i=0;i<psRGXTDMSubmitTransferIN->ui32SyncPMRCount;i++)
730 /* Look up the address from the handle */
731 psRGXTDMSubmitTransferOUT->eError =
732 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
733 (void **) &psSyncPMRsInt[i],
735 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
737 if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
740 goto RGXTDMSubmitTransfer_exit;
745 /* Release now we have looked up handles. */
748 psRGXTDMSubmitTransferOUT->eError =
749 PVRSRVRGXTDMSubmitTransferKM(
750 psTransferContextInt,
751 psRGXTDMSubmitTransferIN->ui32PDumpFlags,
752 psRGXTDMSubmitTransferIN->ui32ClientCacheOpSeqNum,
753 psRGXTDMSubmitTransferIN->ui32ClientFenceCount,
754 psFenceUFOSyncPrimBlockInt,
755 ui32FenceSyncOffsetInt,
757 psRGXTDMSubmitTransferIN->ui32ClientUpdateCount,
758 psUpdateUFOSyncPrimBlockInt,
759 ui32UpdateSyncOffsetInt,
761 psRGXTDMSubmitTransferIN->ui32ServerSyncCount,
762 ui32ServerSyncFlagsInt,
764 psRGXTDMSubmitTransferIN->i32CheckFenceFD,
765 psRGXTDMSubmitTransferIN->i32UpdateTimelineFD,
766 &psRGXTDMSubmitTransferOUT->i32UpdateFenceFD,
767 uiUpdateFenceNameInt,
768 psRGXTDMSubmitTransferIN->ui32CommandSize,
770 psRGXTDMSubmitTransferIN->ui32ExternalJobReference,
771 psRGXTDMSubmitTransferIN->ui32SyncPMRCount,
778 RGXTDMSubmitTransfer_exit:
780 /* Lock over handle lookup cleanup. */
789 /* Unreference the previously looked up handle */
790 if(psTransferContextInt)
792 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
794 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
805 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientFenceCount;i++)
808 /* Unreference the previously looked up handle */
809 if(psFenceUFOSyncPrimBlockInt[i])
811 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
812 hFenceUFOSyncPrimBlockInt2[i],
813 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
826 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientUpdateCount;i++)
829 /* Unreference the previously looked up handle */
830 if(psUpdateUFOSyncPrimBlockInt[i])
832 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
833 hUpdateUFOSyncPrimBlockInt2[i],
834 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
847 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ServerSyncCount;i++)
850 /* Unreference the previously looked up handle */
851 if(psServerSyncInt[i])
853 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
855 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
868 for (i=0;i<psRGXTDMSubmitTransferIN->ui32SyncPMRCount;i++)
871 /* Unreference the previously looked up handle */
874 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
876 PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
881 /* Release now we have cleaned up look up handles. */
884 /* Allocated space should be equal to the last updated offset */
885 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
887 #if defined(INTEGRITY_OS)
890 if(!bHaveEnoughSpace && pArrayArgsBuffer)
892 OSFreeMemNoStats(pArrayArgsBuffer);
900 PVRSRVBridgeRGXTDMSetTransferContextPriority(IMG_UINT32 ui32DispatchTableEntry,
901 PVRSRV_BRIDGE_IN_RGXTDMSETTRANSFERCONTEXTPRIORITY *psRGXTDMSetTransferContextPriorityIN,
902 PVRSRV_BRIDGE_OUT_RGXTDMSETTRANSFERCONTEXTPRIORITY *psRGXTDMSetTransferContextPriorityOUT,
903 CONNECTION_DATA *psConnection)
905 IMG_HANDLE hTransferContext = psRGXTDMSetTransferContextPriorityIN->hTransferContext;
906 RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
910 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
912 /* Check that device supports the required feature */
913 if ((psDeviceNode->pfnCheckDeviceFeature) &&
914 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
916 psRGXTDMSetTransferContextPriorityOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
918 goto RGXTDMSetTransferContextPriority_exit;
926 /* Lock over handle lookup. */
934 /* Look up the address from the handle */
935 psRGXTDMSetTransferContextPriorityOUT->eError =
936 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
937 (void **) &psTransferContextInt,
939 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
941 if(psRGXTDMSetTransferContextPriorityOUT->eError != PVRSRV_OK)
944 goto RGXTDMSetTransferContextPriority_exit;
947 /* Release now we have looked up handles. */
950 psRGXTDMSetTransferContextPriorityOUT->eError =
951 PVRSRVRGXTDMSetTransferContextPriorityKM(psConnection, OSGetDevData(psConnection),
952 psTransferContextInt,
953 psRGXTDMSetTransferContextPriorityIN->ui32Priority);
958 RGXTDMSetTransferContextPriority_exit:
960 /* Lock over handle lookup cleanup. */
969 /* Unreference the previously looked up handle */
970 if(psTransferContextInt)
972 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
974 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
977 /* Release now we have cleaned up look up handles. */
986 PVRSRVBridgeRGXTDMNotifyWriteOffsetUpdate(IMG_UINT32 ui32DispatchTableEntry,
987 PVRSRV_BRIDGE_IN_RGXTDMNOTIFYWRITEOFFSETUPDATE *psRGXTDMNotifyWriteOffsetUpdateIN,
988 PVRSRV_BRIDGE_OUT_RGXTDMNOTIFYWRITEOFFSETUPDATE *psRGXTDMNotifyWriteOffsetUpdateOUT,
989 CONNECTION_DATA *psConnection)
991 IMG_HANDLE hTransferContext = psRGXTDMNotifyWriteOffsetUpdateIN->hTransferContext;
992 RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
996 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
998 /* Check that device supports the required feature */
999 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1000 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
1002 psRGXTDMNotifyWriteOffsetUpdateOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1004 goto RGXTDMNotifyWriteOffsetUpdate_exit;
1012 /* Lock over handle lookup. */
1020 /* Look up the address from the handle */
1021 psRGXTDMNotifyWriteOffsetUpdateOUT->eError =
1022 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1023 (void **) &psTransferContextInt,
1025 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
1027 if(psRGXTDMNotifyWriteOffsetUpdateOUT->eError != PVRSRV_OK)
1030 goto RGXTDMNotifyWriteOffsetUpdate_exit;
1033 /* Release now we have looked up handles. */
1036 psRGXTDMNotifyWriteOffsetUpdateOUT->eError =
1037 PVRSRVRGXTDMNotifyWriteOffsetUpdateKM(
1038 psTransferContextInt,
1039 psRGXTDMNotifyWriteOffsetUpdateIN->ui32PDumpFlags);
1044 RGXTDMNotifyWriteOffsetUpdate_exit:
1046 /* Lock over handle lookup cleanup. */
1055 /* Unreference the previously looked up handle */
1056 if(psTransferContextInt)
1058 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1060 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
1063 /* Release now we have cleaned up look up handles. */
1073 /* ***************************************************************************
1074 * Server bridge dispatch related glue
1077 static IMG_BOOL bUseLock = IMG_TRUE;
1079 PVRSRV_ERROR InitRGXTQ2Bridge(void);
1080 PVRSRV_ERROR DeinitRGXTQ2Bridge(void);
1083 * Register all RGXTQ2 functions with services
1085 PVRSRV_ERROR InitRGXTQ2Bridge(void)
1088 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMCREATETRANSFERCONTEXT, PVRSRVBridgeRGXTDMCreateTransferContext,
1091 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMDESTROYTRANSFERCONTEXT, PVRSRVBridgeRGXTDMDestroyTransferContext,
1094 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMSUBMITTRANSFER, PVRSRVBridgeRGXTDMSubmitTransfer,
1097 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMSETTRANSFERCONTEXTPRIORITY, PVRSRVBridgeRGXTDMSetTransferContextPriority,
1100 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMNOTIFYWRITEOFFSETUPDATE, PVRSRVBridgeRGXTDMNotifyWriteOffsetUpdate,
1108 * Unregister all rgxtq2 functions with services
1110 PVRSRV_ERROR DeinitRGXTQ2Bridge(void)