RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / generated / rgxtq2_bridge / server_rgxtq2_bridge.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          Server bridge for rgxtq2
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the server side of the bridge for rgxtq2
6 @License        Dual MIT/GPLv2
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 "rgxtdmtransfer.h"
50
51
52 #include "common_rgxtq2_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 PVRSRVBridgeRGXTDMCreateTransferContext(IMG_UINT32 ui32DispatchTableEntry,
76                                           PVRSRV_BRIDGE_IN_RGXTDMCREATETRANSFERCONTEXT *psRGXTDMCreateTransferContextIN,
77                                           PVRSRV_BRIDGE_OUT_RGXTDMCREATETRANSFERCONTEXT *psRGXTDMCreateTransferContextOUT,
78                                          CONNECTION_DATA *psConnection)
79 {
80         IMG_BYTE *psFrameworkCmdInt = NULL;
81         IMG_HANDLE hPrivData = psRGXTDMCreateTransferContextIN->hPrivData;
82         IMG_HANDLE hPrivDataInt = NULL;
83         RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = 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                         (psRGXTDMCreateTransferContextIN->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_FASTRENDER_DM_BIT_MASK))
101                 {
102                         psRGXTDMCreateTransferContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
103
104                         goto RGXTDMCreateTransferContext_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(*psRGXTDMCreateTransferContextIN), 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 *)psRGXTDMCreateTransferContextIN;
123
124                         pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset];           }
125                 else
126 #endif
127                 {
128                         pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
129
130                         if(!pArrayArgsBuffer)
131                         {
132                                 psRGXTDMCreateTransferContextOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
133                                 goto RGXTDMCreateTransferContext_exit;
134                         }
135                 }
136         }
137
138         if (psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize != 0)
139         {
140                 psFrameworkCmdInt = (IMG_BYTE*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
141                 ui32NextOffset += psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE);
142         }
143
144                         /* Copy the data over */
145                         if (psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE) > 0)
146                         {
147                                 if ( OSCopyFromUser(NULL, psFrameworkCmdInt, psRGXTDMCreateTransferContextIN->psFrameworkCmd, psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize * sizeof(IMG_BYTE)) != PVRSRV_OK )
148                                 {
149                                         psRGXTDMCreateTransferContextOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
150
151                                         goto RGXTDMCreateTransferContext_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                                         psRGXTDMCreateTransferContextOUT->eError =
165                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
166                                                                                         (void **) &hPrivDataInt,
167                                                                                         hPrivData,
168                                                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
169                                                                                         IMG_TRUE);
170                                         if(psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
171                                         {
172                                                 UnlockHandle();
173                                                 goto RGXTDMCreateTransferContext_exit;
174                                         }
175                                 }
176         /* Release now we have looked up handles. */
177         UnlockHandle();
178
179         psRGXTDMCreateTransferContextOUT->eError =
180                 PVRSRVRGXTDMCreateTransferContextKM(psConnection, OSGetDevData(psConnection),
181                                         psRGXTDMCreateTransferContextIN->ui32Priority,
182                                         psRGXTDMCreateTransferContextIN->sMCUFenceAddr,
183                                         psRGXTDMCreateTransferContextIN->ui32FrameworkCmdize,
184                                         psFrameworkCmdInt,
185                                         hPrivDataInt,
186                                         &psTransferContextInt);
187         /* Exit early if bridged call fails */
188         if(psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
189         {
190                 goto RGXTDMCreateTransferContext_exit;
191         }
192
193         /* Lock over handle creation. */
194         LockHandle();
195
196
197
198
199
200         psRGXTDMCreateTransferContextOUT->eError = PVRSRVAllocHandleUnlocked(psConnection->psHandleBase,
201
202                                                         &psRGXTDMCreateTransferContextOUT->hTransferContext,
203                                                         (void *) psTransferContextInt,
204                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
205                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
206                                                         ,(PFN_HANDLE_RELEASE)&PVRSRVRGXTDMDestroyTransferContextKM);
207         if (psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
208         {
209                 UnlockHandle();
210                 goto RGXTDMCreateTransferContext_exit;
211         }
212
213         /* Release now we have created handles. */
214         UnlockHandle();
215
216
217
218 RGXTDMCreateTransferContext_exit:
219
220         /* Lock over handle lookup cleanup. */
221         LockHandle();
222
223
224
225
226
227
228                                 {
229                                         /* Unreference the previously looked up handle */
230                                                 if(hPrivDataInt)
231                                                 {
232                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
233                                                                                         hPrivData,
234                                                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
235                                                 }
236                                 }
237         /* Release now we have cleaned up look up handles. */
238         UnlockHandle();
239
240         if (psRGXTDMCreateTransferContextOUT->eError != PVRSRV_OK)
241         {
242                 if (psTransferContextInt)
243                 {
244                         PVRSRVRGXTDMDestroyTransferContextKM(psTransferContextInt);
245                 }
246         }
247
248         /* Allocated space should be equal to the last updated offset */
249         PVR_ASSERT(ui32BufferSize == ui32NextOffset);
250
251 #if defined(INTEGRITY_OS)
252         if(pArrayArgsBuffer)
253 #else
254         if(!bHaveEnoughSpace && pArrayArgsBuffer)
255 #endif
256                 OSFreeMemNoStats(pArrayArgsBuffer);
257
258
259         return 0;
260 }
261
262
263 static IMG_INT
264 PVRSRVBridgeRGXTDMDestroyTransferContext(IMG_UINT32 ui32DispatchTableEntry,
265                                           PVRSRV_BRIDGE_IN_RGXTDMDESTROYTRANSFERCONTEXT *psRGXTDMDestroyTransferContextIN,
266                                           PVRSRV_BRIDGE_OUT_RGXTDMDESTROYTRANSFERCONTEXT *psRGXTDMDestroyTransferContextOUT,
267                                          CONNECTION_DATA *psConnection)
268 {
269
270
271         {
272                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
273
274                 /* Check that device supports the required feature */
275                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
276                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
277                 {
278                         psRGXTDMDestroyTransferContextOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
279
280                         goto RGXTDMDestroyTransferContext_exit;
281                 }
282         }
283
284
285
286
287
288
289
290         /* Lock over handle destruction. */
291         LockHandle();
292
293
294
295
296
297         psRGXTDMDestroyTransferContextOUT->eError =
298                 PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
299                                         (IMG_HANDLE) psRGXTDMDestroyTransferContextIN->hTransferContext,
300                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
301         if ((psRGXTDMDestroyTransferContextOUT->eError != PVRSRV_OK) &&
302             (psRGXTDMDestroyTransferContextOUT->eError != PVRSRV_ERROR_RETRY))
303         {
304                 PVR_DPF((PVR_DBG_ERROR,
305                         "PVRSRVBridgeRGXTDMDestroyTransferContext: %s",
306                         PVRSRVGetErrorStringKM(psRGXTDMDestroyTransferContextOUT->eError)));
307                 PVR_ASSERT(0);
308                 UnlockHandle();
309                 goto RGXTDMDestroyTransferContext_exit;
310         }
311
312         /* Release now we have destroyed handles. */
313         UnlockHandle();
314
315
316
317 RGXTDMDestroyTransferContext_exit:
318
319
320
321
322         return 0;
323 }
324
325
326 static IMG_INT
327 PVRSRVBridgeRGXTDMSubmitTransfer(IMG_UINT32 ui32DispatchTableEntry,
328                                           PVRSRV_BRIDGE_IN_RGXTDMSUBMITTRANSFER *psRGXTDMSubmitTransferIN,
329                                           PVRSRV_BRIDGE_OUT_RGXTDMSUBMITTRANSFER *psRGXTDMSubmitTransferOUT,
330                                          CONNECTION_DATA *psConnection)
331 {
332         IMG_HANDLE hTransferContext = psRGXTDMSubmitTransferIN->hTransferContext;
333         RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
334         SYNC_PRIMITIVE_BLOCK * *psFenceUFOSyncPrimBlockInt = NULL;
335         IMG_HANDLE *hFenceUFOSyncPrimBlockInt2 = NULL;
336         IMG_UINT32 *ui32FenceSyncOffsetInt = NULL;
337         IMG_UINT32 *ui32FenceValueInt = NULL;
338         SYNC_PRIMITIVE_BLOCK * *psUpdateUFOSyncPrimBlockInt = NULL;
339         IMG_HANDLE *hUpdateUFOSyncPrimBlockInt2 = NULL;
340         IMG_UINT32 *ui32UpdateSyncOffsetInt = NULL;
341         IMG_UINT32 *ui32UpdateValueInt = NULL;
342         IMG_UINT32 *ui32ServerSyncFlagsInt = NULL;
343         SERVER_SYNC_PRIMITIVE * *psServerSyncInt = NULL;
344         IMG_HANDLE *hServerSyncInt2 = NULL;
345         IMG_CHAR *uiUpdateFenceNameInt = NULL;
346         IMG_UINT8 *ui8FWCommandInt = NULL;
347         IMG_UINT32 *ui32SyncPMRFlagsInt = NULL;
348         PMR * *psSyncPMRsInt = NULL;
349         IMG_HANDLE *hSyncPMRsInt2 = NULL;
350
351         IMG_UINT32 ui32NextOffset = 0;
352         IMG_BYTE   *pArrayArgsBuffer = NULL;
353 #if !defined(INTEGRITY_OS)
354         IMG_BOOL bHaveEnoughSpace = IMG_FALSE;
355 #endif
356
357         IMG_UINT32 ui32BufferSize = 
358                         (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
359                         (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) +
360                         (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
361                         (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) +
362                         (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *)) +
363                         (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) +
364                         (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
365                         (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) +
366                         (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) +
367                         (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *)) +
368                         (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) +
369                         (32 * sizeof(IMG_CHAR)) +
370                         (psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8)) +
371                         (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32)) +
372                         (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(PMR *)) +
373                         (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE)) +
374                         0;
375
376         {
377                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
378
379                 /* Check that device supports the required feature */
380                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
381                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
382                 {
383                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
384
385                         goto RGXTDMSubmitTransfer_exit;
386                 }
387         }
388
389
390
391
392         if (ui32BufferSize != 0)
393         {
394 #if !defined(INTEGRITY_OS)
395                 /* Try to use remainder of input buffer for copies if possible, word-aligned for safety. */
396                 IMG_UINT32 ui32InBufferOffset = PVR_ALIGN(sizeof(*psRGXTDMSubmitTransferIN), sizeof(unsigned long));
397                 IMG_UINT32 ui32InBufferExcessSize = ui32InBufferOffset >= PVRSRV_MAX_BRIDGE_IN_SIZE ? 0 :
398                         PVRSRV_MAX_BRIDGE_IN_SIZE - ui32InBufferOffset;
399
400                 bHaveEnoughSpace = ui32BufferSize <= ui32InBufferExcessSize;
401                 if (bHaveEnoughSpace)
402                 {
403                         IMG_BYTE *pInputBuffer = (IMG_BYTE *)psRGXTDMSubmitTransferIN;
404
405                         pArrayArgsBuffer = &pInputBuffer[ui32InBufferOffset];           }
406                 else
407 #endif
408                 {
409                         pArrayArgsBuffer = OSAllocMemNoStats(ui32BufferSize);
410
411                         if(!pArrayArgsBuffer)
412                         {
413                                 psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
414                                 goto RGXTDMSubmitTransfer_exit;
415                         }
416                 }
417         }
418
419         if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount != 0)
420         {
421                 psFenceUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
422                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
423                 hFenceUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset); 
424                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE);
425         }
426
427                         /* Copy the data over */
428                         if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE) > 0)
429                         {
430                                 if ( OSCopyFromUser(NULL, hFenceUFOSyncPrimBlockInt2, psRGXTDMSubmitTransferIN->phFenceUFOSyncPrimBlock, psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
431                                 {
432                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
433
434                                         goto RGXTDMSubmitTransfer_exit;
435                                 }
436                         }
437         if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount != 0)
438         {
439                 ui32FenceSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
440                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
441         }
442
443                         /* Copy the data over */
444                         if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
445                         {
446                                 if ( OSCopyFromUser(NULL, ui32FenceSyncOffsetInt, psRGXTDMSubmitTransferIN->pui32FenceSyncOffset, psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
447                                 {
448                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
449
450                                         goto RGXTDMSubmitTransfer_exit;
451                                 }
452                         }
453         if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount != 0)
454         {
455                 ui32FenceValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
456                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32);
457         }
458
459                         /* Copy the data over */
460                         if (psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32) > 0)
461                         {
462                                 if ( OSCopyFromUser(NULL, ui32FenceValueInt, psRGXTDMSubmitTransferIN->pui32FenceValue, psRGXTDMSubmitTransferIN->ui32ClientFenceCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
463                                 {
464                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
465
466                                         goto RGXTDMSubmitTransfer_exit;
467                                 }
468                         }
469         if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount != 0)
470         {
471                 psUpdateUFOSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
472                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(SYNC_PRIMITIVE_BLOCK *);
473                 hUpdateUFOSyncPrimBlockInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset); 
474                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE);
475         }
476
477                         /* Copy the data over */
478                         if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE) > 0)
479                         {
480                                 if ( OSCopyFromUser(NULL, hUpdateUFOSyncPrimBlockInt2, psRGXTDMSubmitTransferIN->phUpdateUFOSyncPrimBlock, psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
481                                 {
482                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
483
484                                         goto RGXTDMSubmitTransfer_exit;
485                                 }
486                         }
487         if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount != 0)
488         {
489                 ui32UpdateSyncOffsetInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
490                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
491         }
492
493                         /* Copy the data over */
494                         if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
495                         {
496                                 if ( OSCopyFromUser(NULL, ui32UpdateSyncOffsetInt, psRGXTDMSubmitTransferIN->pui32UpdateSyncOffset, psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
497                                 {
498                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
499
500                                         goto RGXTDMSubmitTransfer_exit;
501                                 }
502                         }
503         if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount != 0)
504         {
505                 ui32UpdateValueInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
506                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32);
507         }
508
509                         /* Copy the data over */
510                         if (psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32) > 0)
511                         {
512                                 if ( OSCopyFromUser(NULL, ui32UpdateValueInt, psRGXTDMSubmitTransferIN->pui32UpdateValue, psRGXTDMSubmitTransferIN->ui32ClientUpdateCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
513                                 {
514                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
515
516                                         goto RGXTDMSubmitTransfer_exit;
517                                 }
518                         }
519         if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount != 0)
520         {
521                 ui32ServerSyncFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
522                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32);
523         }
524
525                         /* Copy the data over */
526                         if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32) > 0)
527                         {
528                                 if ( OSCopyFromUser(NULL, ui32ServerSyncFlagsInt, psRGXTDMSubmitTransferIN->pui32ServerSyncFlags, psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
529                                 {
530                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
531
532                                         goto RGXTDMSubmitTransfer_exit;
533                                 }
534                         }
535         if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount != 0)
536         {
537                 psServerSyncInt = (SERVER_SYNC_PRIMITIVE **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
538                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(SERVER_SYNC_PRIMITIVE *);
539                 hServerSyncInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset); 
540                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE);
541         }
542
543                         /* Copy the data over */
544                         if (psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE) > 0)
545                         {
546                                 if ( OSCopyFromUser(NULL, hServerSyncInt2, psRGXTDMSubmitTransferIN->phServerSync, psRGXTDMSubmitTransferIN->ui32ServerSyncCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
547                                 {
548                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
549
550                                         goto RGXTDMSubmitTransfer_exit;
551                                 }
552                         }
553         
554         {
555                 uiUpdateFenceNameInt = (IMG_CHAR*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
556                 ui32NextOffset += 32 * sizeof(IMG_CHAR);
557         }
558
559                         /* Copy the data over */
560                         if (32 * sizeof(IMG_CHAR) > 0)
561                         {
562                                 if ( OSCopyFromUser(NULL, uiUpdateFenceNameInt, psRGXTDMSubmitTransferIN->puiUpdateFenceName, 32 * sizeof(IMG_CHAR)) != PVRSRV_OK )
563                                 {
564                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
565
566                                         goto RGXTDMSubmitTransfer_exit;
567                                 }
568                         }
569         if (psRGXTDMSubmitTransferIN->ui32CommandSize != 0)
570         {
571                 ui8FWCommandInt = (IMG_UINT8*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
572                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8);
573         }
574
575                         /* Copy the data over */
576                         if (psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8) > 0)
577                         {
578                                 if ( OSCopyFromUser(NULL, ui8FWCommandInt, psRGXTDMSubmitTransferIN->pui8FWCommand, psRGXTDMSubmitTransferIN->ui32CommandSize * sizeof(IMG_UINT8)) != PVRSRV_OK )
579                                 {
580                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
581
582                                         goto RGXTDMSubmitTransfer_exit;
583                                 }
584                         }
585         if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount != 0)
586         {
587                 ui32SyncPMRFlagsInt = (IMG_UINT32*)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
588                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32);
589         }
590
591                         /* Copy the data over */
592                         if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32) > 0)
593                         {
594                                 if ( OSCopyFromUser(NULL, ui32SyncPMRFlagsInt, psRGXTDMSubmitTransferIN->pui32SyncPMRFlags, psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_UINT32)) != PVRSRV_OK )
595                                 {
596                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
597
598                                         goto RGXTDMSubmitTransfer_exit;
599                                 }
600                         }
601         if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount != 0)
602         {
603                 psSyncPMRsInt = (PMR **)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset);
604                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(PMR *);
605                 hSyncPMRsInt2 = (IMG_HANDLE *)(((IMG_UINT8 *)pArrayArgsBuffer) + ui32NextOffset); 
606                 ui32NextOffset += psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE);
607         }
608
609                         /* Copy the data over */
610                         if (psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE) > 0)
611                         {
612                                 if ( OSCopyFromUser(NULL, hSyncPMRsInt2, psRGXTDMSubmitTransferIN->phSyncPMRs, psRGXTDMSubmitTransferIN->ui32SyncPMRCount * sizeof(IMG_HANDLE)) != PVRSRV_OK )
613                                 {
614                                         psRGXTDMSubmitTransferOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
615
616                                         goto RGXTDMSubmitTransfer_exit;
617                                 }
618                         }
619
620         /* Lock over handle lookup. */
621         LockHandle();
622
623
624
625
626
627                                 {
628                                         /* Look up the address from the handle */
629                                         psRGXTDMSubmitTransferOUT->eError =
630                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
631                                                                                         (void **) &psTransferContextInt,
632                                                                                         hTransferContext,
633                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
634                                                                                         IMG_TRUE);
635                                         if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
636                                         {
637                                                 UnlockHandle();
638                                                 goto RGXTDMSubmitTransfer_exit;
639                                         }
640                                 }
641
642
643
644
645
646         {
647                 IMG_UINT32 i;
648
649                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientFenceCount;i++)
650                 {
651                                 {
652                                         /* Look up the address from the handle */
653                                         psRGXTDMSubmitTransferOUT->eError =
654                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
655                                                                                         (void **) &psFenceUFOSyncPrimBlockInt[i],
656                                                                                         hFenceUFOSyncPrimBlockInt2[i],
657                                                                                         PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
658                                                                                         IMG_TRUE);
659                                         if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
660                                         {
661                                                 UnlockHandle();
662                                                 goto RGXTDMSubmitTransfer_exit;
663                                         }
664                                 }
665                 }
666         }
667
668
669
670
671
672         {
673                 IMG_UINT32 i;
674
675                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientUpdateCount;i++)
676                 {
677                                 {
678                                         /* Look up the address from the handle */
679                                         psRGXTDMSubmitTransferOUT->eError =
680                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
681                                                                                         (void **) &psUpdateUFOSyncPrimBlockInt[i],
682                                                                                         hUpdateUFOSyncPrimBlockInt2[i],
683                                                                                         PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK,
684                                                                                         IMG_TRUE);
685                                         if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
686                                         {
687                                                 UnlockHandle();
688                                                 goto RGXTDMSubmitTransfer_exit;
689                                         }
690                                 }
691                 }
692         }
693
694
695
696
697
698         {
699                 IMG_UINT32 i;
700
701                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ServerSyncCount;i++)
702                 {
703                                 {
704                                         /* Look up the address from the handle */
705                                         psRGXTDMSubmitTransferOUT->eError =
706                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
707                                                                                         (void **) &psServerSyncInt[i],
708                                                                                         hServerSyncInt2[i],
709                                                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
710                                                                                         IMG_TRUE);
711                                         if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
712                                         {
713                                                 UnlockHandle();
714                                                 goto RGXTDMSubmitTransfer_exit;
715                                         }
716                                 }
717                 }
718         }
719
720
721
722
723
724         {
725                 IMG_UINT32 i;
726
727                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32SyncPMRCount;i++)
728                 {
729                                 {
730                                         /* Look up the address from the handle */
731                                         psRGXTDMSubmitTransferOUT->eError =
732                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
733                                                                                         (void **) &psSyncPMRsInt[i],
734                                                                                         hSyncPMRsInt2[i],
735                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR,
736                                                                                         IMG_TRUE);
737                                         if(psRGXTDMSubmitTransferOUT->eError != PVRSRV_OK)
738                                         {
739                                                 UnlockHandle();
740                                                 goto RGXTDMSubmitTransfer_exit;
741                                         }
742                                 }
743                 }
744         }
745         /* Release now we have looked up handles. */
746         UnlockHandle();
747
748         psRGXTDMSubmitTransferOUT->eError =
749                 PVRSRVRGXTDMSubmitTransferKM(
750                                         psTransferContextInt,
751                                         psRGXTDMSubmitTransferIN->ui32PDumpFlags,
752                                         psRGXTDMSubmitTransferIN->ui32ClientCacheOpSeqNum,
753                                         psRGXTDMSubmitTransferIN->ui32ClientFenceCount,
754                                         psFenceUFOSyncPrimBlockInt,
755                                         ui32FenceSyncOffsetInt,
756                                         ui32FenceValueInt,
757                                         psRGXTDMSubmitTransferIN->ui32ClientUpdateCount,
758                                         psUpdateUFOSyncPrimBlockInt,
759                                         ui32UpdateSyncOffsetInt,
760                                         ui32UpdateValueInt,
761                                         psRGXTDMSubmitTransferIN->ui32ServerSyncCount,
762                                         ui32ServerSyncFlagsInt,
763                                         psServerSyncInt,
764                                         psRGXTDMSubmitTransferIN->i32CheckFenceFD,
765                                         psRGXTDMSubmitTransferIN->i32UpdateTimelineFD,
766                                         &psRGXTDMSubmitTransferOUT->i32UpdateFenceFD,
767                                         uiUpdateFenceNameInt,
768                                         psRGXTDMSubmitTransferIN->ui32CommandSize,
769                                         ui8FWCommandInt,
770                                         psRGXTDMSubmitTransferIN->ui32ExternalJobReference,
771                                         psRGXTDMSubmitTransferIN->ui32SyncPMRCount,
772                                         ui32SyncPMRFlagsInt,
773                                         psSyncPMRsInt);
774
775
776
777
778 RGXTDMSubmitTransfer_exit:
779
780         /* Lock over handle lookup cleanup. */
781         LockHandle();
782
783
784
785
786
787
788                                 {
789                                         /* Unreference the previously looked up handle */
790                                                 if(psTransferContextInt)
791                                                 {
792                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
793                                                                                         hTransferContext,
794                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
795                                                 }
796                                 }
797
798
799
800
801
802         {
803                 IMG_UINT32 i;
804
805                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientFenceCount;i++)
806                 {
807                                 {
808                                         /* Unreference the previously looked up handle */
809                                                 if(psFenceUFOSyncPrimBlockInt[i])
810                                                 {
811                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
812                                                                                         hFenceUFOSyncPrimBlockInt2[i],
813                                                                                         PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
814                                                 }
815                                 }
816                 }
817         }
818
819
820
821
822
823         {
824                 IMG_UINT32 i;
825
826                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ClientUpdateCount;i++)
827                 {
828                                 {
829                                         /* Unreference the previously looked up handle */
830                                                 if(psUpdateUFOSyncPrimBlockInt[i])
831                                                 {
832                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
833                                                                                         hUpdateUFOSyncPrimBlockInt2[i],
834                                                                                         PVRSRV_HANDLE_TYPE_SYNC_PRIMITIVE_BLOCK);
835                                                 }
836                                 }
837                 }
838         }
839
840
841
842
843
844         {
845                 IMG_UINT32 i;
846
847                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32ServerSyncCount;i++)
848                 {
849                                 {
850                                         /* Unreference the previously looked up handle */
851                                                 if(psServerSyncInt[i])
852                                                 {
853                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
854                                                                                         hServerSyncInt2[i],
855                                                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
856                                                 }
857                                 }
858                 }
859         }
860
861
862
863
864
865         {
866                 IMG_UINT32 i;
867
868                 for (i=0;i<psRGXTDMSubmitTransferIN->ui32SyncPMRCount;i++)
869                 {
870                                 {
871                                         /* Unreference the previously looked up handle */
872                                                 if(psSyncPMRsInt[i])
873                                                 {
874                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
875                                                                                         hSyncPMRsInt2[i],
876                                                                                         PVRSRV_HANDLE_TYPE_PHYSMEM_PMR);
877                                                 }
878                                 }
879                 }
880         }
881         /* Release now we have cleaned up look up handles. */
882         UnlockHandle();
883
884         /* Allocated space should be equal to the last updated offset */
885         PVR_ASSERT(ui32BufferSize == ui32NextOffset);
886
887 #if defined(INTEGRITY_OS)
888         if(pArrayArgsBuffer)
889 #else
890         if(!bHaveEnoughSpace && pArrayArgsBuffer)
891 #endif
892                 OSFreeMemNoStats(pArrayArgsBuffer);
893
894
895         return 0;
896 }
897
898
899 static IMG_INT
900 PVRSRVBridgeRGXTDMSetTransferContextPriority(IMG_UINT32 ui32DispatchTableEntry,
901                                           PVRSRV_BRIDGE_IN_RGXTDMSETTRANSFERCONTEXTPRIORITY *psRGXTDMSetTransferContextPriorityIN,
902                                           PVRSRV_BRIDGE_OUT_RGXTDMSETTRANSFERCONTEXTPRIORITY *psRGXTDMSetTransferContextPriorityOUT,
903                                          CONNECTION_DATA *psConnection)
904 {
905         IMG_HANDLE hTransferContext = psRGXTDMSetTransferContextPriorityIN->hTransferContext;
906         RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
907
908
909         {
910                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
911
912                 /* Check that device supports the required feature */
913                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
914                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
915                 {
916                         psRGXTDMSetTransferContextPriorityOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
917
918                         goto RGXTDMSetTransferContextPriority_exit;
919                 }
920         }
921
922
923
924
925
926         /* Lock over handle lookup. */
927         LockHandle();
928
929
930
931
932
933                                 {
934                                         /* Look up the address from the handle */
935                                         psRGXTDMSetTransferContextPriorityOUT->eError =
936                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
937                                                                                         (void **) &psTransferContextInt,
938                                                                                         hTransferContext,
939                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
940                                                                                         IMG_TRUE);
941                                         if(psRGXTDMSetTransferContextPriorityOUT->eError != PVRSRV_OK)
942                                         {
943                                                 UnlockHandle();
944                                                 goto RGXTDMSetTransferContextPriority_exit;
945                                         }
946                                 }
947         /* Release now we have looked up handles. */
948         UnlockHandle();
949
950         psRGXTDMSetTransferContextPriorityOUT->eError =
951                 PVRSRVRGXTDMSetTransferContextPriorityKM(psConnection, OSGetDevData(psConnection),
952                                         psTransferContextInt,
953                                         psRGXTDMSetTransferContextPriorityIN->ui32Priority);
954
955
956
957
958 RGXTDMSetTransferContextPriority_exit:
959
960         /* Lock over handle lookup cleanup. */
961         LockHandle();
962
963
964
965
966
967
968                                 {
969                                         /* Unreference the previously looked up handle */
970                                                 if(psTransferContextInt)
971                                                 {
972                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
973                                                                                         hTransferContext,
974                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
975                                                 }
976                                 }
977         /* Release now we have cleaned up look up handles. */
978         UnlockHandle();
979
980
981         return 0;
982 }
983
984
985 static IMG_INT
986 PVRSRVBridgeRGXTDMNotifyWriteOffsetUpdate(IMG_UINT32 ui32DispatchTableEntry,
987                                           PVRSRV_BRIDGE_IN_RGXTDMNOTIFYWRITEOFFSETUPDATE *psRGXTDMNotifyWriteOffsetUpdateIN,
988                                           PVRSRV_BRIDGE_OUT_RGXTDMNOTIFYWRITEOFFSETUPDATE *psRGXTDMNotifyWriteOffsetUpdateOUT,
989                                          CONNECTION_DATA *psConnection)
990 {
991         IMG_HANDLE hTransferContext = psRGXTDMNotifyWriteOffsetUpdateIN->hTransferContext;
992         RGX_SERVER_TQ_TDM_CONTEXT * psTransferContextInt = NULL;
993
994
995         {
996                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
997
998                 /* Check that device supports the required feature */
999                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
1000                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_FASTRENDER_DM_BIT_MASK))
1001                 {
1002                         psRGXTDMNotifyWriteOffsetUpdateOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
1003
1004                         goto RGXTDMNotifyWriteOffsetUpdate_exit;
1005                 }
1006         }
1007
1008
1009
1010
1011
1012         /* Lock over handle lookup. */
1013         LockHandle();
1014
1015
1016
1017
1018
1019                                 {
1020                                         /* Look up the address from the handle */
1021                                         psRGXTDMNotifyWriteOffsetUpdateOUT->eError =
1022                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
1023                                                                                         (void **) &psTransferContextInt,
1024                                                                                         hTransferContext,
1025                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT,
1026                                                                                         IMG_TRUE);
1027                                         if(psRGXTDMNotifyWriteOffsetUpdateOUT->eError != PVRSRV_OK)
1028                                         {
1029                                                 UnlockHandle();
1030                                                 goto RGXTDMNotifyWriteOffsetUpdate_exit;
1031                                         }
1032                                 }
1033         /* Release now we have looked up handles. */
1034         UnlockHandle();
1035
1036         psRGXTDMNotifyWriteOffsetUpdateOUT->eError =
1037                 PVRSRVRGXTDMNotifyWriteOffsetUpdateKM(
1038                                         psTransferContextInt,
1039                                         psRGXTDMNotifyWriteOffsetUpdateIN->ui32PDumpFlags);
1040
1041
1042
1043
1044 RGXTDMNotifyWriteOffsetUpdate_exit:
1045
1046         /* Lock over handle lookup cleanup. */
1047         LockHandle();
1048
1049
1050
1051
1052
1053
1054                                 {
1055                                         /* Unreference the previously looked up handle */
1056                                                 if(psTransferContextInt)
1057                                                 {
1058                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
1059                                                                                         hTransferContext,
1060                                                                                         PVRSRV_HANDLE_TYPE_RGX_SERVER_TQ_TDM_CONTEXT);
1061                                                 }
1062                                 }
1063         /* Release now we have cleaned up look up handles. */
1064         UnlockHandle();
1065
1066
1067         return 0;
1068 }
1069
1070
1071
1072
1073 /* *************************************************************************** 
1074  * Server bridge dispatch related glue 
1075  */
1076
1077 static IMG_BOOL bUseLock = IMG_TRUE;
1078
1079 PVRSRV_ERROR InitRGXTQ2Bridge(void);
1080 PVRSRV_ERROR DeinitRGXTQ2Bridge(void);
1081
1082 /*
1083  * Register all RGXTQ2 functions with services
1084  */
1085 PVRSRV_ERROR InitRGXTQ2Bridge(void)
1086 {
1087
1088         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMCREATETRANSFERCONTEXT, PVRSRVBridgeRGXTDMCreateTransferContext,
1089                                         NULL, bUseLock);
1090
1091         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMDESTROYTRANSFERCONTEXT, PVRSRVBridgeRGXTDMDestroyTransferContext,
1092                                         NULL, bUseLock);
1093
1094         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMSUBMITTRANSFER, PVRSRVBridgeRGXTDMSubmitTransfer,
1095                                         NULL, bUseLock);
1096
1097         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMSETTRANSFERCONTEXTPRIORITY, PVRSRVBridgeRGXTDMSetTransferContextPriority,
1098                                         NULL, bUseLock);
1099
1100         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXTQ2, PVRSRV_BRIDGE_RGXTQ2_RGXTDMNOTIFYWRITEOFFSETUPDATE, PVRSRVBridgeRGXTDMNotifyWriteOffsetUpdate,
1101                                         NULL, bUseLock);
1102
1103
1104         return PVRSRV_OK;
1105 }
1106
1107 /*
1108  * Unregister all rgxtq2 functions with services
1109  */
1110 PVRSRV_ERROR DeinitRGXTQ2Bridge(void)
1111 {
1112         return PVRSRV_OK;
1113 }