1 /*************************************************************************/ /*!
3 @Title Server bridge for rgxtq
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for rgxtq
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 "rgxtransfer.h"
52 #include "common_rgxtq_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 PVRSRVBridgeRGXCreateTransferContext(IMG_UINT32 ui32DispatchTableEntry,
77 PVRSRV_BRIDGE_IN_RGXCREATETRANSFERCONTEXT *psRGXCreateTransferContextIN,
78 PVRSRV_BRIDGE_OUT_RGXCREATETRANSFERCONTEXT *psRGXCreateTransferContextOUT,
79 CONNECTION_DATA *psConnection)
81 IMG_HANDLE hDevNodeInt = IMG_NULL;
82 IMG_BYTE *psFrameworkCmdInt = IMG_NULL;
83 IMG_HANDLE hPrivDataInt = IMG_NULL;
84 RGX_SERVER_TQ_CONTEXT * psTransferContextInt = IMG_NULL;
89 if (psRGXCreateTransferContextIN->ui32FrameworkCmdize != 0)
91 psFrameworkCmdInt = OSAllocMem(psRGXCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE));
92 if (!psFrameworkCmdInt)
94 psRGXCreateTransferContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
96 goto RGXCreateTransferContext_exit;
100 /* Copy the data over */
101 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXCreateTransferContextIN->psFrameworkCmd, psRGXCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE))
102 || (OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXCreateTransferContextIN->psFrameworkCmd,
103 psRGXCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) != PVRSRV_OK) )
105 psRGXCreateTransferContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
107 goto RGXCreateTransferContext_exit;
113 /* Look up the address from the handle */
114 psRGXCreateTransferContextOUT->eError =
115 PVRSRVLookupHandle(psConnection->psHandleBase,
116 (IMG_VOID **) &hDevNodeInt,
117 psRGXCreateTransferContextIN->hDevNode,
118 PVRSRV_HANDLE_TYPE_DEV_NODE);
119 if(psRGXCreateTransferContextOUT->eError != PVRSRV_OK)
121 goto RGXCreateTransferContext_exit;
127 /* Look up the address from the handle */
128 psRGXCreateTransferContextOUT->eError =
129 PVRSRVLookupHandle(psConnection->psHandleBase,
130 (IMG_VOID **) &hPrivDataInt,
131 psRGXCreateTransferContextIN->hPrivData,
132 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
133 if(psRGXCreateTransferContextOUT->eError != PVRSRV_OK)
135 goto RGXCreateTransferContext_exit;
140 psRGXCreateTransferContextOUT->eError =
141 PVRSRVRGXCreateTransferContextKM(psConnection,
143 psRGXCreateTransferContextIN->ui32Priority,
144 psRGXCreateTransferContextIN->sMCUFenceAddr,
145 psRGXCreateTransferContextIN->ui32FrameworkCmdize,
148 &psTransferContextInt);
149 /* Exit early if bridged call fails */
150 if(psRGXCreateTransferContextOUT->eError != PVRSRV_OK)
152 goto RGXCreateTransferContext_exit;
156 psRGXCreateTransferContextOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
157 &psRGXCreateTransferContextOUT->hTransferContext,
158 (IMG_VOID *) psTransferContextInt,
159 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_CONTEXT,
160 PVRSRV_HANDLE_ALLOC_FLAG_MULTI
161 ,(PFN_HANDLE_RELEASE)&PVRSRVRGXDestroyTransferContextKM);
162 if (psRGXCreateTransferContextOUT->eError != PVRSRV_OK)
164 goto RGXCreateTransferContext_exit;
170 RGXCreateTransferContext_exit:
171 if (psRGXCreateTransferContextOUT->eError != PVRSRV_OK)
173 if (psTransferContextInt)
175 PVRSRVRGXDestroyTransferContextKM(psTransferContextInt);
179 if (psFrameworkCmdInt)
180 OSFreeMem(psFrameworkCmdInt);
186 PVRSRVBridgeRGXDestroyTransferContext(IMG_UINT32 ui32DispatchTableEntry,
187 PVRSRV_BRIDGE_IN_RGXDESTROYTRANSFERCONTEXT *psRGXDestroyTransferContextIN,
188 PVRSRV_BRIDGE_OUT_RGXDESTROYTRANSFERCONTEXT *psRGXDestroyTransferContextOUT,
189 CONNECTION_DATA *psConnection)
200 psRGXDestroyTransferContextOUT->eError =
201 PVRSRVReleaseHandle(psConnection->psHandleBase,
202 (IMG_HANDLE) psRGXDestroyTransferContextIN->hTransferContext,
203 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_CONTEXT);
204 if ((psRGXDestroyTransferContextOUT->eError != PVRSRV_OK) && (psRGXDestroyTransferContextOUT->eError != PVRSRV_ERROR_RETRY))
207 goto RGXDestroyTransferContext_exit;
212 RGXDestroyTransferContext_exit:
218 PVRSRVBridgeRGXSubmitTransfer(IMG_UINT32 ui32DispatchTableEntry,
219 PVRSRV_BRIDGE_IN_RGXSUBMITTRANSFER *psRGXSubmitTransferIN,
220 PVRSRV_BRIDGE_OUT_RGXSUBMITTRANSFER *psRGXSubmitTransferOUT,
221 CONNECTION_DATA *psConnection)
223 RGX_SERVER_TQ_CONTEXT * psTransferContextInt = IMG_NULL;
224 IMG_UINT32 *ui32ClientFenceCountInt = IMG_NULL;
225 SYNC_PRIMITIVE_BLOCK * **psFenceUFOSyncPrimBlockInt = IMG_NULL;
226 IMG_HANDLE **hFenceUFOSyncPrimBlockInt2 = IMG_NULL;
227 IMG_UINT32 **ui32FenceSyncOffsetInt = IMG_NULL;
228 IMG_UINT32 **ui32FenceValueInt = IMG_NULL;
229 IMG_UINT32 *ui32ClientUpdateCountInt = IMG_NULL;
230 SYNC_PRIMITIVE_BLOCK * **psUpdateUFOSyncPrimBlockInt = IMG_NULL;
231 IMG_HANDLE **hUpdateUFOSyncPrimBlockInt2 = IMG_NULL;
232 IMG_UINT32 **ui32UpdateSyncOffsetInt = IMG_NULL;
233 IMG_UINT32 **ui32UpdateValueInt = IMG_NULL;
234 IMG_UINT32 *ui32ServerSyncCountInt = IMG_NULL;
235 IMG_UINT32 **ui32ServerSyncFlagsInt = IMG_NULL;
236 SERVER_SYNC_PRIMITIVE * **psServerSyncInt = IMG_NULL;
237 IMG_HANDLE **hServerSyncInt2 = IMG_NULL;
238 IMG_INT32 *i32CheckFenceFDsInt = IMG_NULL;
239 IMG_UINT32 *ui32CommandSizeInt = IMG_NULL;
240 IMG_UINT8 **ui8FWCommandInt = IMG_NULL;
241 IMG_UINT32 *ui32TQPrepareFlagsInt = IMG_NULL;
246 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
248 ui32ClientFenceCountInt = OSAllocMem(psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32));
249 if (!ui32ClientFenceCountInt)
251 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
253 goto RGXSubmitTransfer_exit;
257 /* Copy the data over */
258 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXSubmitTransferIN->pui32ClientFenceCount, psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32))
259 || (OSCopyFromUser(NULL, ui32ClientFenceCountInt, psRGXSubmitTransferIN->pui32ClientFenceCount,
260 psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
262 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
264 goto RGXSubmitTransfer_exit;
266 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
268 IMG_UINT32 ui32Pass=0;
270 IMG_UINT32 ui32AllocSize=0;
272 IMG_UINT8 *pui8Ptr = IMG_NULL;
273 IMG_UINT32 ui32AllocSize2=0;
274 IMG_UINT32 ui32Size2;
275 IMG_UINT8 *pui8Ptr2 = IMG_NULL;
278 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
279 Keeps allocation cost down and simplifies the free path
281 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
283 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(SYNC_PRIMITIVE_BLOCK * *);
284 ui32Size2 = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_HANDLE *);
287 ui32AllocSize += ui32Size;
288 ui32AllocSize2 += ui32Size2;
292 pui8Ptr = OSAllocMem(ui32AllocSize);
293 if (pui8Ptr == IMG_NULL)
295 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
296 goto RGXSubmitTransfer_exit;
298 psFenceUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK * **) pui8Ptr;
300 pui8Ptr2 = OSAllocMem(ui32AllocSize2);
301 if (pui8Ptr2 == IMG_NULL)
303 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
304 goto RGXSubmitTransfer_exit;
306 hFenceUFOSyncPrimBlockInt2 = (IMG_HANDLE **) pui8Ptr2;
307 pui8Ptr2 += ui32Size2;
310 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
312 ui32Size = ui32ClientFenceCountInt[i] * sizeof(SYNC_PRIMITIVE_BLOCK *);
313 ui32Size2 = ui32ClientFenceCountInt[i] * sizeof(IMG_HANDLE);
318 ui32AllocSize += ui32Size;
319 ui32AllocSize2 += ui32Size2;
323 psFenceUFOSyncPrimBlockInt[i] = (SYNC_PRIMITIVE_BLOCK * *) pui8Ptr;
325 hFenceUFOSyncPrimBlockInt2[i] = (IMG_HANDLE *) pui8Ptr2;
326 pui8Ptr2 += ui32Size2;
337 /* Loop over all the pointers in the array copying the data into the kernel */
338 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
340 /* Copy the pointer over from the client side */
341 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->phFenceUFOSyncPrimBlock[i], sizeof(IMG_HANDLE **))
342 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->phFenceUFOSyncPrimBlock[i],
343 sizeof(IMG_HANDLE **)) != PVRSRV_OK) )
345 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
347 goto RGXSubmitTransfer_exit;
349 /* Copy the data over */
350 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ClientFenceCountInt[i] * sizeof(IMG_HANDLE)))
351 || (OSCopyFromUser(NULL, (hFenceUFOSyncPrimBlockInt2[i]), psPtr,
352 (ui32ClientFenceCountInt[i] * sizeof(IMG_HANDLE))) != PVRSRV_OK) )
354 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
356 goto RGXSubmitTransfer_exit;
360 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
362 IMG_UINT32 ui32Pass=0;
364 IMG_UINT32 ui32AllocSize=0;
366 IMG_UINT8 *pui8Ptr = IMG_NULL;
369 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
370 Keeps allocation cost down and simplifies the free path
372 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
374 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32 *);
377 ui32AllocSize += ui32Size;
381 pui8Ptr = OSAllocMem(ui32AllocSize);
382 if (pui8Ptr == IMG_NULL)
384 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
385 goto RGXSubmitTransfer_exit;
387 ui32FenceSyncOffsetInt = (IMG_UINT32 **) pui8Ptr;
391 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
393 ui32Size = ui32ClientFenceCountInt[i] * sizeof(IMG_UINT32);
398 ui32AllocSize += ui32Size;
402 ui32FenceSyncOffsetInt[i] = (IMG_UINT32 *) pui8Ptr;
414 /* Loop over all the pointers in the array copying the data into the kernel */
415 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
417 /* Copy the pointer over from the client side */
418 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->pui32FenceSyncOffset[i], sizeof(IMG_UINT32 **))
419 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->pui32FenceSyncOffset[i],
420 sizeof(IMG_UINT32 **)) != PVRSRV_OK) )
422 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
424 goto RGXSubmitTransfer_exit;
426 /* Copy the data over */
427 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ClientFenceCountInt[i] * sizeof(IMG_UINT32)))
428 || (OSCopyFromUser(NULL, (ui32FenceSyncOffsetInt[i]), psPtr,
429 (ui32ClientFenceCountInt[i] * sizeof(IMG_UINT32))) != PVRSRV_OK) )
431 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
433 goto RGXSubmitTransfer_exit;
437 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
439 IMG_UINT32 ui32Pass=0;
441 IMG_UINT32 ui32AllocSize=0;
443 IMG_UINT8 *pui8Ptr = IMG_NULL;
446 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
447 Keeps allocation cost down and simplifies the free path
449 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
451 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32 *);
454 ui32AllocSize += ui32Size;
458 pui8Ptr = OSAllocMem(ui32AllocSize);
459 if (pui8Ptr == IMG_NULL)
461 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
462 goto RGXSubmitTransfer_exit;
464 ui32FenceValueInt = (IMG_UINT32 **) pui8Ptr;
468 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
470 ui32Size = ui32ClientFenceCountInt[i] * sizeof(IMG_UINT32);
475 ui32AllocSize += ui32Size;
479 ui32FenceValueInt[i] = (IMG_UINT32 *) pui8Ptr;
491 /* Loop over all the pointers in the array copying the data into the kernel */
492 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
494 /* Copy the pointer over from the client side */
495 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->pui32FenceValue[i], sizeof(IMG_UINT32 **))
496 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->pui32FenceValue[i],
497 sizeof(IMG_UINT32 **)) != PVRSRV_OK) )
499 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
501 goto RGXSubmitTransfer_exit;
503 /* Copy the data over */
504 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ClientFenceCountInt[i] * sizeof(IMG_UINT32)))
505 || (OSCopyFromUser(NULL, (ui32FenceValueInt[i]), psPtr,
506 (ui32ClientFenceCountInt[i] * sizeof(IMG_UINT32))) != PVRSRV_OK) )
508 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
510 goto RGXSubmitTransfer_exit;
514 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
516 ui32ClientUpdateCountInt = OSAllocMem(psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32));
517 if (!ui32ClientUpdateCountInt)
519 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
521 goto RGXSubmitTransfer_exit;
525 /* Copy the data over */
526 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXSubmitTransferIN->pui32ClientUpdateCount, psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32))
527 || (OSCopyFromUser(NULL, ui32ClientUpdateCountInt, psRGXSubmitTransferIN->pui32ClientUpdateCount,
528 psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
530 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
532 goto RGXSubmitTransfer_exit;
534 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
536 IMG_UINT32 ui32Pass=0;
538 IMG_UINT32 ui32AllocSize=0;
540 IMG_UINT8 *pui8Ptr = IMG_NULL;
541 IMG_UINT32 ui32AllocSize2=0;
542 IMG_UINT32 ui32Size2;
543 IMG_UINT8 *pui8Ptr2 = IMG_NULL;
546 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
547 Keeps allocation cost down and simplifies the free path
549 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
551 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(SYNC_PRIMITIVE_BLOCK * *);
552 ui32Size2 = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_HANDLE *);
555 ui32AllocSize += ui32Size;
556 ui32AllocSize2 += ui32Size2;
560 pui8Ptr = OSAllocMem(ui32AllocSize);
561 if (pui8Ptr == IMG_NULL)
563 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
564 goto RGXSubmitTransfer_exit;
566 psUpdateUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK * **) pui8Ptr;
568 pui8Ptr2 = OSAllocMem(ui32AllocSize2);
569 if (pui8Ptr2 == IMG_NULL)
571 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
572 goto RGXSubmitTransfer_exit;
574 hUpdateUFOSyncPrimBlockInt2 = (IMG_HANDLE **) pui8Ptr2;
575 pui8Ptr2 += ui32Size2;
578 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
580 ui32Size = ui32ClientUpdateCountInt[i] * sizeof(SYNC_PRIMITIVE_BLOCK *);
581 ui32Size2 = ui32ClientUpdateCountInt[i] * sizeof(IMG_HANDLE);
586 ui32AllocSize += ui32Size;
587 ui32AllocSize2 += ui32Size2;
591 psUpdateUFOSyncPrimBlockInt[i] = (SYNC_PRIMITIVE_BLOCK * *) pui8Ptr;
593 hUpdateUFOSyncPrimBlockInt2[i] = (IMG_HANDLE *) pui8Ptr2;
594 pui8Ptr2 += ui32Size2;
605 /* Loop over all the pointers in the array copying the data into the kernel */
606 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
608 /* Copy the pointer over from the client side */
609 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->phUpdateUFOSyncPrimBlock[i], sizeof(IMG_HANDLE **))
610 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->phUpdateUFOSyncPrimBlock[i],
611 sizeof(IMG_HANDLE **)) != PVRSRV_OK) )
613 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
615 goto RGXSubmitTransfer_exit;
617 /* Copy the data over */
618 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ClientUpdateCountInt[i] * sizeof(IMG_HANDLE)))
619 || (OSCopyFromUser(NULL, (hUpdateUFOSyncPrimBlockInt2[i]), psPtr,
620 (ui32ClientUpdateCountInt[i] * sizeof(IMG_HANDLE))) != PVRSRV_OK) )
622 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
624 goto RGXSubmitTransfer_exit;
628 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
630 IMG_UINT32 ui32Pass=0;
632 IMG_UINT32 ui32AllocSize=0;
634 IMG_UINT8 *pui8Ptr = IMG_NULL;
637 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
638 Keeps allocation cost down and simplifies the free path
640 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
642 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32 *);
645 ui32AllocSize += ui32Size;
649 pui8Ptr = OSAllocMem(ui32AllocSize);
650 if (pui8Ptr == IMG_NULL)
652 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
653 goto RGXSubmitTransfer_exit;
655 ui32UpdateSyncOffsetInt = (IMG_UINT32 **) pui8Ptr;
659 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
661 ui32Size = ui32ClientUpdateCountInt[i] * sizeof(IMG_UINT32);
666 ui32AllocSize += ui32Size;
670 ui32UpdateSyncOffsetInt[i] = (IMG_UINT32 *) pui8Ptr;
682 /* Loop over all the pointers in the array copying the data into the kernel */
683 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
685 /* Copy the pointer over from the client side */
686 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->pui32UpdateSyncOffset[i], sizeof(IMG_UINT32 **))
687 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->pui32UpdateSyncOffset[i],
688 sizeof(IMG_UINT32 **)) != PVRSRV_OK) )
690 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
692 goto RGXSubmitTransfer_exit;
694 /* Copy the data over */
695 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ClientUpdateCountInt[i] * sizeof(IMG_UINT32)))
696 || (OSCopyFromUser(NULL, (ui32UpdateSyncOffsetInt[i]), psPtr,
697 (ui32ClientUpdateCountInt[i] * sizeof(IMG_UINT32))) != PVRSRV_OK) )
699 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
701 goto RGXSubmitTransfer_exit;
705 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
707 IMG_UINT32 ui32Pass=0;
709 IMG_UINT32 ui32AllocSize=0;
711 IMG_UINT8 *pui8Ptr = IMG_NULL;
714 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
715 Keeps allocation cost down and simplifies the free path
717 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
719 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32 *);
722 ui32AllocSize += ui32Size;
726 pui8Ptr = OSAllocMem(ui32AllocSize);
727 if (pui8Ptr == IMG_NULL)
729 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
730 goto RGXSubmitTransfer_exit;
732 ui32UpdateValueInt = (IMG_UINT32 **) pui8Ptr;
736 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
738 ui32Size = ui32ClientUpdateCountInt[i] * sizeof(IMG_UINT32);
743 ui32AllocSize += ui32Size;
747 ui32UpdateValueInt[i] = (IMG_UINT32 *) pui8Ptr;
759 /* Loop over all the pointers in the array copying the data into the kernel */
760 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
762 /* Copy the pointer over from the client side */
763 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->pui32UpdateValue[i], sizeof(IMG_UINT32 **))
764 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->pui32UpdateValue[i],
765 sizeof(IMG_UINT32 **)) != PVRSRV_OK) )
767 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
769 goto RGXSubmitTransfer_exit;
771 /* Copy the data over */
772 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ClientUpdateCountInt[i] * sizeof(IMG_UINT32)))
773 || (OSCopyFromUser(NULL, (ui32UpdateValueInt[i]), psPtr,
774 (ui32ClientUpdateCountInt[i] * sizeof(IMG_UINT32))) != PVRSRV_OK) )
776 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
778 goto RGXSubmitTransfer_exit;
782 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
784 ui32ServerSyncCountInt = OSAllocMem(psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32));
785 if (!ui32ServerSyncCountInt)
787 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
789 goto RGXSubmitTransfer_exit;
793 /* Copy the data over */
794 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXSubmitTransferIN->pui32ServerSyncCount, psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32))
795 || (OSCopyFromUser(NULL, ui32ServerSyncCountInt, psRGXSubmitTransferIN->pui32ServerSyncCount,
796 psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
798 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
800 goto RGXSubmitTransfer_exit;
802 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
804 IMG_UINT32 ui32Pass=0;
806 IMG_UINT32 ui32AllocSize=0;
808 IMG_UINT8 *pui8Ptr = IMG_NULL;
811 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
812 Keeps allocation cost down and simplifies the free path
814 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
816 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32 *);
819 ui32AllocSize += ui32Size;
823 pui8Ptr = OSAllocMem(ui32AllocSize);
824 if (pui8Ptr == IMG_NULL)
826 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
827 goto RGXSubmitTransfer_exit;
829 ui32ServerSyncFlagsInt = (IMG_UINT32 **) pui8Ptr;
833 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
835 ui32Size = ui32ServerSyncCountInt[i] * sizeof(IMG_UINT32);
840 ui32AllocSize += ui32Size;
844 ui32ServerSyncFlagsInt[i] = (IMG_UINT32 *) pui8Ptr;
856 /* Loop over all the pointers in the array copying the data into the kernel */
857 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
859 /* Copy the pointer over from the client side */
860 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->pui32ServerSyncFlags[i], sizeof(IMG_UINT32 **))
861 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->pui32ServerSyncFlags[i],
862 sizeof(IMG_UINT32 **)) != PVRSRV_OK) )
864 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
866 goto RGXSubmitTransfer_exit;
868 /* Copy the data over */
869 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ServerSyncCountInt[i] * sizeof(IMG_UINT32)))
870 || (OSCopyFromUser(NULL, (ui32ServerSyncFlagsInt[i]), psPtr,
871 (ui32ServerSyncCountInt[i] * sizeof(IMG_UINT32))) != PVRSRV_OK) )
873 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
875 goto RGXSubmitTransfer_exit;
879 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
881 IMG_UINT32 ui32Pass=0;
883 IMG_UINT32 ui32AllocSize=0;
885 IMG_UINT8 *pui8Ptr = IMG_NULL;
886 IMG_UINT32 ui32AllocSize2=0;
887 IMG_UINT32 ui32Size2;
888 IMG_UINT8 *pui8Ptr2 = IMG_NULL;
891 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
892 Keeps allocation cost down and simplifies the free path
894 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
896 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(SERVER_SYNC_PRIMITIVE * *);
897 ui32Size2 = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_HANDLE *);
900 ui32AllocSize += ui32Size;
901 ui32AllocSize2 += ui32Size2;
905 pui8Ptr = OSAllocMem(ui32AllocSize);
906 if (pui8Ptr == IMG_NULL)
908 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
909 goto RGXSubmitTransfer_exit;
911 psServerSyncInt = (SERVER_SYNC_PRIMITIVE * **) pui8Ptr;
913 pui8Ptr2 = OSAllocMem(ui32AllocSize2);
914 if (pui8Ptr2 == IMG_NULL)
916 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
917 goto RGXSubmitTransfer_exit;
919 hServerSyncInt2 = (IMG_HANDLE **) pui8Ptr2;
920 pui8Ptr2 += ui32Size2;
923 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
925 ui32Size = ui32ServerSyncCountInt[i] * sizeof(SERVER_SYNC_PRIMITIVE *);
926 ui32Size2 = ui32ServerSyncCountInt[i] * sizeof(IMG_HANDLE);
931 ui32AllocSize += ui32Size;
932 ui32AllocSize2 += ui32Size2;
936 psServerSyncInt[i] = (SERVER_SYNC_PRIMITIVE * *) pui8Ptr;
938 hServerSyncInt2[i] = (IMG_HANDLE *) pui8Ptr2;
939 pui8Ptr2 += ui32Size2;
950 /* Loop over all the pointers in the array copying the data into the kernel */
951 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
953 /* Copy the pointer over from the client side */
954 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->phServerSync[i], sizeof(IMG_HANDLE **))
955 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->phServerSync[i],
956 sizeof(IMG_HANDLE **)) != PVRSRV_OK) )
958 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
960 goto RGXSubmitTransfer_exit;
962 /* Copy the data over */
963 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32ServerSyncCountInt[i] * sizeof(IMG_HANDLE)))
964 || (OSCopyFromUser(NULL, (hServerSyncInt2[i]), psPtr,
965 (ui32ServerSyncCountInt[i] * sizeof(IMG_HANDLE))) != PVRSRV_OK) )
967 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
969 goto RGXSubmitTransfer_exit;
973 if (psRGXSubmitTransferIN->ui32NumCheckFenceFDs != 0)
975 i32CheckFenceFDsInt = OSAllocMem(psRGXSubmitTransferIN->ui32NumCheckFenceFDs * sizeof(IMG_INT32));
976 if (!i32CheckFenceFDsInt)
978 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
980 goto RGXSubmitTransfer_exit;
984 /* Copy the data over */
985 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXSubmitTransferIN->pi32CheckFenceFDs, psRGXSubmitTransferIN->ui32NumCheckFenceFDs * sizeof(IMG_INT32))
986 || (OSCopyFromUser(NULL, i32CheckFenceFDsInt, psRGXSubmitTransferIN->pi32CheckFenceFDs,
987 psRGXSubmitTransferIN->ui32NumCheckFenceFDs * sizeof(IMG_INT32)) != PVRSRV_OK) )
989 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
991 goto RGXSubmitTransfer_exit;
993 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
995 ui32CommandSizeInt = OSAllocMem(psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32));
996 if (!ui32CommandSizeInt)
998 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1000 goto RGXSubmitTransfer_exit;
1004 /* Copy the data over */
1005 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXSubmitTransferIN->pui32CommandSize, psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32))
1006 || (OSCopyFromUser(NULL, ui32CommandSizeInt, psRGXSubmitTransferIN->pui32CommandSize,
1007 psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1009 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1011 goto RGXSubmitTransfer_exit;
1013 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
1015 IMG_UINT32 ui32Pass=0;
1017 IMG_UINT32 ui32AllocSize=0;
1018 IMG_UINT32 ui32Size;
1019 IMG_UINT8 *pui8Ptr = IMG_NULL;
1022 Two pass loop, 1st find out the size and 2nd allocation and set offsets.
1023 Keeps allocation cost down and simplifies the free path
1025 for (ui32Pass=0;ui32Pass<2;ui32Pass++)
1027 ui32Size = psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT8 *);
1030 ui32AllocSize += ui32Size;
1034 pui8Ptr = OSAllocMem(ui32AllocSize);
1035 if (pui8Ptr == IMG_NULL)
1037 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1038 goto RGXSubmitTransfer_exit;
1040 ui8FWCommandInt = (IMG_UINT8 **) pui8Ptr;
1041 pui8Ptr += ui32Size;
1044 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
1046 ui32Size = ui32CommandSizeInt[i] * sizeof(IMG_UINT8);
1051 ui32AllocSize += ui32Size;
1055 ui8FWCommandInt[i] = (IMG_UINT8 *) pui8Ptr;
1056 pui8Ptr += ui32Size;
1067 /* Loop over all the pointers in the array copying the data into the kernel */
1068 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
1070 /* Copy the pointer over from the client side */
1071 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) &psRGXSubmitTransferIN->pui8FWCommand[i], sizeof(IMG_UINT8 **))
1072 || (OSCopyFromUser(NULL, &psPtr, &psRGXSubmitTransferIN->pui8FWCommand[i],
1073 sizeof(IMG_UINT8 **)) != PVRSRV_OK) )
1075 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1077 goto RGXSubmitTransfer_exit;
1079 /* Copy the data over */
1080 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psPtr, (ui32CommandSizeInt[i] * sizeof(IMG_UINT8)))
1081 || (OSCopyFromUser(NULL, (ui8FWCommandInt[i]), psPtr,
1082 (ui32CommandSizeInt[i] * sizeof(IMG_UINT8))) != PVRSRV_OK) )
1084 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1086 goto RGXSubmitTransfer_exit;
1090 if (psRGXSubmitTransferIN->ui32PrepareCount != 0)
1092 ui32TQPrepareFlagsInt = OSAllocMem(psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32));
1093 if (!ui32TQPrepareFlagsInt)
1095 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1097 goto RGXSubmitTransfer_exit;
1101 /* Copy the data over */
1102 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXSubmitTransferIN->pui32TQPrepareFlags, psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32))
1103 || (OSCopyFromUser(NULL, ui32TQPrepareFlagsInt, psRGXSubmitTransferIN->pui32TQPrepareFlags,
1104 psRGXSubmitTransferIN->ui32PrepareCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1106 psRGXSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1108 goto RGXSubmitTransfer_exit;
1114 /* Look up the address from the handle */
1115 psRGXSubmitTransferOUT->eError =
1116 PVRSRVLookupHandle(psConnection->psHandleBase,
1117 (IMG_VOID **) &psTransferContextInt,
1118 psRGXSubmitTransferIN->hTransferContext,
1119 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_CONTEXT);
1120 if(psRGXSubmitTransferOUT->eError != PVRSRV_OK)
1122 goto RGXSubmitTransfer_exit;
1130 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
1133 for (j=0;j<ui32ClientFenceCountInt[i];j++)
1136 /* Look up the address from the handle */
1137 psRGXSubmitTransferOUT->eError =
1138 PVRSRVLookupHandle(psConnection->psHandleBase,
1139 (IMG_VOID **) &psFenceUFOSyncPrimBlockInt[i][j],
1140 hFenceUFOSyncPrimBlockInt2[i][j],
1141 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
1142 if(psRGXSubmitTransferOUT->eError != PVRSRV_OK)
1144 goto RGXSubmitTransfer_exit;
1155 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
1158 for (j=0;j<ui32ClientUpdateCountInt[i];j++)
1161 /* Look up the address from the handle */
1162 psRGXSubmitTransferOUT->eError =
1163 PVRSRVLookupHandle(psConnection->psHandleBase,
1164 (IMG_VOID **) &psUpdateUFOSyncPrimBlockInt[i][j],
1165 hUpdateUFOSyncPrimBlockInt2[i][j],
1166 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
1167 if(psRGXSubmitTransferOUT->eError != PVRSRV_OK)
1169 goto RGXSubmitTransfer_exit;
1180 for (i=0;i<psRGXSubmitTransferIN->ui32PrepareCount;i++)
1183 for (j=0;j<ui32ServerSyncCountInt[i];j++)
1186 /* Look up the address from the handle */
1187 psRGXSubmitTransferOUT->eError =
1188 PVRSRVLookupHandle(psConnection->psHandleBase,
1189 (IMG_VOID **) &psServerSyncInt[i][j],
1190 hServerSyncInt2[i][j],
1191 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
1192 if(psRGXSubmitTransferOUT->eError != PVRSRV_OK)
1194 goto RGXSubmitTransfer_exit;
1202 psRGXSubmitTransferOUT->eError =
1203 PVRSRVRGXSubmitTransferKM(
1204 psTransferContextInt,
1205 psRGXSubmitTransferIN->ui32PrepareCount,
1206 ui32ClientFenceCountInt,
1207 psFenceUFOSyncPrimBlockInt,
1208 ui32FenceSyncOffsetInt,
1210 ui32ClientUpdateCountInt,
1211 psUpdateUFOSyncPrimBlockInt,
1212 ui32UpdateSyncOffsetInt,
1214 ui32ServerSyncCountInt,
1215 ui32ServerSyncFlagsInt,
1217 psRGXSubmitTransferIN->ui32NumCheckFenceFDs,
1218 i32CheckFenceFDsInt,
1219 psRGXSubmitTransferIN->i32UpdateFenceFD,
1222 ui32TQPrepareFlagsInt,
1223 psRGXSubmitTransferIN->ui32ExternalJobReference,
1224 psRGXSubmitTransferIN->ui32InternalJobReference);
1229 RGXSubmitTransfer_exit:
1230 if (ui32ClientFenceCountInt)
1231 OSFreeMem(ui32ClientFenceCountInt);
1232 if (psFenceUFOSyncPrimBlockInt)
1233 OSFreeMem(psFenceUFOSyncPrimBlockInt);
1234 if (hFenceUFOSyncPrimBlockInt2)
1235 OSFreeMem(hFenceUFOSyncPrimBlockInt2);
1236 if (ui32FenceSyncOffsetInt)
1237 OSFreeMem(ui32FenceSyncOffsetInt);
1238 if (ui32FenceValueInt)
1239 OSFreeMem(ui32FenceValueInt);
1240 if (ui32ClientUpdateCountInt)
1241 OSFreeMem(ui32ClientUpdateCountInt);
1242 if (psUpdateUFOSyncPrimBlockInt)
1243 OSFreeMem(psUpdateUFOSyncPrimBlockInt);
1244 if (hUpdateUFOSyncPrimBlockInt2)
1245 OSFreeMem(hUpdateUFOSyncPrimBlockInt2);
1246 if (ui32UpdateSyncOffsetInt)
1247 OSFreeMem(ui32UpdateSyncOffsetInt);
1248 if (ui32UpdateValueInt)
1249 OSFreeMem(ui32UpdateValueInt);
1250 if (ui32ServerSyncCountInt)
1251 OSFreeMem(ui32ServerSyncCountInt);
1252 if (ui32ServerSyncFlagsInt)
1253 OSFreeMem(ui32ServerSyncFlagsInt);
1254 if (psServerSyncInt)
1255 OSFreeMem(psServerSyncInt);
1256 if (hServerSyncInt2)
1257 OSFreeMem(hServerSyncInt2);
1258 if (i32CheckFenceFDsInt)
1259 OSFreeMem(i32CheckFenceFDsInt);
1260 if (ui32CommandSizeInt)
1261 OSFreeMem(ui32CommandSizeInt);
1262 if (ui8FWCommandInt)
1263 OSFreeMem(ui8FWCommandInt);
1264 if (ui32TQPrepareFlagsInt)
1265 OSFreeMem(ui32TQPrepareFlagsInt);
1271 PVRSRVBridgeRGXSetTransferContextPriority(IMG_UINT32 ui32DispatchTableEntry,
1272 PVRSRV_BRIDGE_IN_RGXSETTRANSFERCONTEXTPRIORITY *psRGXSetTransferContextPriorityIN,
1273 PVRSRV_BRIDGE_OUT_RGXSETTRANSFERCONTEXTPRIORITY *psRGXSetTransferContextPriorityOUT,
1274 CONNECTION_DATA *psConnection)
1276 RGX_SERVER_TQ_CONTEXT * psTransferContextInt = IMG_NULL;
1285 /* Look up the address from the handle */
1286 psRGXSetTransferContextPriorityOUT->eError =
1287 PVRSRVLookupHandle(psConnection->psHandleBase,
1288 (IMG_VOID **) &psTransferContextInt,
1289 psRGXSetTransferContextPriorityIN->hTransferContext,
1290 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_CONTEXT);
1291 if(psRGXSetTransferContextPriorityOUT->eError != PVRSRV_OK)
1293 goto RGXSetTransferContextPriority_exit;
1298 psRGXSetTransferContextPriorityOUT->eError =
1299 PVRSRVRGXSetTransferContextPriorityKM(psConnection,
1300 psTransferContextInt,
1301 psRGXSetTransferContextPriorityIN->ui32Priority);
1306 RGXSetTransferContextPriority_exit:
1312 PVRSRVBridgeRGXKickSyncTransfer(IMG_UINT32 ui32DispatchTableEntry,
1313 PVRSRV_BRIDGE_IN_RGXKICKSYNCTRANSFER *psRGXKickSyncTransferIN,
1314 PVRSRV_BRIDGE_OUT_RGXKICKSYNCTRANSFER *psRGXKickSyncTransferOUT,
1315 CONNECTION_DATA *psConnection)
1317 RGX_SERVER_TQ_CONTEXT * psTransferContextInt = IMG_NULL;
1318 SYNC_PRIMITIVE_BLOCK * *psClientFenceUFOSyncPrimBlockInt = IMG_NULL;
1319 IMG_HANDLE *hClientFenceUFOSyncPrimBlockInt2 = IMG_NULL;
1320 IMG_UINT32 *ui32ClientFenceSyncOffsetInt = IMG_NULL;
1321 IMG_UINT32 *ui32ClientFenceValueInt = IMG_NULL;
1322 SYNC_PRIMITIVE_BLOCK * *psClientUpdateUFOSyncPrimBlockInt = IMG_NULL;
1323 IMG_HANDLE *hClientUpdateUFOSyncPrimBlockInt2 = IMG_NULL;
1324 IMG_UINT32 *ui32ClientUpdateSyncOffsetInt = IMG_NULL;
1325 IMG_UINT32 *ui32ClientUpdateValueInt = IMG_NULL;
1326 IMG_UINT32 *ui32ServerSyncFlagsInt = IMG_NULL;
1327 SERVER_SYNC_PRIMITIVE * *psServerSyncsInt = IMG_NULL;
1328 IMG_HANDLE *hServerSyncsInt2 = IMG_NULL;
1329 IMG_INT32 *i32CheckFenceFDsInt = IMG_NULL;
1334 if (psRGXKickSyncTransferIN->ui32ClientFenceCount != 0)
1336 psClientFenceUFOSyncPrimBlockInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *));
1337 if (!psClientFenceUFOSyncPrimBlockInt)
1339 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1341 goto RGXKickSyncTransfer_exit;
1343 hClientFenceUFOSyncPrimBlockInt2 = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE));
1344 if (!hClientFenceUFOSyncPrimBlockInt2)
1346 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1348 goto RGXKickSyncTransfer_exit;
1352 /* Copy the data over */
1353 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->phClientFenceUFOSyncPrimBlock, psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE))
1354 || (OSCopyFromUser(NULL, hClientFenceUFOSyncPrimBlockInt2, psRGXKickSyncTransferIN->phClientFenceUFOSyncPrimBlock,
1355 psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK) )
1357 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1359 goto RGXKickSyncTransfer_exit;
1361 if (psRGXKickSyncTransferIN->ui32ClientFenceCount != 0)
1363 ui32ClientFenceSyncOffsetInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32));
1364 if (!ui32ClientFenceSyncOffsetInt)
1366 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1368 goto RGXKickSyncTransfer_exit;
1372 /* Copy the data over */
1373 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->pui32ClientFenceSyncOffset, psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32))
1374 || (OSCopyFromUser(NULL, ui32ClientFenceSyncOffsetInt, psRGXKickSyncTransferIN->pui32ClientFenceSyncOffset,
1375 psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1377 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1379 goto RGXKickSyncTransfer_exit;
1381 if (psRGXKickSyncTransferIN->ui32ClientFenceCount != 0)
1383 ui32ClientFenceValueInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32));
1384 if (!ui32ClientFenceValueInt)
1386 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1388 goto RGXKickSyncTransfer_exit;
1392 /* Copy the data over */
1393 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->pui32ClientFenceValue, psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32))
1394 || (OSCopyFromUser(NULL, ui32ClientFenceValueInt, psRGXKickSyncTransferIN->pui32ClientFenceValue,
1395 psRGXKickSyncTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1397 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1399 goto RGXKickSyncTransfer_exit;
1401 if (psRGXKickSyncTransferIN->ui32ClientUpdateCount != 0)
1403 psClientUpdateUFOSyncPrimBlockInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *));
1404 if (!psClientUpdateUFOSyncPrimBlockInt)
1406 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1408 goto RGXKickSyncTransfer_exit;
1410 hClientUpdateUFOSyncPrimBlockInt2 = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE));
1411 if (!hClientUpdateUFOSyncPrimBlockInt2)
1413 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1415 goto RGXKickSyncTransfer_exit;
1419 /* Copy the data over */
1420 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->phClientUpdateUFOSyncPrimBlock, psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE))
1421 || (OSCopyFromUser(NULL, hClientUpdateUFOSyncPrimBlockInt2, psRGXKickSyncTransferIN->phClientUpdateUFOSyncPrimBlock,
1422 psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK) )
1424 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1426 goto RGXKickSyncTransfer_exit;
1428 if (psRGXKickSyncTransferIN->ui32ClientUpdateCount != 0)
1430 ui32ClientUpdateSyncOffsetInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32));
1431 if (!ui32ClientUpdateSyncOffsetInt)
1433 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1435 goto RGXKickSyncTransfer_exit;
1439 /* Copy the data over */
1440 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->pui32ClientUpdateSyncOffset, psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32))
1441 || (OSCopyFromUser(NULL, ui32ClientUpdateSyncOffsetInt, psRGXKickSyncTransferIN->pui32ClientUpdateSyncOffset,
1442 psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1444 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1446 goto RGXKickSyncTransfer_exit;
1448 if (psRGXKickSyncTransferIN->ui32ClientUpdateCount != 0)
1450 ui32ClientUpdateValueInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32));
1451 if (!ui32ClientUpdateValueInt)
1453 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1455 goto RGXKickSyncTransfer_exit;
1459 /* Copy the data over */
1460 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->pui32ClientUpdateValue, psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32))
1461 || (OSCopyFromUser(NULL, ui32ClientUpdateValueInt, psRGXKickSyncTransferIN->pui32ClientUpdateValue,
1462 psRGXKickSyncTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1464 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1466 goto RGXKickSyncTransfer_exit;
1468 if (psRGXKickSyncTransferIN->ui32ServerSyncCount != 0)
1470 ui32ServerSyncFlagsInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32));
1471 if (!ui32ServerSyncFlagsInt)
1473 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1475 goto RGXKickSyncTransfer_exit;
1479 /* Copy the data over */
1480 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->pui32ServerSyncFlags, psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32))
1481 || (OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXKickSyncTransferIN->pui32ServerSyncFlags,
1482 psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK) )
1484 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1486 goto RGXKickSyncTransfer_exit;
1488 if (psRGXKickSyncTransferIN->ui32ServerSyncCount != 0)
1490 psServerSyncsInt = OSAllocMem(psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *));
1491 if (!psServerSyncsInt)
1493 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1495 goto RGXKickSyncTransfer_exit;
1497 hServerSyncsInt2 = OSAllocMem(psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE));
1498 if (!hServerSyncsInt2)
1500 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1502 goto RGXKickSyncTransfer_exit;
1506 /* Copy the data over */
1507 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->phServerSyncs, psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE))
1508 || (OSCopyFromUser(NULL, hServerSyncsInt2, psRGXKickSyncTransferIN->phServerSyncs,
1509 psRGXKickSyncTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK) )
1511 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1513 goto RGXKickSyncTransfer_exit;
1515 if (psRGXKickSyncTransferIN->ui32NumCheckFenceFDs != 0)
1517 i32CheckFenceFDsInt = OSAllocMem(psRGXKickSyncTransferIN->ui32NumCheckFenceFDs * sizeof(IMG_INT32));
1518 if (!i32CheckFenceFDsInt)
1520 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1522 goto RGXKickSyncTransfer_exit;
1526 /* Copy the data over */
1527 if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psRGXKickSyncTransferIN->pi32CheckFenceFDs, psRGXKickSyncTransferIN->ui32NumCheckFenceFDs * sizeof(IMG_INT32))
1528 || (OSCopyFromUser(NULL, i32CheckFenceFDsInt, psRGXKickSyncTransferIN->pi32CheckFenceFDs,
1529 psRGXKickSyncTransferIN->ui32NumCheckFenceFDs * sizeof(IMG_INT32)) != PVRSRV_OK) )
1531 psRGXKickSyncTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1533 goto RGXKickSyncTransfer_exit;
1539 /* Look up the address from the handle */
1540 psRGXKickSyncTransferOUT->eError =
1541 PVRSRVLookupHandle(psConnection->psHandleBase,
1542 (IMG_VOID **) &psTransferContextInt,
1543 psRGXKickSyncTransferIN->hTransferContext,
1544 PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_CONTEXT);
1545 if(psRGXKickSyncTransferOUT->eError != PVRSRV_OK)
1547 goto RGXKickSyncTransfer_exit;
1555 for (i=0;i<psRGXKickSyncTransferIN->ui32ClientFenceCount;i++)
1558 /* Look up the address from the handle */
1559 psRGXKickSyncTransferOUT->eError =
1560 PVRSRVLookupHandle(psConnection->psHandleBase,
1561 (IMG_VOID **) &psClientFenceUFOSyncPrimBlockInt[i],
1562 hClientFenceUFOSyncPrimBlockInt2[i],
1563 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
1564 if(psRGXKickSyncTransferOUT->eError != PVRSRV_OK)
1566 goto RGXKickSyncTransfer_exit;
1576 for (i=0;i<psRGXKickSyncTransferIN->ui32ClientUpdateCount;i++)
1579 /* Look up the address from the handle */
1580 psRGXKickSyncTransferOUT->eError =
1581 PVRSRVLookupHandle(psConnection->psHandleBase,
1582 (IMG_VOID **) &psClientUpdateUFOSyncPrimBlockInt[i],
1583 hClientUpdateUFOSyncPrimBlockInt2[i],
1584 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
1585 if(psRGXKickSyncTransferOUT->eError != PVRSRV_OK)
1587 goto RGXKickSyncTransfer_exit;
1597 for (i=0;i<psRGXKickSyncTransferIN->ui32ServerSyncCount;i++)
1600 /* Look up the address from the handle */
1601 psRGXKickSyncTransferOUT->eError =
1602 PVRSRVLookupHandle(psConnection->psHandleBase,
1603 (IMG_VOID **) &psServerSyncsInt[i],
1604 hServerSyncsInt2[i],
1605 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
1606 if(psRGXKickSyncTransferOUT->eError != PVRSRV_OK)
1608 goto RGXKickSyncTransfer_exit;
1615 psRGXKickSyncTransferOUT->eError =
1616 PVRSRVRGXKickSyncTransferKM(
1617 psTransferContextInt,
1618 psRGXKickSyncTransferIN->ui32ClientFenceCount,
1619 psClientFenceUFOSyncPrimBlockInt,
1620 ui32ClientFenceSyncOffsetInt,
1621 ui32ClientFenceValueInt,
1622 psRGXKickSyncTransferIN->ui32ClientUpdateCount,
1623 psClientUpdateUFOSyncPrimBlockInt,
1624 ui32ClientUpdateSyncOffsetInt,
1625 ui32ClientUpdateValueInt,
1626 psRGXKickSyncTransferIN->ui32ServerSyncCount,
1627 ui32ServerSyncFlagsInt,
1629 psRGXKickSyncTransferIN->ui32NumCheckFenceFDs,
1630 i32CheckFenceFDsInt,
1631 psRGXKickSyncTransferIN->i32UpdateFenceFD,
1632 psRGXKickSyncTransferIN->ui32TQPrepareFlags);
1637 RGXKickSyncTransfer_exit:
1638 if (psClientFenceUFOSyncPrimBlockInt)
1639 OSFreeMem(psClientFenceUFOSyncPrimBlockInt);
1640 if (hClientFenceUFOSyncPrimBlockInt2)
1641 OSFreeMem(hClientFenceUFOSyncPrimBlockInt2);
1642 if (ui32ClientFenceSyncOffsetInt)
1643 OSFreeMem(ui32ClientFenceSyncOffsetInt);
1644 if (ui32ClientFenceValueInt)
1645 OSFreeMem(ui32ClientFenceValueInt);
1646 if (psClientUpdateUFOSyncPrimBlockInt)
1647 OSFreeMem(psClientUpdateUFOSyncPrimBlockInt);
1648 if (hClientUpdateUFOSyncPrimBlockInt2)
1649 OSFreeMem(hClientUpdateUFOSyncPrimBlockInt2);
1650 if (ui32ClientUpdateSyncOffsetInt)
1651 OSFreeMem(ui32ClientUpdateSyncOffsetInt);
1652 if (ui32ClientUpdateValueInt)
1653 OSFreeMem(ui32ClientUpdateValueInt);
1654 if (ui32ServerSyncFlagsInt)
1655 OSFreeMem(ui32ServerSyncFlagsInt);
1656 if (psServerSyncsInt)
1657 OSFreeMem(psServerSyncsInt);
1658 if (hServerSyncsInt2)
1659 OSFreeMem(hServerSyncsInt2);
1660 if (i32CheckFenceFDsInt)
1661 OSFreeMem(i32CheckFenceFDsInt);
1668 /* ***************************************************************************
1669 * Server bridge dispatch related glue
1673 PVRSRV_ERROR InitRGXTQBridge(IMG_VOID);
1674 PVRSRV_ERROR DeinitRGXTQBridge(IMG_VOID);
1677 * Register all RGXTQ functions with services
1679 PVRSRV_ERROR InitRGXTQBridge(IMG_VOID)
1682 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ, PVRSRV_BRIDGE_RGXTQ_RGXCREATETRANSFERCONTEXT, PVRSRVBridgeRGXCreateTransferContext,
1686 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ, PVRSRV_BRIDGE_RGXTQ_RGXDESTROYTRANSFERCONTEXT, PVRSRVBridgeRGXDestroyTransferContext,
1690 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ, PVRSRV_BRIDGE_RGXTQ_RGXSUBMITTRANSFER, PVRSRVBridgeRGXSubmitTransfer,
1694 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ, PVRSRV_BRIDGE_RGXTQ_RGXSETTRANSFERCONTEXTPRIORITY, PVRSRVBridgeRGXSetTransferContextPriority,
1698 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ, PVRSRV_BRIDGE_RGXTQ_RGXKICKSYNCTRANSFER, PVRSRVBridgeRGXKickSyncTransfer,
1707 * Unregister all rgxtq functions with services
1709 PVRSRV_ERROR DeinitRGXTQBridge(IMG_VOID)