1 /*************************************************************************/ /*!
3 @Title Server bridge for rgxcmp
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Implements the server side of the bridge for rgxcmp
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 "rgxcompute.h"
52 #include "common_rgxcmp_bridge.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
62 #include <linux/slab.h>
65 #include "rgx_bvnc_defs_km.h"
70 /* ***************************************************************************
71 * Server-side bridge entry points
75 PVRSRVBridgeRGXCreateComputeContext(IMG_UINT32 ui32DispatchTableEntry,
76 PVRSRV_BRIDGE_IN_RGXCREATECOMPUTECONTEXT *psRGXCreateComputeContextIN,
77 PVRSRV_BRIDGE_OUT_RGXCREATECOMPUTECONTEXT *psRGXCreateComputeContextOUT,
78 CONNECTION_DATA *psConnection)
80 IMG_BYTE *psFrameworkCmdInt = NULL;
81 IMG_HANDLE hPrivData = psRGXCreateComputeContextIN->hPrivData;
82 IMG_HANDLE hPrivDataInt = NULL;
83 RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
85 IMG_UINT32 ui32NextOffset = 0;
86 IMG_BYTE *pArrayArgsBuffer = NULL;
87 #if !defined(INTEGRITY_OS)
88 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
91 IMG_UINT32 ui32BufferSize =
92 (psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) +
96 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
98 /* Check that device supports the required feature */
99 if ((psDeviceNode->pfnCheckDeviceFeature) &&
100 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
102 psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
104 goto RGXCreateComputeContext_exit;
111 if (ui32BufferSize != 0)
113 #if !defined(INTEGRITY_OS)
114 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
115 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXCreateComputeContextIN), sizeof(unsigned long));
116 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
117 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
119 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
120 if (bHaveEnoughSpace)
122 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXCreateComputeContextIN;
124 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
128 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
130 if(!pArrayArgsBuffer)
132 psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
133 goto RGXCreateComputeContext_exit;
138 if (psRGXCreateComputeContextIN->ui32FrameworkCmdize != 0)
140 psFrameworkCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
141 ui32NextOffset += psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE);
144 /* Copy the data over */
145 if (psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE) > 0)
147 if ( OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXCreateComputeContextIN->psFrameworkCmd, psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) != PVRSRV_OK )
149 psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
151 goto RGXCreateComputeContext_exit;
155 /* Lock over handle lookup. */
163 /* Look up the address from the handle */
164 psRGXCreateComputeContextOUT->eError =
165 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
166 (void **) &hPrivDataInt,
168 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
170 if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
173 goto RGXCreateComputeContext_exit;
176 /* Release now we have looked up handles. */
179 psRGXCreateComputeContextOUT->eError =
180 PVRSRVRGXCreateComputeContextKM(psConnection, OSGetDevData(psConnection),
181 psRGXCreateComputeContextIN->ui32Priority,
182 psRGXCreateComputeContextIN->sMCUFenceAddr,
183 psRGXCreateComputeContextIN->ui32FrameworkCmdize,
186 psRGXCreateComputeContextIN->sResumeSignalAddr,
187 &psComputeContextInt);
188 /* Exit early if bridged call fails */
189 if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
191 goto RGXCreateComputeContext_exit;
194 /* Lock over handle creation. */
201 psRGXCreateComputeContextOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
203 &psRGXCreateComputeContextOUT->hComputeContext,
204 (void *) psComputeContextInt,
205 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
206 PVRSRV_HANDLE_ALLOC_FLAG_MULTI
207 ,(PFN_HANDLE_RELEASE)&PVRSRVRGXDestroyComputeContextKM);
208 if (psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
211 goto RGXCreateComputeContext_exit;
214 /* Release now we have created handles. */
219 RGXCreateComputeContext_exit:
221 /* Lock over handle lookup cleanup. */
230 /* Unreference the previously looked up handle */
233 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
235 PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
238 /* Release now we have cleaned up look up handles. */
241 if (psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
243 if (psComputeContextInt)
245 PVRSRVRGXDestroyComputeContextKM(psComputeContextInt);
249 /* Allocated space should be equal to the last updated offset */
250 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
252 #if defined(INTEGRITY_OS)
255 if(!bHaveEnoughSpace && pArrayArgsBuffer)
257 OSFreeMemNoStats(pArrayArgsBuffer);
265 PVRSRVBridgeRGXDestroyComputeContext(IMG_UINT32 ui32DispatchTableEntry,
266 PVRSRV_BRIDGE_IN_RGXDESTROYCOMPUTECONTEXT *psRGXDestroyComputeContextIN,
267 PVRSRV_BRIDGE_OUT_RGXDESTROYCOMPUTECONTEXT *psRGXDestroyComputeContextOUT,
268 CONNECTION_DATA *psConnection)
273 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
275 /* Check that device supports the required feature */
276 if ((psDeviceNode->pfnCheckDeviceFeature) &&
277 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
279 psRGXDestroyComputeContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
281 goto RGXDestroyComputeContext_exit;
291 /* Lock over handle destruction. */
298 psRGXDestroyComputeContextOUT->eError =
299 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
300 (IMG_HANDLE) psRGXDestroyComputeContextIN->hComputeContext,
301 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
302 if ((psRGXDestroyComputeContextOUT->eError != PVRSRV_OK) &&
303 (psRGXDestroyComputeContextOUT->eError != PVRSRV_ERROR_RETRY))
305 PVR_DPF((PVR_DBG_ERROR,
306 "PVRSRVBridgeRGXDestroyComputeContext: %s",
307 PVRSRVGetErrorStringKM(psRGXDestroyComputeContextOUT->eError)));
310 goto RGXDestroyComputeContext_exit;
313 /* Release now we have destroyed handles. */
318 RGXDestroyComputeContext_exit:
328 PVRSRVBridgeRGXKickCDM(IMG_UINT32 ui32DispatchTableEntry,
329 PVRSRV_BRIDGE_IN_RGXKICKCDM *psRGXKickCDMIN,
330 PVRSRV_BRIDGE_OUT_RGXKICKCDM *psRGXKickCDMOUT,
331 CONNECTION_DATA *psConnection)
333 IMG_HANDLE hComputeContext = psRGXKickCDMIN->hComputeContext;
334 RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
335 SYNC_PRIMITIVE_BLOCK * *psClientFenceUFOSyncPrimBlockInt = NULL;
336 IMG_HANDLE *hClientFenceUFOSyncPrimBlockInt2 = NULL;
337 IMG_UINT32 *ui32ClientFenceOffsetInt = NULL;
338 IMG_UINT32 *ui32ClientFenceValueInt = NULL;
339 SYNC_PRIMITIVE_BLOCK * *psClientUpdateUFOSyncPrimBlockInt = NULL;
340 IMG_HANDLE *hClientUpdateUFOSyncPrimBlockInt2 = NULL;
341 IMG_UINT32 *ui32ClientUpdateOffsetInt = NULL;
342 IMG_UINT32 *ui32ClientUpdateValueInt = NULL;
343 IMG_UINT32 *ui32ServerSyncFlagsInt = NULL;
344 SERVER_SYNC_PRIMITIVE * *psServerSyncsInt = NULL;
345 IMG_HANDLE *hServerSyncsInt2 = NULL;
346 IMG_CHAR *uiUpdateFenceNameInt = NULL;
347 IMG_BYTE *psDMCmdInt = NULL;
349 IMG_UINT32 ui32NextOffset = 0;
350 IMG_BYTE *pArrayArgsBuffer = NULL;
351 #if !defined(INTEGRITY_OS)
352 IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
355 IMG_UINT32 ui32BufferSize =
356 (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
357 (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) +
358 (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
359 (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
360 (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
361 (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) +
362 (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
363 (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
364 (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) +
365 (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)) +
366 (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) +
367 (32 * sizeof(IMG_CHAR)) +
368 (psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE)) +
372 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
374 /* Check that device supports the required feature */
375 if ((psDeviceNode->pfnCheckDeviceFeature) &&
376 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
378 psRGXKickCDMOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
380 goto RGXKickCDM_exit;
387 if (ui32BufferSize != 0)
389 #if !defined(INTEGRITY_OS)
390 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
391 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXKickCDMIN), sizeof(unsigned long));
392 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
393 PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
395 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
396 if (bHaveEnoughSpace)
398 IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXKickCDMIN;
400 pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset]; }
404 pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
406 if(!pArrayArgsBuffer)
408 psRGXKickCDMOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
409 goto RGXKickCDM_exit;
414 if (psRGXKickCDMIN->ui32ClientFenceCount != 0)
416 psClientFenceUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
417 ui32NextOffset += psRGXKickCDMIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
418 hClientFenceUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
419 ui32NextOffset += psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE);
422 /* Copy the data over */
423 if (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE) > 0)
425 if ( OSCopyFromUser(NULL, hClientFenceUFOSyncPrimBlockInt2, psRGXKickCDMIN->phClientFenceUFOSyncPrimBlock, psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
427 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
429 goto RGXKickCDM_exit;
432 if (psRGXKickCDMIN->ui32ClientFenceCount != 0)
434 ui32ClientFenceOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
435 ui32NextOffset += psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
438 /* Copy the data over */
439 if (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
441 if ( OSCopyFromUser(NULL, ui32ClientFenceOffsetInt, psRGXKickCDMIN->pui32ClientFenceOffset, psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
443 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
445 goto RGXKickCDM_exit;
448 if (psRGXKickCDMIN->ui32ClientFenceCount != 0)
450 ui32ClientFenceValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
451 ui32NextOffset += psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
454 /* Copy the data over */
455 if (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
457 if ( OSCopyFromUser(NULL, ui32ClientFenceValueInt, psRGXKickCDMIN->pui32ClientFenceValue, psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
459 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
461 goto RGXKickCDM_exit;
464 if (psRGXKickCDMIN->ui32ClientUpdateCount != 0)
466 psClientUpdateUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
467 ui32NextOffset += psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
468 hClientUpdateUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
469 ui32NextOffset += psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE);
472 /* Copy the data over */
473 if (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE) > 0)
475 if ( OSCopyFromUser(NULL, hClientUpdateUFOSyncPrimBlockInt2, psRGXKickCDMIN->phClientUpdateUFOSyncPrimBlock, psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
477 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
479 goto RGXKickCDM_exit;
482 if (psRGXKickCDMIN->ui32ClientUpdateCount != 0)
484 ui32ClientUpdateOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
485 ui32NextOffset += psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
488 /* Copy the data over */
489 if (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
491 if ( OSCopyFromUser(NULL, ui32ClientUpdateOffsetInt, psRGXKickCDMIN->pui32ClientUpdateOffset, psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
493 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
495 goto RGXKickCDM_exit;
498 if (psRGXKickCDMIN->ui32ClientUpdateCount != 0)
500 ui32ClientUpdateValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
501 ui32NextOffset += psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
504 /* Copy the data over */
505 if (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
507 if ( OSCopyFromUser(NULL, ui32ClientUpdateValueInt, psRGXKickCDMIN->pui32ClientUpdateValue, psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
509 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
511 goto RGXKickCDM_exit;
514 if (psRGXKickCDMIN->ui32ServerSyncCount != 0)
516 ui32ServerSyncFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
517 ui32NextOffset += psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32);
520 /* Copy the data over */
521 if (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32) > 0)
523 if ( OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXKickCDMIN->pui32ServerSyncFlags, psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
525 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
527 goto RGXKickCDM_exit;
530 if (psRGXKickCDMIN->ui32ServerSyncCount != 0)
532 psServerSyncsInt = (SERVER_SYNC_PRIMITIVE **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
533 ui32NextOffset += psRGXKickCDMIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *);
534 hServerSyncsInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
535 ui32NextOffset += psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE);
538 /* Copy the data over */
539 if (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE) > 0)
541 if ( OSCopyFromUser(NULL, hServerSyncsInt2, psRGXKickCDMIN->phServerSyncs, psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
543 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
545 goto RGXKickCDM_exit;
550 uiUpdateFenceNameInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
551 ui32NextOffset += 32 * sizeof(IMG_CHAR);
554 /* Copy the data over */
555 if (32 * sizeof(IMG_CHAR) > 0)
557 if ( OSCopyFromUser(NULL, uiUpdateFenceNameInt, psRGXKickCDMIN->puiUpdateFenceName, 32 * sizeof(IMG_CHAR)) != PVRSRV_OK )
559 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
561 goto RGXKickCDM_exit;
564 if (psRGXKickCDMIN->ui32CmdSize != 0)
566 psDMCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
567 ui32NextOffset += psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE);
570 /* Copy the data over */
571 if (psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE) > 0)
573 if ( OSCopyFromUser(NULL, psDMCmdInt, psRGXKickCDMIN->psDMCmd, psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE)) != PVRSRV_OK )
575 psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
577 goto RGXKickCDM_exit;
581 /* Lock over handle lookup. */
589 /* Look up the address from the handle */
590 psRGXKickCDMOUT->eError =
591 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
592 (void **) &psComputeContextInt,
594 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
596 if(psRGXKickCDMOUT->eError != PVRSRV_OK)
599 goto RGXKickCDM_exit;
610 for (i=0;i<psRGXKickCDMIN->ui32ClientFenceCount;i++)
613 /* Look up the address from the handle */
614 psRGXKickCDMOUT->eError =
615 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
616 (void **) &psClientFenceUFOSyncPrimBlockInt[i],
617 hClientFenceUFOSyncPrimBlockInt2[i],
618 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
620 if(psRGXKickCDMOUT->eError != PVRSRV_OK)
623 goto RGXKickCDM_exit;
636 for (i=0;i<psRGXKickCDMIN->ui32ClientUpdateCount;i++)
639 /* Look up the address from the handle */
640 psRGXKickCDMOUT->eError =
641 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
642 (void **) &psClientUpdateUFOSyncPrimBlockInt[i],
643 hClientUpdateUFOSyncPrimBlockInt2[i],
644 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
646 if(psRGXKickCDMOUT->eError != PVRSRV_OK)
649 goto RGXKickCDM_exit;
662 for (i=0;i<psRGXKickCDMIN->ui32ServerSyncCount;i++)
665 /* Look up the address from the handle */
666 psRGXKickCDMOUT->eError =
667 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
668 (void **) &psServerSyncsInt[i],
670 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
672 if(psRGXKickCDMOUT->eError != PVRSRV_OK)
675 goto RGXKickCDM_exit;
680 /* Release now we have looked up handles. */
683 psRGXKickCDMOUT->eError =
686 psRGXKickCDMIN->ui32ClientCacheOpSeqNum,
687 psRGXKickCDMIN->ui32ClientFenceCount,
688 psClientFenceUFOSyncPrimBlockInt,
689 ui32ClientFenceOffsetInt,
690 ui32ClientFenceValueInt,
691 psRGXKickCDMIN->ui32ClientUpdateCount,
692 psClientUpdateUFOSyncPrimBlockInt,
693 ui32ClientUpdateOffsetInt,
694 ui32ClientUpdateValueInt,
695 psRGXKickCDMIN->ui32ServerSyncCount,
696 ui32ServerSyncFlagsInt,
698 psRGXKickCDMIN->i32CheckFenceFd,
699 psRGXKickCDMIN->i32UpdateTimelineFd,
700 &psRGXKickCDMOUT->i32UpdateFenceFd,
701 uiUpdateFenceNameInt,
702 psRGXKickCDMIN->ui32CmdSize,
704 psRGXKickCDMIN->ui32PDumpFlags,
705 psRGXKickCDMIN->ui32ExtJobRef);
712 /* Lock over handle lookup cleanup. */
721 /* Unreference the previously looked up handle */
722 if(psComputeContextInt)
724 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
726 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
737 for (i=0;i<psRGXKickCDMIN->ui32ClientFenceCount;i++)
740 /* Unreference the previously looked up handle */
741 if(psClientFenceUFOSyncPrimBlockInt[i])
743 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
744 hClientFenceUFOSyncPrimBlockInt2[i],
745 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
758 for (i=0;i<psRGXKickCDMIN->ui32ClientUpdateCount;i++)
761 /* Unreference the previously looked up handle */
762 if(psClientUpdateUFOSyncPrimBlockInt[i])
764 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
765 hClientUpdateUFOSyncPrimBlockInt2[i],
766 PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
779 for (i=0;i<psRGXKickCDMIN->ui32ServerSyncCount;i++)
782 /* Unreference the previously looked up handle */
783 if(psServerSyncsInt[i])
785 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
787 PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
792 /* Release now we have cleaned up look up handles. */
795 /* Allocated space should be equal to the last updated offset */
796 PVR_ASSERT(ui32BufferSize == ui32NextOffset);
798 #if defined(INTEGRITY_OS)
801 if(!bHaveEnoughSpace && pArrayArgsBuffer)
803 OSFreeMemNoStats(pArrayArgsBuffer);
811 PVRSRVBridgeRGXFlushComputeData(IMG_UINT32 ui32DispatchTableEntry,
812 PVRSRV_BRIDGE_IN_RGXFLUSHCOMPUTEDATA *psRGXFlushComputeDataIN,
813 PVRSRV_BRIDGE_OUT_RGXFLUSHCOMPUTEDATA *psRGXFlushComputeDataOUT,
814 CONNECTION_DATA *psConnection)
816 IMG_HANDLE hComputeContext = psRGXFlushComputeDataIN->hComputeContext;
817 RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
821 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
823 /* Check that device supports the required feature */
824 if ((psDeviceNode->pfnCheckDeviceFeature) &&
825 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
827 psRGXFlushComputeDataOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
829 goto RGXFlushComputeData_exit;
837 /* Lock over handle lookup. */
845 /* Look up the address from the handle */
846 psRGXFlushComputeDataOUT->eError =
847 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
848 (void **) &psComputeContextInt,
850 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
852 if(psRGXFlushComputeDataOUT->eError != PVRSRV_OK)
855 goto RGXFlushComputeData_exit;
858 /* Release now we have looked up handles. */
861 psRGXFlushComputeDataOUT->eError =
862 PVRSRVRGXFlushComputeDataKM(
863 psComputeContextInt);
868 RGXFlushComputeData_exit:
870 /* Lock over handle lookup cleanup. */
879 /* Unreference the previously looked up handle */
880 if(psComputeContextInt)
882 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
884 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
887 /* Release now we have cleaned up look up handles. */
896 PVRSRVBridgeRGXSetComputeContextPriority(IMG_UINT32 ui32DispatchTableEntry,
897 PVRSRV_BRIDGE_IN_RGXSETCOMPUTECONTEXTPRIORITY *psRGXSetComputeContextPriorityIN,
898 PVRSRV_BRIDGE_OUT_RGXSETCOMPUTECONTEXTPRIORITY *psRGXSetComputeContextPriorityOUT,
899 CONNECTION_DATA *psConnection)
901 IMG_HANDLE hComputeContext = psRGXSetComputeContextPriorityIN->hComputeContext;
902 RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
906 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
908 /* Check that device supports the required feature */
909 if ((psDeviceNode->pfnCheckDeviceFeature) &&
910 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
912 psRGXSetComputeContextPriorityOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
914 goto RGXSetComputeContextPriority_exit;
922 /* Lock over handle lookup. */
930 /* Look up the address from the handle */
931 psRGXSetComputeContextPriorityOUT->eError =
932 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
933 (void **) &psComputeContextInt,
935 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
937 if(psRGXSetComputeContextPriorityOUT->eError != PVRSRV_OK)
940 goto RGXSetComputeContextPriority_exit;
943 /* Release now we have looked up handles. */
946 psRGXSetComputeContextPriorityOUT->eError =
947 PVRSRVRGXSetComputeContextPriorityKM(psConnection, OSGetDevData(psConnection),
949 psRGXSetComputeContextPriorityIN->ui32Priority);
954 RGXSetComputeContextPriority_exit:
956 /* Lock over handle lookup cleanup. */
965 /* Unreference the previously looked up handle */
966 if(psComputeContextInt)
968 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
970 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
973 /* Release now we have cleaned up look up handles. */
982 PVRSRVBridgeRGXGetLastComputeContextResetReason(IMG_UINT32 ui32DispatchTableEntry,
983 PVRSRV_BRIDGE_IN_RGXGETLASTCOMPUTECONTEXTRESETREASON *psRGXGetLastComputeContextResetReasonIN,
984 PVRSRV_BRIDGE_OUT_RGXGETLASTCOMPUTECONTEXTRESETREASON *psRGXGetLastComputeContextResetReasonOUT,
985 CONNECTION_DATA *psConnection)
987 IMG_HANDLE hComputeContext = psRGXGetLastComputeContextResetReasonIN->hComputeContext;
988 RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
992 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
994 /* Check that device supports the required feature */
995 if ((psDeviceNode->pfnCheckDeviceFeature) &&
996 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
998 psRGXGetLastComputeContextResetReasonOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1000 goto RGXGetLastComputeContextResetReason_exit;
1008 /* Lock over handle lookup. */
1016 /* Look up the address from the handle */
1017 psRGXGetLastComputeContextResetReasonOUT->eError =
1018 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1019 (void **) &psComputeContextInt,
1021 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
1023 if(psRGXGetLastComputeContextResetReasonOUT->eError != PVRSRV_OK)
1026 goto RGXGetLastComputeContextResetReason_exit;
1029 /* Release now we have looked up handles. */
1032 psRGXGetLastComputeContextResetReasonOUT->eError =
1033 PVRSRVRGXGetLastComputeContextResetReasonKM(
1034 psComputeContextInt,
1035 &psRGXGetLastComputeContextResetReasonOUT->ui32LastResetReason,
1036 &psRGXGetLastComputeContextResetReasonOUT->ui32LastResetJobRef);
1041 RGXGetLastComputeContextResetReason_exit:
1043 /* Lock over handle lookup cleanup. */
1052 /* Unreference the previously looked up handle */
1053 if(psComputeContextInt)
1055 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1057 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
1060 /* Release now we have cleaned up look up handles. */
1069 PVRSRVBridgeRGXNotifyComputeWriteOffsetUpdate(IMG_UINT32 ui32DispatchTableEntry,
1070 PVRSRV_BRIDGE_IN_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE *psRGXNotifyComputeWriteOffsetUpdateIN,
1071 PVRSRV_BRIDGE_OUT_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE *psRGXNotifyComputeWriteOffsetUpdateOUT,
1072 CONNECTION_DATA *psConnection)
1074 IMG_HANDLE hComputeContext = psRGXNotifyComputeWriteOffsetUpdateIN->hComputeContext;
1075 RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
1079 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
1081 /* Check that device supports the required feature */
1082 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1083 !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
1085 psRGXNotifyComputeWriteOffsetUpdateOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1087 goto RGXNotifyComputeWriteOffsetUpdate_exit;
1095 /* Lock over handle lookup. */
1103 /* Look up the address from the handle */
1104 psRGXNotifyComputeWriteOffsetUpdateOUT->eError =
1105 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1106 (void **) &psComputeContextInt,
1108 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
1110 if(psRGXNotifyComputeWriteOffsetUpdateOUT->eError != PVRSRV_OK)
1113 goto RGXNotifyComputeWriteOffsetUpdate_exit;
1116 /* Release now we have looked up handles. */
1119 psRGXNotifyComputeWriteOffsetUpdateOUT->eError =
1120 PVRSRVRGXNotifyComputeWriteOffsetUpdateKM(
1121 psComputeContextInt);
1126 RGXNotifyComputeWriteOffsetUpdate_exit:
1128 /* Lock over handle lookup cleanup. */
1137 /* Unreference the previously looked up handle */
1138 if(psComputeContextInt)
1140 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1142 PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
1145 /* Release now we have cleaned up look up handles. */
1155 /* ***************************************************************************
1156 * Server bridge dispatch related glue
1159 static IMG_BOOL bUseLock = IMG_TRUE;
1161 PVRSRV_ERROR InitRGXCMPBridge(void);
1162 PVRSRV_ERROR DeinitRGXCMPBridge(void);
1165 * Register all RGXCMP functions with services
1167 PVRSRV_ERROR InitRGXCMPBridge(void)
1170 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXCREATECOMPUTECONTEXT, PVRSRVBridgeRGXCreateComputeContext,
1173 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXDESTROYCOMPUTECONTEXT, PVRSRVBridgeRGXDestroyComputeContext,
1176 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXKICKCDM, PVRSRVBridgeRGXKickCDM,
1179 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXFLUSHCOMPUTEDATA, PVRSRVBridgeRGXFlushComputeData,
1182 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXSETCOMPUTECONTEXTPRIORITY, PVRSRVBridgeRGXSetComputeContextPriority,
1185 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXGETLASTCOMPUTECONTEXTRESETREASON, PVRSRVBridgeRGXGetLastComputeContextResetReason,
1188 SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE, PVRSRVBridgeRGXNotifyComputeWriteOffsetUpdate,
1196 * Unregister all rgxcmp functions with services
1198 PVRSRV_ERROR DeinitRGXCMPBridge(void)