1 /*************************************************************************/ /*!
3 @Title Server bridge for rgxray
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for rgxray
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>
50 #include "devicemem_server.h"
53 #include "common_rgxray_bridge.h"
56 #include "pvr_debug.h"
57 #include "connection_server.h"
58 #include "pvr_bridge.h"
59 #include "rgx_bridge.h"
63 #include <linux/slab.h>
66 #include "rgx_bvnc_defs_km.h"
71 /* ***************************************************************************
72 * Server-side bridge entry points
76 PVRSRVBridgeRGXCreateRPMFreeList(IMG_UINT32 ui32DispatchTableEntry,
77 PVRSRV_BRIDGE_IN_RGXCREATERPMFREELIST *psRGXCreateRPMFreeListIN,
78 PVRSRV_BRIDGE_OUT_RGXCREATERPMFREELIST *psRGXCreateRPMFreeListOUT,
79 CONNECTION_DATA *psConnection)
81 IMG_HANDLE hRPMContext = psRGXCreateRPMFreeListIN->hRPMContext;
82 RGX_SERVER_RPM_CONTEXT * psRPMContextInt = NULL;
83 RGX_RPM_FREELIST * psCleanupCookieInt = NULL;
87 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
89 /* Check that device supports the required feature */
90 if ((psDeviceNode->pfnCheckDeviceFeature) &&
91 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
93 psRGXCreateRPMFreeListOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
95 goto RGXCreateRPMFreeList_exit;
103 /* Lock over handle lookup. */
111 /* Look up the address from the handle */
112 psRGXCreateRPMFreeListOUT->eError =
113 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
114 (void **) &psRPMContextInt,
116 PVRSRV_HANDLE_TYPE_RGX_SERVER_RPM_CONTEXT,
118 if(psRGXCreateRPMFreeListOUT->eError != PVRSRV_OK)
121 goto RGXCreateRPMFreeList_exit;
124 /* Release now we have looked up handles. */
127 psRGXCreateRPMFreeListOUT->eError =
128 RGXCreateRPMFreeList(psConnection, OSGetDevData(psConnection),
130 psRGXCreateRPMFreeListIN->ui32InitFLPages,
131 psRGXCreateRPMFreeListIN->ui32GrowFLPages,
132 psRGXCreateRPMFreeListIN->sFreeListDevVAddr,
134 &psRGXCreateRPMFreeListOUT->ui32HWFreeList,
135 psRGXCreateRPMFreeListIN->bIsExternal);
136 /* Exit early if bridged call fails */
137 if(psRGXCreateRPMFreeListOUT->eError != PVRSRV_OK)
139 goto RGXCreateRPMFreeList_exit;
142 /* Lock over handle creation. */
149 psRGXCreateRPMFreeListOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
151 &psRGXCreateRPMFreeListOUT->hCleanupCookie,
152 (void *) psCleanupCookieInt,
153 PVRSRV_HANDLE_TYPE_RGX_RPM_FREELIST,
154 PVRSRV_HANDLE_ALLOC_FLAG_NONE
155 ,(PFN_HANDLE_RELEASE)&RGXDestroyRPMFreeList);
156 if (psRGXCreateRPMFreeListOUT->eError != PVRSRV_OK)
159 goto RGXCreateRPMFreeList_exit;
162 /* Release now we have created handles. */
167 RGXCreateRPMFreeList_exit:
169 /* Lock over handle lookup cleanup. */
178 /* Unreference the previously looked up handle */
181 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
183 PVRSRV_HANDLE_TYPE_RGX_SERVER_RPM_CONTEXT);
186 /* Release now we have cleaned up look up handles. */
189 if (psRGXCreateRPMFreeListOUT->eError != PVRSRV_OK)
191 if (psCleanupCookieInt)
193 RGXDestroyRPMFreeList(psCleanupCookieInt);
203 PVRSRVBridgeRGXDestroyRPMFreeList(IMG_UINT32 ui32DispatchTableEntry,
204 PVRSRV_BRIDGE_IN_RGXDESTROYRPMFREELIST *psRGXDestroyRPMFreeListIN,
205 PVRSRV_BRIDGE_OUT_RGXDESTROYRPMFREELIST *psRGXDestroyRPMFreeListOUT,
206 CONNECTION_DATA *psConnection)
211 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
213 /* Check that device supports the required feature */
214 if ((psDeviceNode->pfnCheckDeviceFeature) &&
215 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
217 psRGXDestroyRPMFreeListOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
219 goto RGXDestroyRPMFreeList_exit;
229 /* Lock over handle destruction. */
236 psRGXDestroyRPMFreeListOUT->eError =
237 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
238 (IMG_HANDLE) psRGXDestroyRPMFreeListIN->hCleanupCookie,
239 PVRSRV_HANDLE_TYPE_RGX_RPM_FREELIST);
240 if ((psRGXDestroyRPMFreeListOUT->eError != PVRSRV_OK) &&
241 (psRGXDestroyRPMFreeListOUT->eError != PVRSRV_ERROR_RETRY))
243 PVR_DPF((PVR_DBG_ERROR,
244 "PVRSRVBridgeRGXDestroyRPMFreeList: %s",
245 PVRSRVGetErrorStringKM(psRGXDestroyRPMFreeListOUT->eError)));
248 goto RGXDestroyRPMFreeList_exit;
251 /* Release now we have destroyed handles. */
256 RGXDestroyRPMFreeList_exit:
266 PVRSRVBridgeRGXCreateRPMContext(IMG_UINT32 ui32DispatchTableEntry,
267 PVRSRV_BRIDGE_IN_RGXCREATERPMCONTEXT *psRGXCreateRPMContextIN,
268 PVRSRV_BRIDGE_OUT_RGXCREATERPMCONTEXT *psRGXCreateRPMContextOUT,
269 CONNECTION_DATA *psConnection)
271 RGX_SERVER_RPM_CONTEXT * psCleanupCookieInt = NULL;
272 IMG_HANDLE hSceneHeap = psRGXCreateRPMContextIN->hSceneHeap;
273 DEVMEMINT_HEAP * psSceneHeapInt = NULL;
274 IMG_HANDLE hRPMPageTableHeap = psRGXCreateRPMContextIN->hRPMPageTableHeap;
275 DEVMEMINT_HEAP * psRPMPageTableHeapInt = NULL;
276 DEVMEM_MEMDESC * psHWMemDescInt = NULL;
280 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
282 /* Check that device supports the required feature */
283 if ((psDeviceNode->pfnCheckDeviceFeature) &&
284 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
286 psRGXCreateRPMContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
288 goto RGXCreateRPMContext_exit;
294 psRGXCreateRPMContextOUT->hCleanupCookie = NULL;
297 /* Lock over handle lookup. */
305 /* Look up the address from the handle */
306 psRGXCreateRPMContextOUT->eError =
307 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
308 (void **) &psSceneHeapInt,
310 PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP,
312 if(psRGXCreateRPMContextOUT->eError != PVRSRV_OK)
315 goto RGXCreateRPMContext_exit;
324 /* Look up the address from the handle */
325 psRGXCreateRPMContextOUT->eError =
326 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
327 (void **) &psRPMPageTableHeapInt,
329 PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP,
331 if(psRGXCreateRPMContextOUT->eError != PVRSRV_OK)
334 goto RGXCreateRPMContext_exit;
337 /* Release now we have looked up handles. */
340 psRGXCreateRPMContextOUT->eError =
341 RGXCreateRPMContext(psConnection, OSGetDevData(psConnection),
343 psRGXCreateRPMContextIN->ui32TotalRPMPages,
344 psRGXCreateRPMContextIN->ui32Log2DopplerPageSize,
345 psRGXCreateRPMContextIN->sSceneMemoryBaseAddr,
346 psRGXCreateRPMContextIN->sDopplerHeapBaseAddr,
348 psRGXCreateRPMContextIN->sRPMPageTableBaseAddr,
349 psRPMPageTableHeapInt,
351 &psRGXCreateRPMContextOUT->ui32HWFrameData);
352 /* Exit early if bridged call fails */
353 if(psRGXCreateRPMContextOUT->eError != PVRSRV_OK)
355 goto RGXCreateRPMContext_exit;
358 /* Lock over handle creation. */
365 psRGXCreateRPMContextOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
367 &psRGXCreateRPMContextOUT->hCleanupCookie,
368 (void *) psCleanupCookieInt,
369 PVRSRV_HANDLE_TYPE_RGX_SERVER_RPM_CONTEXT,
370 PVRSRV_HANDLE_ALLOC_FLAG_NONE
371 ,(PFN_HANDLE_RELEASE)&RGXDestroyRPMContext);
372 if (psRGXCreateRPMContextOUT->eError != PVRSRV_OK)
375 goto RGXCreateRPMContext_exit;
383 psRGXCreateRPMContextOUT->eError = PVRSRVAllocSubHandleUnlocked(psConnection->psHandleBase,
385 &psRGXCreateRPMContextOUT->hHWMemDesc,
386 (void *) psHWMemDescInt,
387 PVRSRV_HANDLE_TYPE_RGX_FW_MEMDESC,
388 PVRSRV_HANDLE_ALLOC_FLAG_NONE
389 ,psRGXCreateRPMContextOUT->hCleanupCookie);
390 if (psRGXCreateRPMContextOUT->eError != PVRSRV_OK)
393 goto RGXCreateRPMContext_exit;
396 /* Release now we have created handles. */
401 RGXCreateRPMContext_exit:
403 /* Lock over handle lookup cleanup. */
412 /* Unreference the previously looked up handle */
415 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
417 PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP);
426 /* Unreference the previously looked up handle */
427 if(psRPMPageTableHeapInt)
429 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
431 PVRSRV_HANDLE_TYPE_DEVMEMINT_HEAP);
434 /* Release now we have cleaned up look up handles. */
437 if (psRGXCreateRPMContextOUT->eError != PVRSRV_OK)
439 /* Lock over handle creation cleanup. */
441 if (psRGXCreateRPMContextOUT->hCleanupCookie)
445 PVRSRV_ERROR eError = PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
446 (IMG_HANDLE) psRGXCreateRPMContextOUT->hCleanupCookie,
447 PVRSRV_HANDLE_TYPE_RGX_SERVER_RPM_CONTEXT);
448 if ((eError != PVRSRV_OK) && (eError != PVRSRV_ERROR_RETRY))
450 PVR_DPF((PVR_DBG_ERROR,
451 "PVRSRVBridgeRGXCreateRPMContext: %s",
452 PVRSRVGetErrorStringKM(eError)));
454 /* Releasing the handle should free/destroy/release the resource.
455 * This should never fail... */
456 PVR_ASSERT((eError == PVRSRV_OK) || (eError == PVRSRV_ERROR_RETRY));
458 /* Avoid freeing/destroying/releasing the resource a second time below */
459 psCleanupCookieInt = NULL;
463 /* Release now we have cleaned up creation handles. */
465 if (psCleanupCookieInt)
467 RGXDestroyRPMContext(psCleanupCookieInt);
477 PVRSRVBridgeRGXDestroyRPMContext(IMG_UINT32 ui32DispatchTableEntry,
478 PVRSRV_BRIDGE_IN_RGXDESTROYRPMCONTEXT *psRGXDestroyRPMContextIN,
479 PVRSRV_BRIDGE_OUT_RGXDESTROYRPMCONTEXT *psRGXDestroyRPMContextOUT,
480 CONNECTION_DATA *psConnection)
485 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
487 /* Check that device supports the required feature */
488 if ((psDeviceNode->pfnCheckDeviceFeature) &&
489 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
491 psRGXDestroyRPMContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
493 goto RGXDestroyRPMContext_exit;
503 /* Lock over handle destruction. */
510 psRGXDestroyRPMContextOUT->eError =
511 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
512 (IMG_HANDLE) psRGXDestroyRPMContextIN->hCleanupCookie,
513 PVRSRV_HANDLE_TYPE_RGX_SERVER_RPM_CONTEXT);
514 if ((psRGXDestroyRPMContextOUT->eError != PVRSRV_OK) &&
515 (psRGXDestroyRPMContextOUT->eError != PVRSRV_ERROR_RETRY))
517 PVR_DPF((PVR_DBG_ERROR,
518 "PVRSRVBridgeRGXDestroyRPMContext: %s",
519 PVRSRVGetErrorStringKM(psRGXDestroyRPMContextOUT->eError)));
522 goto RGXDestroyRPMContext_exit;
525 /* Release now we have destroyed handles. */
530 RGXDestroyRPMContext_exit:
540 PVRSRVBridgeRGXKickRS(IMG_UINT32 ui32DispatchTableEntry,
541 PVRSRV_BRIDGE_IN_RGXKICKRS *psRGXKickRSIN,
542 PVRSRV_BRIDGE_OUT_RGXKICKRS *psRGXKickRSOUT,
543 CONNECTION_DATA *psConnection)
545 IMG_HANDLE hRayContext = psRGXKickRSIN->hRayContext;
546 RGX_SERVER_RAY_CONTEXT * psRayContextInt = NULL;
547 SYNC_PRIMITIVE_BLOCK * *psClientFenceUFOSyncPrimBlockInt = NULL;
548 IMG_HANDLE *hClientFenceUFOSyncPrimBlockInt2 = NULL;
549 IMG_UINT32 *ui32ClientFenceSyncOffsetInt = NULL;
550 IMG_UINT32 *ui32ClientFenceValueInt = NULL;
551 SYNC_PRIMITIVE_BLOCK * *psClientUpdateUFOSyncPrimBlockInt = NULL;
552 IMG_HANDLE *hClientUpdateUFOSyncPrimBlockInt2 = NULL;
553 IMG_UINT32 *ui32ClientUpdateSyncOffsetInt = NULL;
554 IMG_UINT32 *ui32ClientUpdateValueInt = NULL;
555 IMG_UINT32 *ui32ServerSyncFlagsInt = NULL;
556 SERVER_SYNC_PRIMITIVE * *psServerSyncsInt = NULL;
557 IMG_HANDLE *hServerSyncsInt2 = NULL;
558 IMG_BYTE *psDMCmdInt = NULL;
559 IMG_BYTE *psFCDMCmdInt = NULL;
561 IMG_UINT32 ui32NextOffset = 0;
562 IMG_BYTE *pArrayArgsBuffer = NULL;
563 #if !defined(INTEGRITY_OS)
564 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
567 IMG_UINT32 ui32BufferSize =
568 (psRGXKickRSIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
569 (psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) +
570 (psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
571 (psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
572 (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
573 (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) +
574 (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
575 (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
576 (psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) +
577 (psRGXKickRSIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)) +
578 (psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) +
579 (psRGXKickRSIN->ui32CmdSize * sizeof(IMG_BYTE)) +
580 (psRGXKickRSIN->ui32FCCmdSize * sizeof(IMG_BYTE)) +
584 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
586 /* Check that device supports the required feature */
587 if ((psDeviceNode->pfnCheckDeviceFeature) &&
588 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
590 psRGXKickRSOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
599 if (ui32BufferSize != 0)
601 #if !defined(INTEGRITY_OS)
602 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
603 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXKickRSIN), sizeof(unsigned long));
604 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
605 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
607 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
608 if (bHaveEnoughSpace)
610 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXKickRSIN;
612 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
616 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
618 if(!pArrayArgsBuffer)
620 psRGXKickRSOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
626 if (psRGXKickRSIN->ui32ClientFenceCount != 0)
628 psClientFenceUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
629 ui32NextOffset += psRGXKickRSIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
630 hClientFenceUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
631 ui32NextOffset += psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_HANDLE);
634 /* Copy the data over */
635 if (psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_HANDLE) > 0)
637 if ( OSCopyFromUser(NULL, hClientFenceUFOSyncPrimBlockInt2, psRGXKickRSIN->phClientFenceUFOSyncPrimBlock, psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
639 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
644 if (psRGXKickRSIN->ui32ClientFenceCount != 0)
646 ui32ClientFenceSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
647 ui32NextOffset += psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
650 /* Copy the data over */
651 if (psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
653 if ( OSCopyFromUser(NULL, ui32ClientFenceSyncOffsetInt, psRGXKickRSIN->pui32ClientFenceSyncOffset, psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
655 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
660 if (psRGXKickRSIN->ui32ClientFenceCount != 0)
662 ui32ClientFenceValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
663 ui32NextOffset += psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
666 /* Copy the data over */
667 if (psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
669 if ( OSCopyFromUser(NULL, ui32ClientFenceValueInt, psRGXKickRSIN->pui32ClientFenceValue, psRGXKickRSIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
671 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
676 if (psRGXKickRSIN->ui32ClientUpdateCount != 0)
678 psClientUpdateUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
679 ui32NextOffset += psRGXKickRSIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
680 hClientUpdateUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
681 ui32NextOffset += psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE);
684 /* Copy the data over */
685 if (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE) > 0)
687 if ( OSCopyFromUser(NULL, hClientUpdateUFOSyncPrimBlockInt2, psRGXKickRSIN->phClientUpdateUFOSyncPrimBlock, psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
689 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
694 if (psRGXKickRSIN->ui32ClientUpdateCount != 0)
696 ui32ClientUpdateSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
697 ui32NextOffset += psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
700 /* Copy the data over */
701 if (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
703 if ( OSCopyFromUser(NULL, ui32ClientUpdateSyncOffsetInt, psRGXKickRSIN->pui32ClientUpdateSyncOffset, psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
705 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
710 if (psRGXKickRSIN->ui32ClientUpdateCount != 0)
712 ui32ClientUpdateValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
713 ui32NextOffset += psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
716 /* Copy the data over */
717 if (psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
719 if ( OSCopyFromUser(NULL, ui32ClientUpdateValueInt, psRGXKickRSIN->pui32ClientUpdateValue, psRGXKickRSIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
721 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
726 if (psRGXKickRSIN->ui32ServerSyncCount != 0)
728 ui32ServerSyncFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
729 ui32NextOffset += psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_UINT32);
732 /* Copy the data over */
733 if (psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_UINT32) > 0)
735 if ( OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXKickRSIN->pui32ServerSyncFlags, psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
737 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
742 if (psRGXKickRSIN->ui32ServerSyncCount != 0)
744 psServerSyncsInt = (SERVER_SYNC_PRIMITIVE **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
745 ui32NextOffset += psRGXKickRSIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *);
746 hServerSyncsInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
747 ui32NextOffset += psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_HANDLE);
750 /* Copy the data over */
751 if (psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_HANDLE) > 0)
753 if ( OSCopyFromUser(NULL, hServerSyncsInt2, psRGXKickRSIN->phServerSyncs, psRGXKickRSIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
755 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
760 if (psRGXKickRSIN->ui32CmdSize != 0)
762 psDMCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
763 ui32NextOffset += psRGXKickRSIN->ui32CmdSize * sizeof(IMG_BYTE);
766 /* Copy the data over */
767 if (psRGXKickRSIN->ui32CmdSize * sizeof(IMG_BYTE) > 0)
769 if ( OSCopyFromUser(NULL, psDMCmdInt, psRGXKickRSIN->psDMCmd, psRGXKickRSIN->ui32CmdSize * sizeof(IMG_BYTE)) != PVRSRV_OK )
771 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
776 if (psRGXKickRSIN->ui32FCCmdSize != 0)
778 psFCDMCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
779 ui32NextOffset += psRGXKickRSIN->ui32FCCmdSize * sizeof(IMG_BYTE);
782 /* Copy the data over */
783 if (psRGXKickRSIN->ui32FCCmdSize * sizeof(IMG_BYTE) > 0)
785 if ( OSCopyFromUser(NULL, psFCDMCmdInt, psRGXKickRSIN->psFCDMCmd, psRGXKickRSIN->ui32FCCmdSize * sizeof(IMG_BYTE)) != PVRSRV_OK )
787 psRGXKickRSOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
793 /* Lock over handle lookup. */
801 /* Look up the address from the handle */
802 psRGXKickRSOUT->eError =
803 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
804 (void **) &psRayContextInt,
806 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT,
808 if(psRGXKickRSOUT->eError != PVRSRV_OK)
822 for (i=0;i<psRGXKickRSIN->ui32ClientFenceCount;i++)
825 /* Look up the address from the handle */
826 psRGXKickRSOUT->eError =
827 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
828 (void **) &psClientFenceUFOSyncPrimBlockInt[i],
829 hClientFenceUFOSyncPrimBlockInt2[i],
830 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
832 if(psRGXKickRSOUT->eError != PVRSRV_OK)
848 for (i=0;i<psRGXKickRSIN->ui32ClientUpdateCount;i++)
851 /* Look up the address from the handle */
852 psRGXKickRSOUT->eError =
853 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
854 (void **) &psClientUpdateUFOSyncPrimBlockInt[i],
855 hClientUpdateUFOSyncPrimBlockInt2[i],
856 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
858 if(psRGXKickRSOUT->eError != PVRSRV_OK)
874 for (i=0;i<psRGXKickRSIN->ui32ServerSyncCount;i++)
877 /* Look up the address from the handle */
878 psRGXKickRSOUT->eError =
879 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
880 (void **) &psServerSyncsInt[i],
882 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
884 if(psRGXKickRSOUT->eError != PVRSRV_OK)
892 /* Release now we have looked up handles. */
895 psRGXKickRSOUT->eError =
898 psRGXKickRSIN->ui32ClientCacheOpSeqNum,
899 psRGXKickRSIN->ui32ClientFenceCount,
900 psClientFenceUFOSyncPrimBlockInt,
901 ui32ClientFenceSyncOffsetInt,
902 ui32ClientFenceValueInt,
903 psRGXKickRSIN->ui32ClientUpdateCount,
904 psClientUpdateUFOSyncPrimBlockInt,
905 ui32ClientUpdateSyncOffsetInt,
906 ui32ClientUpdateValueInt,
907 psRGXKickRSIN->ui32ServerSyncCount,
908 ui32ServerSyncFlagsInt,
910 psRGXKickRSIN->ui32CmdSize,
912 psRGXKickRSIN->ui32FCCmdSize,
914 psRGXKickRSIN->ui32FrameContext,
915 psRGXKickRSIN->ui32PDumpFlags,
916 psRGXKickRSIN->ui32ExtJobRef);
923 /* Lock over handle lookup cleanup. */
932 /* Unreference the previously looked up handle */
935 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
937 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT);
948 for (i=0;i<psRGXKickRSIN->ui32ClientFenceCount;i++)
951 /* Unreference the previously looked up handle */
952 if(psClientFenceUFOSyncPrimBlockInt[i])
954 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
955 hClientFenceUFOSyncPrimBlockInt2[i],
956 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
969 for (i=0;i<psRGXKickRSIN->ui32ClientUpdateCount;i++)
972 /* Unreference the previously looked up handle */
973 if(psClientUpdateUFOSyncPrimBlockInt[i])
975 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
976 hClientUpdateUFOSyncPrimBlockInt2[i],
977 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
990 for (i=0;i<psRGXKickRSIN->ui32ServerSyncCount;i++)
993 /* Unreference the previously looked up handle */
994 if(psServerSyncsInt[i])
996 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
998 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
1003 /* Release now we have cleaned up look up handles. */
1006 /* Allocated space should be equal to the last updated offset */
1007 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
1009 #if defined(INTEGRITY_OS)
1010 if(pArrayArgsBuffer)
1012 if(!bHaveEnoughSpace && pArrayArgsBuffer)
1014 OSFreeMemNoStats(pArrayArgsBuffer);
1022 PVRSRVBridgeRGXKickVRDM(IMG_UINT32 ui32DispatchTableEntry,
1023 PVRSRV_BRIDGE_IN_RGXKICKVRDM *psRGXKickVRDMIN,
1024 PVRSRV_BRIDGE_OUT_RGXKICKVRDM *psRGXKickVRDMOUT,
1025 CONNECTION_DATA *psConnection)
1027 IMG_HANDLE hRayContext = psRGXKickVRDMIN->hRayContext;
1028 RGX_SERVER_RAY_CONTEXT * psRayContextInt = NULL;
1029 SYNC_PRIMITIVE_BLOCK * *psClientFenceUFOSyncPrimBlockInt = NULL;
1030 IMG_HANDLE *hClientFenceUFOSyncPrimBlockInt2 = NULL;
1031 IMG_UINT32 *ui32ClientFenceSyncOffsetInt = NULL;
1032 IMG_UINT32 *ui32ClientFenceValueInt = NULL;
1033 SYNC_PRIMITIVE_BLOCK * *psClientUpdateUFOSyncPrimBlockInt = NULL;
1034 IMG_HANDLE *hClientUpdateUFOSyncPrimBlockInt2 = NULL;
1035 IMG_UINT32 *ui32ClientUpdateSyncOffsetInt = NULL;
1036 IMG_UINT32 *ui32ClientUpdateValueInt = NULL;
1037 IMG_UINT32 *ui32ServerSyncFlagsInt = NULL;
1038 SERVER_SYNC_PRIMITIVE * *psServerSyncsInt = NULL;
1039 IMG_HANDLE *hServerSyncsInt2 = NULL;
1040 IMG_BYTE *psDMCmdInt = NULL;
1042 IMG_UINT32 ui32NextOffset = 0;
1043 IMG_BYTE *pArrayArgsBuffer = NULL;
1044 #if !defined(INTEGRITY_OS)
1045 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
1048 IMG_UINT32 ui32BufferSize =
1049 (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
1050 (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) +
1051 (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
1052 (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
1053 (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
1054 (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) +
1055 (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
1056 (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
1057 (psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) +
1058 (psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)) +
1059 (psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) +
1060 (psRGXKickVRDMIN->ui32CmdSize * sizeof(IMG_BYTE)) +
1064 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
1066 /* Check that device supports the required feature */
1067 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1068 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
1070 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1072 goto RGXKickVRDM_exit;
1079 if (ui32BufferSize != 0)
1081 #if !defined(INTEGRITY_OS)
1082 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
1083 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXKickVRDMIN), sizeof(unsigned long));
1084 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
1085 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
1087 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
1088 if (bHaveEnoughSpace)
1090 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXKickVRDMIN;
1092 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
1096 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
1098 if(!pArrayArgsBuffer)
1100 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1101 goto RGXKickVRDM_exit;
1106 if (psRGXKickVRDMIN->ui32ClientFenceCount != 0)
1108 psClientFenceUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1109 ui32NextOffset += psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
1110 hClientFenceUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1111 ui32NextOffset += psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE);
1114 /* Copy the data over */
1115 if (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE) > 0)
1117 if ( OSCopyFromUser(NULL, hClientFenceUFOSyncPrimBlockInt2, psRGXKickVRDMIN->phClientFenceUFOSyncPrimBlock, psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
1119 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1121 goto RGXKickVRDM_exit;
1124 if (psRGXKickVRDMIN->ui32ClientFenceCount != 0)
1126 ui32ClientFenceSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1127 ui32NextOffset += psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
1130 /* Copy the data over */
1131 if (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
1133 if ( OSCopyFromUser(NULL, ui32ClientFenceSyncOffsetInt, psRGXKickVRDMIN->pui32ClientFenceSyncOffset, psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
1135 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1137 goto RGXKickVRDM_exit;
1140 if (psRGXKickVRDMIN->ui32ClientFenceCount != 0)
1142 ui32ClientFenceValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1143 ui32NextOffset += psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
1146 /* Copy the data over */
1147 if (psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
1149 if ( OSCopyFromUser(NULL, ui32ClientFenceValueInt, psRGXKickVRDMIN->pui32ClientFenceValue, psRGXKickVRDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
1151 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1153 goto RGXKickVRDM_exit;
1156 if (psRGXKickVRDMIN->ui32ClientUpdateCount != 0)
1158 psClientUpdateUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1159 ui32NextOffset += psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
1160 hClientUpdateUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1161 ui32NextOffset += psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE);
1164 /* Copy the data over */
1165 if (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE) > 0)
1167 if ( OSCopyFromUser(NULL, hClientUpdateUFOSyncPrimBlockInt2, psRGXKickVRDMIN->phClientUpdateUFOSyncPrimBlock, psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
1169 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1171 goto RGXKickVRDM_exit;
1174 if (psRGXKickVRDMIN->ui32ClientUpdateCount != 0)
1176 ui32ClientUpdateSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1177 ui32NextOffset += psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
1180 /* Copy the data over */
1181 if (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
1183 if ( OSCopyFromUser(NULL, ui32ClientUpdateSyncOffsetInt, psRGXKickVRDMIN->pui32ClientUpdateSyncOffset, psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
1185 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1187 goto RGXKickVRDM_exit;
1190 if (psRGXKickVRDMIN->ui32ClientUpdateCount != 0)
1192 ui32ClientUpdateValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1193 ui32NextOffset += psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
1196 /* Copy the data over */
1197 if (psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
1199 if ( OSCopyFromUser(NULL, ui32ClientUpdateValueInt, psRGXKickVRDMIN->pui32ClientUpdateValue, psRGXKickVRDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
1201 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1203 goto RGXKickVRDM_exit;
1206 if (psRGXKickVRDMIN->ui32ServerSyncCount != 0)
1208 ui32ServerSyncFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1209 ui32NextOffset += psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32);
1212 /* Copy the data over */
1213 if (psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32) > 0)
1215 if ( OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXKickVRDMIN->pui32ServerSyncFlags, psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
1217 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1219 goto RGXKickVRDM_exit;
1222 if (psRGXKickVRDMIN->ui32ServerSyncCount != 0)
1224 psServerSyncsInt = (SERVER_SYNC_PRIMITIVE **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1225 ui32NextOffset += psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *);
1226 hServerSyncsInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1227 ui32NextOffset += psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE);
1230 /* Copy the data over */
1231 if (psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE) > 0)
1233 if ( OSCopyFromUser(NULL, hServerSyncsInt2, psRGXKickVRDMIN->phServerSyncs, psRGXKickVRDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
1235 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1237 goto RGXKickVRDM_exit;
1240 if (psRGXKickVRDMIN->ui32CmdSize != 0)
1242 psDMCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1243 ui32NextOffset += psRGXKickVRDMIN->ui32CmdSize * sizeof(IMG_BYTE);
1246 /* Copy the data over */
1247 if (psRGXKickVRDMIN->ui32CmdSize * sizeof(IMG_BYTE) > 0)
1249 if ( OSCopyFromUser(NULL, psDMCmdInt, psRGXKickVRDMIN->psDMCmd, psRGXKickVRDMIN->ui32CmdSize * sizeof(IMG_BYTE)) != PVRSRV_OK )
1251 psRGXKickVRDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1253 goto RGXKickVRDM_exit;
1257 /* Lock over handle lookup. */
1265 /* Look up the address from the handle */
1266 psRGXKickVRDMOUT->eError =
1267 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1268 (void **) &psRayContextInt,
1270 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT,
1272 if(psRGXKickVRDMOUT->eError != PVRSRV_OK)
1275 goto RGXKickVRDM_exit;
1286 for (i=0;i<psRGXKickVRDMIN->ui32ClientFenceCount;i++)
1289 /* Look up the address from the handle */
1290 psRGXKickVRDMOUT->eError =
1291 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1292 (void **) &psClientFenceUFOSyncPrimBlockInt[i],
1293 hClientFenceUFOSyncPrimBlockInt2[i],
1294 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
1296 if(psRGXKickVRDMOUT->eError != PVRSRV_OK)
1299 goto RGXKickVRDM_exit;
1312 for (i=0;i<psRGXKickVRDMIN->ui32ClientUpdateCount;i++)
1315 /* Look up the address from the handle */
1316 psRGXKickVRDMOUT->eError =
1317 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1318 (void **) &psClientUpdateUFOSyncPrimBlockInt[i],
1319 hClientUpdateUFOSyncPrimBlockInt2[i],
1320 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
1322 if(psRGXKickVRDMOUT->eError != PVRSRV_OK)
1325 goto RGXKickVRDM_exit;
1338 for (i=0;i<psRGXKickVRDMIN->ui32ServerSyncCount;i++)
1341 /* Look up the address from the handle */
1342 psRGXKickVRDMOUT->eError =
1343 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1344 (void **) &psServerSyncsInt[i],
1345 hServerSyncsInt2[i],
1346 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
1348 if(psRGXKickVRDMOUT->eError != PVRSRV_OK)
1351 goto RGXKickVRDM_exit;
1356 /* Release now we have looked up handles. */
1359 psRGXKickVRDMOUT->eError =
1360 PVRSRVRGXKickVRDMKM(
1362 psRGXKickVRDMIN->ui32ClientCacheOpSeqNum,
1363 psRGXKickVRDMIN->ui32ClientFenceCount,
1364 psClientFenceUFOSyncPrimBlockInt,
1365 ui32ClientFenceSyncOffsetInt,
1366 ui32ClientFenceValueInt,
1367 psRGXKickVRDMIN->ui32ClientUpdateCount,
1368 psClientUpdateUFOSyncPrimBlockInt,
1369 ui32ClientUpdateSyncOffsetInt,
1370 ui32ClientUpdateValueInt,
1371 psRGXKickVRDMIN->ui32ServerSyncCount,
1372 ui32ServerSyncFlagsInt,
1374 psRGXKickVRDMIN->ui32CmdSize,
1376 psRGXKickVRDMIN->ui32PDumpFlags,
1377 psRGXKickVRDMIN->ui32ExtJobRef);
1384 /* Lock over handle lookup cleanup. */
1393 /* Unreference the previously looked up handle */
1396 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1398 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT);
1409 for (i=0;i<psRGXKickVRDMIN->ui32ClientFenceCount;i++)
1412 /* Unreference the previously looked up handle */
1413 if(psClientFenceUFOSyncPrimBlockInt[i])
1415 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1416 hClientFenceUFOSyncPrimBlockInt2[i],
1417 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
1430 for (i=0;i<psRGXKickVRDMIN->ui32ClientUpdateCount;i++)
1433 /* Unreference the previously looked up handle */
1434 if(psClientUpdateUFOSyncPrimBlockInt[i])
1436 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1437 hClientUpdateUFOSyncPrimBlockInt2[i],
1438 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
1451 for (i=0;i<psRGXKickVRDMIN->ui32ServerSyncCount;i++)
1454 /* Unreference the previously looked up handle */
1455 if(psServerSyncsInt[i])
1457 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1458 hServerSyncsInt2[i],
1459 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
1464 /* Release now we have cleaned up look up handles. */
1467 /* Allocated space should be equal to the last updated offset */
1468 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
1470 #if defined(INTEGRITY_OS)
1471 if(pArrayArgsBuffer)
1473 if(!bHaveEnoughSpace && pArrayArgsBuffer)
1475 OSFreeMemNoStats(pArrayArgsBuffer);
1483 PVRSRVBridgeRGXCreateRayContext(IMG_UINT32 ui32DispatchTableEntry,
1484 PVRSRV_BRIDGE_IN_RGXCREATERAYCONTEXT *psRGXCreateRayContextIN,
1485 PVRSRV_BRIDGE_OUT_RGXCREATERAYCONTEXT *psRGXCreateRayContextOUT,
1486 CONNECTION_DATA *psConnection)
1488 IMG_BYTE *psFrameworkCmdInt = NULL;
1489 IMG_HANDLE hPrivData = psRGXCreateRayContextIN->hPrivData;
1490 IMG_HANDLE hPrivDataInt = NULL;
1491 RGX_SERVER_RAY_CONTEXT * psRayContextInt = NULL;
1493 IMG_UINT32 ui32NextOffset = 0;
1494 IMG_BYTE *pArrayArgsBuffer = NULL;
1495 #if !defined(INTEGRITY_OS)
1496 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
1499 IMG_UINT32 ui32BufferSize =
1500 (psRGXCreateRayContextIN->ui32FrameworkCmdSize * sizeof(IMG_BYTE)) +
1504 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
1506 /* Check that device supports the required feature */
1507 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1508 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
1510 psRGXCreateRayContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1512 goto RGXCreateRayContext_exit;
1519 if (ui32BufferSize != 0)
1521 #if !defined(INTEGRITY_OS)
1522 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
1523 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXCreateRayContextIN), sizeof(unsigned long));
1524 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
1525 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
1527 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
1528 if (bHaveEnoughSpace)
1530 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXCreateRayContextIN;
1532 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
1536 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
1538 if(!pArrayArgsBuffer)
1540 psRGXCreateRayContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
1541 goto RGXCreateRayContext_exit;
1546 if (psRGXCreateRayContextIN->ui32FrameworkCmdSize != 0)
1548 psFrameworkCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
1549 ui32NextOffset += psRGXCreateRayContextIN->ui32FrameworkCmdSize * sizeof(IMG_BYTE);
1552 /* Copy the data over */
1553 if (psRGXCreateRayContextIN->ui32FrameworkCmdSize * sizeof(IMG_BYTE) > 0)
1555 if ( OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXCreateRayContextIN->psFrameworkCmd, psRGXCreateRayContextIN->ui32FrameworkCmdSize * sizeof(IMG_BYTE)) != PVRSRV_OK )
1557 psRGXCreateRayContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
1559 goto RGXCreateRayContext_exit;
1563 /* Lock over handle lookup. */
1571 /* Look up the address from the handle */
1572 psRGXCreateRayContextOUT->eError =
1573 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1574 (void **) &hPrivDataInt,
1576 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
1578 if(psRGXCreateRayContextOUT->eError != PVRSRV_OK)
1581 goto RGXCreateRayContext_exit;
1584 /* Release now we have looked up handles. */
1587 psRGXCreateRayContextOUT->eError =
1588 PVRSRVRGXCreateRayContextKM(psConnection, OSGetDevData(psConnection),
1589 psRGXCreateRayContextIN->ui32Priority,
1590 psRGXCreateRayContextIN->sMCUFenceAddr,
1591 psRGXCreateRayContextIN->sVRMCallStackAddr,
1592 psRGXCreateRayContextIN->ui32FrameworkCmdSize,
1596 /* Exit early if bridged call fails */
1597 if(psRGXCreateRayContextOUT->eError != PVRSRV_OK)
1599 goto RGXCreateRayContext_exit;
1602 /* Lock over handle creation. */
1609 psRGXCreateRayContextOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
1611 &psRGXCreateRayContextOUT->hRayContext,
1612 (void *) psRayContextInt,
1613 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT,
1614 PVRSRV_HANDLE_ALLOC_FLAG_MULTI
1615 ,(PFN_HANDLE_RELEASE)&PVRSRVRGXDestroyRayContextKM);
1616 if (psRGXCreateRayContextOUT->eError != PVRSRV_OK)
1619 goto RGXCreateRayContext_exit;
1622 /* Release now we have created handles. */
1627 RGXCreateRayContext_exit:
1629 /* Lock over handle lookup cleanup. */
1638 /* Unreference the previously looked up handle */
1641 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1643 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
1646 /* Release now we have cleaned up look up handles. */
1649 if (psRGXCreateRayContextOUT->eError != PVRSRV_OK)
1651 if (psRayContextInt)
1653 PVRSRVRGXDestroyRayContextKM(psRayContextInt);
1657 /* Allocated space should be equal to the last updated offset */
1658 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
1660 #if defined(INTEGRITY_OS)
1661 if(pArrayArgsBuffer)
1663 if(!bHaveEnoughSpace && pArrayArgsBuffer)
1665 OSFreeMemNoStats(pArrayArgsBuffer);
1673 PVRSRVBridgeRGXDestroyRayContext(IMG_UINT32 ui32DispatchTableEntry,
1674 PVRSRV_BRIDGE_IN_RGXDESTROYRAYCONTEXT *psRGXDestroyRayContextIN,
1675 PVRSRV_BRIDGE_OUT_RGXDESTROYRAYCONTEXT *psRGXDestroyRayContextOUT,
1676 CONNECTION_DATA *psConnection)
1681 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
1683 /* Check that device supports the required feature */
1684 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1685 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
1687 psRGXDestroyRayContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1689 goto RGXDestroyRayContext_exit;
1699 /* Lock over handle destruction. */
1706 psRGXDestroyRayContextOUT->eError =
1707 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1708 (IMG_HANDLE) psRGXDestroyRayContextIN->hRayContext,
1709 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT);
1710 if ((psRGXDestroyRayContextOUT->eError != PVRSRV_OK) &&
1711 (psRGXDestroyRayContextOUT->eError != PVRSRV_ERROR_RETRY))
1713 PVR_DPF((PVR_DBG_ERROR,
1714 "PVRSRVBridgeRGXDestroyRayContext: %s",
1715 PVRSRVGetErrorStringKM(psRGXDestroyRayContextOUT->eError)));
1718 goto RGXDestroyRayContext_exit;
1721 /* Release now we have destroyed handles. */
1726 RGXDestroyRayContext_exit:
1736 PVRSRVBridgeRGXSetRayContextPriority(IMG_UINT32 ui32DispatchTableEntry,
1737 PVRSRV_BRIDGE_IN_RGXSETRAYCONTEXTPRIORITY *psRGXSetRayContextPriorityIN,
1738 PVRSRV_BRIDGE_OUT_RGXSETRAYCONTEXTPRIORITY *psRGXSetRayContextPriorityOUT,
1739 CONNECTION_DATA *psConnection)
1741 IMG_HANDLE hRayContext = psRGXSetRayContextPriorityIN->hRayContext;
1742 RGX_SERVER_RAY_CONTEXT * psRayContextInt = NULL;
1746 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
1748 /* Check that device supports the required feature */
1749 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1750 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_RAY_TRACING_BIT_MASK))
1752 psRGXSetRayContextPriorityOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1754 goto RGXSetRayContextPriority_exit;
1762 /* Lock over handle lookup. */
1770 /* Look up the address from the handle */
1771 psRGXSetRayContextPriorityOUT->eError =
1772 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1773 (void **) &psRayContextInt,
1775 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT,
1777 if(psRGXSetRayContextPriorityOUT->eError != PVRSRV_OK)
1780 goto RGXSetRayContextPriority_exit;
1783 /* Release now we have looked up handles. */
1786 psRGXSetRayContextPriorityOUT->eError =
1787 PVRSRVRGXSetRayContextPriorityKM(psConnection, OSGetDevData(psConnection),
1789 psRGXSetRayContextPriorityIN->ui32Priority);
1794 RGXSetRayContextPriority_exit:
1796 /* Lock over handle lookup cleanup. */
1805 /* Unreference the previously looked up handle */
1808 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1810 PVRSRV_HANDLE_TYPE_RGX_SERVER_RAY_CONTEXT);
1813 /* Release now we have cleaned up look up handles. */
1823 /* ***************************************************************************
1824 * Server bridge dispatch related glue
1827 static IMG_BOOL bUseLock = IMG_TRUE;
1829 PVRSRV_ERROR InitRGXRAYBridge(void);
1830 PVRSRV_ERROR DeinitRGXRAYBridge(void);
1833 * Register all RGXRAY functions with services
1835 PVRSRV_ERROR InitRGXRAYBridge(void)
1838 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXCREATERPMFREELIST, PVRSRVBridgeRGXCreateRPMFreeList,
1841 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXDESTROYRPMFREELIST, PVRSRVBridgeRGXDestroyRPMFreeList,
1844 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXCREATERPMCONTEXT, PVRSRVBridgeRGXCreateRPMContext,
1847 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXDESTROYRPMCONTEXT, PVRSRVBridgeRGXDestroyRPMContext,
1850 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXKICKRS, PVRSRVBridgeRGXKickRS,
1853 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXKICKVRDM, PVRSRVBridgeRGXKickVRDM,
1856 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXCREATERAYCONTEXT, PVRSRVBridgeRGXCreateRayContext,
1859 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXDESTROYRAYCONTEXT, PVRSRVBridgeRGXDestroyRayContext,
1862 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXRAY, PVRSRV_BRIDGE_RGXRAY_RGXSETRAYCONTEXTPRIORITY, PVRSRVBridgeRGXSetRayContextPriority,
1870 * Unregister all rgxray functions with services
1872 PVRSRV_ERROR DeinitRGXRAYBridge(void)