RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / generated / rgxcmp_bridge / server_rgxcmp_bridge.c
1 /*************************************************************************/ /*!
2 @File
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
7
8 The contents of this file are subject to the MIT license as set out below.
9
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:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
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.
23
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.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
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 */ /**************************************************************************/
43
44 #include <stddef.h>
45 #include <asm/uaccess.h>
46
47 #include "img_defs.h"
48
49 #include "rgxcompute.h"
50
51
52 #include "common_rgxcmp_bridge.h"
53
54 #include "allocmem.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
59 #include "srvcore.h"
60 #include "handle.h"
61
62 #include <linux/slab.h>
63
64
65 #include "rgx_bvnc_defs_km.h"
66
67
68
69
70 /* ***************************************************************************
71  * Server-side bridge entry points
72  */
73  
74 static IMG_INT
75 PVRSRVBridgeRGXCreateComputeContext(IMG_UINT32 ui32DispatchTableEntry,
76                                           PVRSRV_BRIDGE_IN_RGXCREATECOMPUTECONTEXT *psRGXCreateComputeContextIN,
77                                           PVRSRV_BRIDGE_OUT_RGXCREATECOMPUTECONTEXT *psRGXCreateComputeContextOUT,
78                                          CONNECTION_DATA *psConnection)
79 {
80         IMG_BYTE *psFrameworkCmdInt = NULL;
81         IMG_HANDLE hPrivData = psRGXCreateComputeContextIN->hPrivData;
82         IMG_HANDLE hPrivDataInt = NULL;
83         RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
84
85         IMG_UINT32 ui32NextOffset = 0;
86         IMG_BYTE   *pArrayArgsBuffer = NULL;
87 #if !defined(INTEGRITY_OS)
88         IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
89 #endif
90
91         IMG_UINT32 ui32BufferSize = 
92                         (psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) +
93                         0;
94
95         {
96                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
97
98                 /* Check that device supports the required feature */
99                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
100                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
101                 {
102                         psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
103
104                         goto RGXCreateComputeContext_exit;
105                 }
106         }
107
108
109
110
111         if (ui32BufferSize != 0)
112         {
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;
118
119                 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
120                 if (bHaveEnoughSpace)
121                 {
122                         IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXCreateComputeContextIN;
123
124                         pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset];           }
125                 else
126 #endif
127                 {
128                         pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
129
130                         if(!pArrayArgsBuffer)
131                         {
132                                 psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
133                                 goto RGXCreateComputeContext_exit;
134                         }
135                 }
136         }
137
138         if (psRGXCreateComputeContextIN->ui32FrameworkCmdize != 0)
139         {
140                 psFrameworkCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
141                 ui32NextOffset += psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE);
142         }
143
144                         /* Copy the data over */
145                         if (psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE) > 0)
146                         {
147                                 if ( OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXCreateComputeContextIN->psFrameworkCmd, psRGXCreateComputeContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) != PVRSRV_OK )
148                                 {
149                                         psRGXCreateComputeContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
150
151                                         goto RGXCreateComputeContext_exit;
152                                 }
153                         }
154
155         /* Lock over handle lookup. */
156         LockHandle();
157
158
159
160
161
162                                 {
163                                         /* Look up the address from the handle */
164                                         psRGXCreateComputeContextOUT->eError =
165                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
166                                                                                         (void **) &hPrivDataInt,
167                                                                                         hPrivData,
168                                                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
169                                                                                         IMG_TRUE);
170                                         if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
171                                         {
172                                                 UnlockHandle();
173                                                 goto RGXCreateComputeContext_exit;
174                                         }
175                                 }
176         /* Release now we have looked up handles. */
177         UnlockHandle();
178
179         psRGXCreateComputeContextOUT->eError =
180                 PVRSRVRGXCreateComputeContextKM(psConnection, OSGetDevData(psConnection),
181                                         psRGXCreateComputeContextIN->ui32Priority,
182                                         psRGXCreateComputeContextIN->sMCUFenceAddr,
183                                         psRGXCreateComputeContextIN->ui32FrameworkCmdize,
184                                         psFrameworkCmdInt,
185                                         hPrivDataInt,
186                                         psRGXCreateComputeContextIN->sResumeSignalAddr,
187                                         &psComputeContextInt);
188         /* Exit early if bridged call fails */
189         if(psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
190         {
191                 goto RGXCreateComputeContext_exit;
192         }
193
194         /* Lock over handle creation. */
195         LockHandle();
196
197
198
199
200
201         psRGXCreateComputeContextOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
202
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)
209         {
210                 UnlockHandle();
211                 goto RGXCreateComputeContext_exit;
212         }
213
214         /* Release now we have created handles. */
215         UnlockHandle();
216
217
218
219 RGXCreateComputeContext_exit:
220
221         /* Lock over handle lookup cleanup. */
222         LockHandle();
223
224
225
226
227
228
229                                 {
230                                         /* Unreference the previously looked up handle */
231                                                 if(hPrivDataInt)
232                                                 {
233                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
234                                                                                         hPrivData,
235                                                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
236                                                 }
237                                 }
238         /* Release now we have cleaned up look up handles. */
239         UnlockHandle();
240
241         if (psRGXCreateComputeContextOUT->eError != PVRSRV_OK)
242         {
243                 if (psComputeContextInt)
244                 {
245                         PVRSRVRGXDestroyComputeContextKM(psComputeContextInt);
246                 }
247         }
248
249         /* Allocated space should be equal to the last updated offset */
250         PVR_ASSERT(ui32BufferSize == ui32NextOffset);
251
252 #if defined(INTEGRITY_OS)
253         if(pArrayArgsBuffer)
254 #else
255         if(!bHaveEnoughSpace && pArrayArgsBuffer)
256 #endif
257                 OSFreeMemNoStats(pArrayArgsBuffer);
258
259
260         return 0;
261 }
262
263
264 static IMG_INT
265 PVRSRVBridgeRGXDestroyComputeContext(IMG_UINT32 ui32DispatchTableEntry,
266                                           PVRSRV_BRIDGE_IN_RGXDESTROYCOMPUTECONTEXT *psRGXDestroyComputeContextIN,
267                                           PVRSRV_BRIDGE_OUT_RGXDESTROYCOMPUTECONTEXT *psRGXDestroyComputeContextOUT,
268                                          CONNECTION_DATA *psConnection)
269 {
270
271
272         {
273                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
274
275                 /* Check that device supports the required feature */
276                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
277                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
278                 {
279                         psRGXDestroyComputeContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
280
281                         goto RGXDestroyComputeContext_exit;
282                 }
283         }
284
285
286
287
288
289
290
291         /* Lock over handle destruction. */
292         LockHandle();
293
294
295
296
297
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))
304         {
305                 PVR_DPF((PVR_DBG_ERROR,
306                         "PVRSRVBridgeRGXDestroyComputeContext: %s",
307                         PVRSRVGetErrorStringKM(psRGXDestroyComputeContextOUT->eError)));
308                 PVR_ASSERT(0);
309                 UnlockHandle();
310                 goto RGXDestroyComputeContext_exit;
311         }
312
313         /* Release now we have destroyed handles. */
314         UnlockHandle();
315
316
317
318 RGXDestroyComputeContext_exit:
319
320
321
322
323         return 0;
324 }
325
326
327 static IMG_INT
328 PVRSRVBridgeRGXKickCDM(IMG_UINT32 ui32DispatchTableEntry,
329                                           PVRSRV_BRIDGE_IN_RGXKICKCDM *psRGXKickCDMIN,
330                                           PVRSRV_BRIDGE_OUT_RGXKICKCDM *psRGXKickCDMOUT,
331                                          CONNECTION_DATA *psConnection)
332 {
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;
348
349         IMG_UINT32 ui32NextOffset = 0;
350         IMG_BYTE   *pArrayArgsBuffer = NULL;
351 #if !defined(INTEGRITY_OS)
352         IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
353 #endif
354
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)) +
369                         0;
370
371         {
372                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
373
374                 /* Check that device supports the required feature */
375                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
376                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
377                 {
378                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
379
380                         goto RGXKickCDM_exit;
381                 }
382         }
383
384
385
386
387         if (ui32BufferSize != 0)
388         {
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;
394
395                 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
396                 if (bHaveEnoughSpace)
397                 {
398                         IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXKickCDMIN;
399
400                         pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset];           }
401                 else
402 #endif
403                 {
404                         pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
405
406                         if(!pArrayArgsBuffer)
407                         {
408                                 psRGXKickCDMOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
409                                 goto RGXKickCDM_exit;
410                         }
411                 }
412         }
413
414         if (psRGXKickCDMIN->ui32ClientFenceCount != 0)
415         {
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);
420         }
421
422                         /* Copy the data over */
423                         if (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE) > 0)
424                         {
425                                 if ( OSCopyFromUser(NULL, hClientFenceUFOSyncPrimBlockInt2, psRGXKickCDMIN->phClientFenceUFOSyncPrimBlock, psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
426                                 {
427                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
428
429                                         goto RGXKickCDM_exit;
430                                 }
431                         }
432         if (psRGXKickCDMIN->ui32ClientFenceCount != 0)
433         {
434                 ui32ClientFenceOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
435                 ui32NextOffset += psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
436         }
437
438                         /* Copy the data over */
439                         if (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
440                         {
441                                 if ( OSCopyFromUser(NULL, ui32ClientFenceOffsetInt, psRGXKickCDMIN->pui32ClientFenceOffset, psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
442                                 {
443                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
444
445                                         goto RGXKickCDM_exit;
446                                 }
447                         }
448         if (psRGXKickCDMIN->ui32ClientFenceCount != 0)
449         {
450                 ui32ClientFenceValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
451                 ui32NextOffset += psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
452         }
453
454                         /* Copy the data over */
455                         if (psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
456                         {
457                                 if ( OSCopyFromUser(NULL, ui32ClientFenceValueInt, psRGXKickCDMIN->pui32ClientFenceValue, psRGXKickCDMIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
458                                 {
459                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
460
461                                         goto RGXKickCDM_exit;
462                                 }
463                         }
464         if (psRGXKickCDMIN->ui32ClientUpdateCount != 0)
465         {
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);
470         }
471
472                         /* Copy the data over */
473                         if (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE) > 0)
474                         {
475                                 if ( OSCopyFromUser(NULL, hClientUpdateUFOSyncPrimBlockInt2, psRGXKickCDMIN->phClientUpdateUFOSyncPrimBlock, psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
476                                 {
477                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
478
479                                         goto RGXKickCDM_exit;
480                                 }
481                         }
482         if (psRGXKickCDMIN->ui32ClientUpdateCount != 0)
483         {
484                 ui32ClientUpdateOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
485                 ui32NextOffset += psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
486         }
487
488                         /* Copy the data over */
489                         if (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
490                         {
491                                 if ( OSCopyFromUser(NULL, ui32ClientUpdateOffsetInt, psRGXKickCDMIN->pui32ClientUpdateOffset, psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
492                                 {
493                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
494
495                                         goto RGXKickCDM_exit;
496                                 }
497                         }
498         if (psRGXKickCDMIN->ui32ClientUpdateCount != 0)
499         {
500                 ui32ClientUpdateValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
501                 ui32NextOffset += psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
502         }
503
504                         /* Copy the data over */
505                         if (psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
506                         {
507                                 if ( OSCopyFromUser(NULL, ui32ClientUpdateValueInt, psRGXKickCDMIN->pui32ClientUpdateValue, psRGXKickCDMIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
508                                 {
509                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
510
511                                         goto RGXKickCDM_exit;
512                                 }
513                         }
514         if (psRGXKickCDMIN->ui32ServerSyncCount != 0)
515         {
516                 ui32ServerSyncFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
517                 ui32NextOffset += psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32);
518         }
519
520                         /* Copy the data over */
521                         if (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32) > 0)
522                         {
523                                 if ( OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXKickCDMIN->pui32ServerSyncFlags, psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
524                                 {
525                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
526
527                                         goto RGXKickCDM_exit;
528                                 }
529                         }
530         if (psRGXKickCDMIN->ui32ServerSyncCount != 0)
531         {
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);
536         }
537
538                         /* Copy the data over */
539                         if (psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE) > 0)
540                         {
541                                 if ( OSCopyFromUser(NULL, hServerSyncsInt2, psRGXKickCDMIN->phServerSyncs, psRGXKickCDMIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
542                                 {
543                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
544
545                                         goto RGXKickCDM_exit;
546                                 }
547                         }
548         
549         {
550                 uiUpdateFenceNameInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
551                 ui32NextOffset += 32 * sizeof(IMG_CHAR);
552         }
553
554                         /* Copy the data over */
555                         if (32 * sizeof(IMG_CHAR) > 0)
556                         {
557                                 if ( OSCopyFromUser(NULL, uiUpdateFenceNameInt, psRGXKickCDMIN->puiUpdateFenceName, 32 * sizeof(IMG_CHAR)) != PVRSRV_OK )
558                                 {
559                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
560
561                                         goto RGXKickCDM_exit;
562                                 }
563                         }
564         if (psRGXKickCDMIN->ui32CmdSize != 0)
565         {
566                 psDMCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
567                 ui32NextOffset += psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE);
568         }
569
570                         /* Copy the data over */
571                         if (psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE) > 0)
572                         {
573                                 if ( OSCopyFromUser(NULL, psDMCmdInt, psRGXKickCDMIN->psDMCmd, psRGXKickCDMIN->ui32CmdSize * sizeof(IMG_BYTE)) != PVRSRV_OK )
574                                 {
575                                         psRGXKickCDMOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
576
577                                         goto RGXKickCDM_exit;
578                                 }
579                         }
580
581         /* Lock over handle lookup. */
582         LockHandle();
583
584
585
586
587
588                                 {
589                                         /* Look up the address from the handle */
590                                         psRGXKickCDMOUT->eError =
591                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
592                                                                                         (void **) &psComputeContextInt,
593                                                                                         hComputeContext,
594                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
595                                                                                         IMG_TRUE);
596                                         if(psRGXKickCDMOUT->eError != PVRSRV_OK)
597                                         {
598                                                 UnlockHandle();
599                                                 goto RGXKickCDM_exit;
600                                         }
601                                 }
602
603
604
605
606
607         {
608                 IMG_UINT32 i;
609
610                 for (i=0;i<psRGXKickCDMIN->ui32ClientFenceCount;i++)
611                 {
612                                 {
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,
619                                                                                         IMG_TRUE);
620                                         if(psRGXKickCDMOUT->eError != PVRSRV_OK)
621                                         {
622                                                 UnlockHandle();
623                                                 goto RGXKickCDM_exit;
624                                         }
625                                 }
626                 }
627         }
628
629
630
631
632
633         {
634                 IMG_UINT32 i;
635
636                 for (i=0;i<psRGXKickCDMIN->ui32ClientUpdateCount;i++)
637                 {
638                                 {
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,
645                                                                                         IMG_TRUE);
646                                         if(psRGXKickCDMOUT->eError != PVRSRV_OK)
647                                         {
648                                                 UnlockHandle();
649                                                 goto RGXKickCDM_exit;
650                                         }
651                                 }
652                 }
653         }
654
655
656
657
658
659         {
660                 IMG_UINT32 i;
661
662                 for (i=0;i<psRGXKickCDMIN->ui32ServerSyncCount;i++)
663                 {
664                                 {
665                                         /* Look up the address from the handle */
666                                         psRGXKickCDMOUT->eError =
667                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
668                                                                                         (void **) &psServerSyncsInt[i],
669                                                                                         hServerSyncsInt2[i],
670                                                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
671                                                                                         IMG_TRUE);
672                                         if(psRGXKickCDMOUT->eError != PVRSRV_OK)
673                                         {
674                                                 UnlockHandle();
675                                                 goto RGXKickCDM_exit;
676                                         }
677                                 }
678                 }
679         }
680         /* Release now we have looked up handles. */
681         UnlockHandle();
682
683         psRGXKickCDMOUT->eError =
684                 PVRSRVRGXKickCDMKM(
685                                         psComputeContextInt,
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,
697                                         psServerSyncsInt,
698                                         psRGXKickCDMIN->i32CheckFenceFd,
699                                         psRGXKickCDMIN->i32UpdateTimelineFd,
700                                         &psRGXKickCDMOUT->i32UpdateFenceFd,
701                                         uiUpdateFenceNameInt,
702                                         psRGXKickCDMIN->ui32CmdSize,
703                                         psDMCmdInt,
704                                         psRGXKickCDMIN->ui32PDumpFlags,
705                                         psRGXKickCDMIN->ui32ExtJobRef);
706
707
708
709
710 RGXKickCDM_exit:
711
712         /* Lock over handle lookup cleanup. */
713         LockHandle();
714
715
716
717
718
719
720                                 {
721                                         /* Unreference the previously looked up handle */
722                                                 if(psComputeContextInt)
723                                                 {
724                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
725                                                                                         hComputeContext,
726                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
727                                                 }
728                                 }
729
730
731
732
733
734         {
735                 IMG_UINT32 i;
736
737                 for (i=0;i<psRGXKickCDMIN->ui32ClientFenceCount;i++)
738                 {
739                                 {
740                                         /* Unreference the previously looked up handle */
741                                                 if(psClientFenceUFOSyncPrimBlockInt[i])
742                                                 {
743                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
744                                                                                         hClientFenceUFOSyncPrimBlockInt2[i],
745                                                                                         PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
746                                                 }
747                                 }
748                 }
749         }
750
751
752
753
754
755         {
756                 IMG_UINT32 i;
757
758                 for (i=0;i<psRGXKickCDMIN->ui32ClientUpdateCount;i++)
759                 {
760                                 {
761                                         /* Unreference the previously looked up handle */
762                                                 if(psClientUpdateUFOSyncPrimBlockInt[i])
763                                                 {
764                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
765                                                                                         hClientUpdateUFOSyncPrimBlockInt2[i],
766                                                                                         PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
767                                                 }
768                                 }
769                 }
770         }
771
772
773
774
775
776         {
777                 IMG_UINT32 i;
778
779                 for (i=0;i<psRGXKickCDMIN->ui32ServerSyncCount;i++)
780                 {
781                                 {
782                                         /* Unreference the previously looked up handle */
783                                                 if(psServerSyncsInt[i])
784                                                 {
785                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
786                                                                                         hServerSyncsInt2[i],
787                                                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
788                                                 }
789                                 }
790                 }
791         }
792         /* Release now we have cleaned up look up handles. */
793         UnlockHandle();
794
795         /* Allocated space should be equal to the last updated offset */
796         PVR_ASSERT(ui32BufferSize == ui32NextOffset);
797
798 #if defined(INTEGRITY_OS)
799         if(pArrayArgsBuffer)
800 #else
801         if(!bHaveEnoughSpace && pArrayArgsBuffer)
802 #endif
803                 OSFreeMemNoStats(pArrayArgsBuffer);
804
805
806         return 0;
807 }
808
809
810 static IMG_INT
811 PVRSRVBridgeRGXFlushComputeData(IMG_UINT32 ui32DispatchTableEntry,
812                                           PVRSRV_BRIDGE_IN_RGXFLUSHCOMPUTEDATA *psRGXFlushComputeDataIN,
813                                           PVRSRV_BRIDGE_OUT_RGXFLUSHCOMPUTEDATA *psRGXFlushComputeDataOUT,
814                                          CONNECTION_DATA *psConnection)
815 {
816         IMG_HANDLE hComputeContext = psRGXFlushComputeDataIN->hComputeContext;
817         RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
818
819
820         {
821                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
822
823                 /* Check that device supports the required feature */
824                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
825                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
826                 {
827                         psRGXFlushComputeDataOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
828
829                         goto RGXFlushComputeData_exit;
830                 }
831         }
832
833
834
835
836
837         /* Lock over handle lookup. */
838         LockHandle();
839
840
841
842
843
844                                 {
845                                         /* Look up the address from the handle */
846                                         psRGXFlushComputeDataOUT->eError =
847                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
848                                                                                         (void **) &psComputeContextInt,
849                                                                                         hComputeContext,
850                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
851                                                                                         IMG_TRUE);
852                                         if(psRGXFlushComputeDataOUT->eError != PVRSRV_OK)
853                                         {
854                                                 UnlockHandle();
855                                                 goto RGXFlushComputeData_exit;
856                                         }
857                                 }
858         /* Release now we have looked up handles. */
859         UnlockHandle();
860
861         psRGXFlushComputeDataOUT->eError =
862                 PVRSRVRGXFlushComputeDataKM(
863                                         psComputeContextInt);
864
865
866
867
868 RGXFlushComputeData_exit:
869
870         /* Lock over handle lookup cleanup. */
871         LockHandle();
872
873
874
875
876
877
878                                 {
879                                         /* Unreference the previously looked up handle */
880                                                 if(psComputeContextInt)
881                                                 {
882                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
883                                                                                         hComputeContext,
884                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
885                                                 }
886                                 }
887         /* Release now we have cleaned up look up handles. */
888         UnlockHandle();
889
890
891         return 0;
892 }
893
894
895 static IMG_INT
896 PVRSRVBridgeRGXSetComputeContextPriority(IMG_UINT32 ui32DispatchTableEntry,
897                                           PVRSRV_BRIDGE_IN_RGXSETCOMPUTECONTEXTPRIORITY *psRGXSetComputeContextPriorityIN,
898                                           PVRSRV_BRIDGE_OUT_RGXSETCOMPUTECONTEXTPRIORITY *psRGXSetComputeContextPriorityOUT,
899                                          CONNECTION_DATA *psConnection)
900 {
901         IMG_HANDLE hComputeContext = psRGXSetComputeContextPriorityIN->hComputeContext;
902         RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
903
904
905         {
906                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
907
908                 /* Check that device supports the required feature */
909                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
910                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
911                 {
912                         psRGXSetComputeContextPriorityOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
913
914                         goto RGXSetComputeContextPriority_exit;
915                 }
916         }
917
918
919
920
921
922         /* Lock over handle lookup. */
923         LockHandle();
924
925
926
927
928
929                                 {
930                                         /* Look up the address from the handle */
931                                         psRGXSetComputeContextPriorityOUT->eError =
932                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
933                                                                                         (void **) &psComputeContextInt,
934                                                                                         hComputeContext,
935                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
936                                                                                         IMG_TRUE);
937                                         if(psRGXSetComputeContextPriorityOUT->eError != PVRSRV_OK)
938                                         {
939                                                 UnlockHandle();
940                                                 goto RGXSetComputeContextPriority_exit;
941                                         }
942                                 }
943         /* Release now we have looked up handles. */
944         UnlockHandle();
945
946         psRGXSetComputeContextPriorityOUT->eError =
947                 PVRSRVRGXSetComputeContextPriorityKM(psConnection, OSGetDevData(psConnection),
948                                         psComputeContextInt,
949                                         psRGXSetComputeContextPriorityIN->ui32Priority);
950
951
952
953
954 RGXSetComputeContextPriority_exit:
955
956         /* Lock over handle lookup cleanup. */
957         LockHandle();
958
959
960
961
962
963
964                                 {
965                                         /* Unreference the previously looked up handle */
966                                                 if(psComputeContextInt)
967                                                 {
968                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
969                                                                                         hComputeContext,
970                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
971                                                 }
972                                 }
973         /* Release now we have cleaned up look up handles. */
974         UnlockHandle();
975
976
977         return 0;
978 }
979
980
981 static IMG_INT
982 PVRSRVBridgeRGXGetLastComputeContextResetReason(IMG_UINT32 ui32DispatchTableEntry,
983                                           PVRSRV_BRIDGE_IN_RGXGETLASTCOMPUTECONTEXTRESETREASON *psRGXGetLastComputeContextResetReasonIN,
984                                           PVRSRV_BRIDGE_OUT_RGXGETLASTCOMPUTECONTEXTRESETREASON *psRGXGetLastComputeContextResetReasonOUT,
985                                          CONNECTION_DATA *psConnection)
986 {
987         IMG_HANDLE hComputeContext = psRGXGetLastComputeContextResetReasonIN->hComputeContext;
988         RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
989
990
991         {
992                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
993
994                 /* Check that device supports the required feature */
995                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
996                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
997                 {
998                         psRGXGetLastComputeContextResetReasonOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
999
1000                         goto RGXGetLastComputeContextResetReason_exit;
1001                 }
1002         }
1003
1004
1005
1006
1007
1008         /* Lock over handle lookup. */
1009         LockHandle();
1010
1011
1012
1013
1014
1015                                 {
1016                                         /* Look up the address from the handle */
1017                                         psRGXGetLastComputeContextResetReasonOUT->eError =
1018                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1019                                                                                         (void **) &psComputeContextInt,
1020                                                                                         hComputeContext,
1021                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
1022                                                                                         IMG_TRUE);
1023                                         if(psRGXGetLastComputeContextResetReasonOUT->eError != PVRSRV_OK)
1024                                         {
1025                                                 UnlockHandle();
1026                                                 goto RGXGetLastComputeContextResetReason_exit;
1027                                         }
1028                                 }
1029         /* Release now we have looked up handles. */
1030         UnlockHandle();
1031
1032         psRGXGetLastComputeContextResetReasonOUT->eError =
1033                 PVRSRVRGXGetLastComputeContextResetReasonKM(
1034                                         psComputeContextInt,
1035                                         &psRGXGetLastComputeContextResetReasonOUT->ui32LastResetReason,
1036                                         &psRGXGetLastComputeContextResetReasonOUT->ui32LastResetJobRef);
1037
1038
1039
1040
1041 RGXGetLastComputeContextResetReason_exit:
1042
1043         /* Lock over handle lookup cleanup. */
1044         LockHandle();
1045
1046
1047
1048
1049
1050
1051                                 {
1052                                         /* Unreference the previously looked up handle */
1053                                                 if(psComputeContextInt)
1054                                                 {
1055                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1056                                                                                         hComputeContext,
1057                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
1058                                                 }
1059                                 }
1060         /* Release now we have cleaned up look up handles. */
1061         UnlockHandle();
1062
1063
1064         return 0;
1065 }
1066
1067
1068 static IMG_INT
1069 PVRSRVBridgeRGXNotifyComputeWriteOffsetUpdate(IMG_UINT32 ui32DispatchTableEntry,
1070                                           PVRSRV_BRIDGE_IN_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE *psRGXNotifyComputeWriteOffsetUpdateIN,
1071                                           PVRSRV_BRIDGE_OUT_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE *psRGXNotifyComputeWriteOffsetUpdateOUT,
1072                                          CONNECTION_DATA *psConnection)
1073 {
1074         IMG_HANDLE hComputeContext = psRGXNotifyComputeWriteOffsetUpdateIN->hComputeContext;
1075         RGX_SERVER_COMPUTE_CONTEXT * psComputeContextInt = NULL;
1076
1077
1078         {
1079                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
1080
1081                 /* Check that device supports the required feature */
1082                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1083                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_COMPUTE_BIT_MASK))
1084                 {
1085                         psRGXNotifyComputeWriteOffsetUpdateOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1086
1087                         goto RGXNotifyComputeWriteOffsetUpdate_exit;
1088                 }
1089         }
1090
1091
1092
1093
1094
1095         /* Lock over handle lookup. */
1096         LockHandle();
1097
1098
1099
1100
1101
1102                                 {
1103                                         /* Look up the address from the handle */
1104                                         psRGXNotifyComputeWriteOffsetUpdateOUT->eError =
1105                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1106                                                                                         (void **) &psComputeContextInt,
1107                                                                                         hComputeContext,
1108                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT,
1109                                                                                         IMG_TRUE);
1110                                         if(psRGXNotifyComputeWriteOffsetUpdateOUT->eError != PVRSRV_OK)
1111                                         {
1112                                                 UnlockHandle();
1113                                                 goto RGXNotifyComputeWriteOffsetUpdate_exit;
1114                                         }
1115                                 }
1116         /* Release now we have looked up handles. */
1117         UnlockHandle();
1118
1119         psRGXNotifyComputeWriteOffsetUpdateOUT->eError =
1120                 PVRSRVRGXNotifyComputeWriteOffsetUpdateKM(
1121                                         psComputeContextInt);
1122
1123
1124
1125
1126 RGXNotifyComputeWriteOffsetUpdate_exit:
1127
1128         /* Lock over handle lookup cleanup. */
1129         LockHandle();
1130
1131
1132
1133
1134
1135
1136                                 {
1137                                         /* Unreference the previously looked up handle */
1138                                                 if(psComputeContextInt)
1139                                                 {
1140                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1141                                                                                         hComputeContext,
1142                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_COMPUTE_CONTEXT);
1143                                                 }
1144                                 }
1145         /* Release now we have cleaned up look up handles. */
1146         UnlockHandle();
1147
1148
1149         return 0;
1150 }
1151
1152
1153
1154
1155 /* *************************************************************************** 
1156  * Server bridge dispatch related glue 
1157  */
1158
1159 static IMG_BOOL bUseLock = IMG_TRUE;
1160
1161 PVRSRV_ERROR InitRGXCMPBridge(void);
1162 PVRSRV_ERROR DeinitRGXCMPBridge(void);
1163
1164 /*
1165  * Register all RGXCMP functions with services
1166  */
1167 PVRSRV_ERROR InitRGXCMPBridge(void)
1168 {
1169
1170         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXCREATECOMPUTECONTEXT, PVRSRVBridgeRGXCreateComputeContext,
1171                                         NULL, bUseLock);
1172
1173         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXDESTROYCOMPUTECONTEXT, PVRSRVBridgeRGXDestroyComputeContext,
1174                                         NULL, bUseLock);
1175
1176         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXKICKCDM, PVRSRVBridgeRGXKickCDM,
1177                                         NULL, bUseLock);
1178
1179         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXFLUSHCOMPUTEDATA, PVRSRVBridgeRGXFlushComputeData,
1180                                         NULL, bUseLock);
1181
1182         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXSETCOMPUTECONTEXTPRIORITY, PVRSRVBridgeRGXSetComputeContextPriority,
1183                                         NULL, bUseLock);
1184
1185         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXGETLASTCOMPUTECONTEXTRESETREASON, PVRSRVBridgeRGXGetLastComputeContextResetReason,
1186                                         NULL, bUseLock);
1187
1188         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXCMP, PVRSRV_BRIDGE_RGXCMP_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE, PVRSRVBridgeRGXNotifyComputeWriteOffsetUpdate,
1189                                         NULL, bUseLock);
1190
1191
1192         return PVRSRV_OK;
1193 }
1194
1195 /*
1196  * Unregister all rgxcmp functions with services
1197  */
1198 PVRSRV_ERROR DeinitRGXCMPBridge(void)
1199 {
1200         return PVRSRV_OK;
1201 }