2344acd00d8bcf3137a084c3220999924499729a
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue / services / server / include / sync_server.h
1 /**************************************************************************/ /*!
2 @File
3 @Title          Server side synchronisation interface
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Describes the server side synchronisation functions
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 "img_types.h"
45 #include "device.h"
46 #include "devicemem.h"
47 #include "pdump.h"
48 #include "pvrsrv_error.h"
49 #include "connection_server.h"
50
51 #ifndef _SYNC_SERVER_H_
52 #define _SYNC_SERVER_H_
53
54 typedef struct _SERVER_OP_COOKIE_ SERVER_OP_COOKIE;
55 typedef struct _SERVER_SYNC_PRIMITIVE_ SERVER_SYNC_PRIMITIVE;
56 typedef struct _SYNC_PRIMITIVE_BLOCK_ SYNC_PRIMITIVE_BLOCK;
57 typedef struct _SERVER_SYNC_EXPORT_ SERVER_SYNC_EXPORT;
58 typedef struct _SYNC_CONNECTION_DATA_ SYNC_CONNECTION_DATA;
59 typedef struct SYNC_RECORD* SYNC_RECORD_HANDLE;
60
61 PVRSRV_ERROR
62 PVRSRVAllocSyncPrimitiveBlockKM(CONNECTION_DATA *psConnection,
63                                                                 PVRSRV_DEVICE_NODE *psDevNode,
64                                                                 SYNC_PRIMITIVE_BLOCK **ppsSyncBlk,
65                                                                 IMG_UINT32 *puiSyncPrimVAddr,
66                                                                 IMG_UINT32 *puiSyncPrimBlockSize,
67                                                                 DEVMEM_EXPORTCOOKIE **psExportCookie);
68
69 PVRSRV_ERROR
70 PVRSRVExportSyncPrimitiveBlockKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk,
71                                                                  DEVMEM_EXPORTCOOKIE **psExportCookie);
72
73 PVRSRV_ERROR
74 PVRSRVUnexportSyncPrimitiveBlockKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk);
75
76 PVRSRV_ERROR
77 PVRSRVFreeSyncPrimitiveBlockKM(SYNC_PRIMITIVE_BLOCK *ppsSyncBlk);
78
79 PVRSRV_ERROR
80 PVRSRVSyncPrimSetKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Index,
81                                         IMG_UINT32 ui32Value);
82
83 PVRSRV_ERROR
84 PVRSRVServerSyncPrimSetKM(SERVER_SYNC_PRIMITIVE *psServerSync, IMG_UINT32 ui32Value);
85
86 #if defined(SUPPORT_INSECURE_EXPORT)
87 PVRSRV_ERROR
88 PVRSRVSyncPrimServerExportKM(SERVER_SYNC_PRIMITIVE *psSync,
89                                                         SERVER_SYNC_EXPORT **ppsExport);
90
91 PVRSRV_ERROR
92 PVRSRVSyncPrimServerUnexportKM(SERVER_SYNC_EXPORT *psExport);
93
94 PVRSRV_ERROR
95 PVRSRVSyncPrimServerImportKM(SERVER_SYNC_EXPORT *psExport,
96                                                          SERVER_SYNC_PRIMITIVE **ppsSync,
97                                                          IMG_UINT32 *pui32SyncPrimVAddr);
98 #endif
99
100 #if defined(SUPPORT_SECURE_EXPORT)
101 PVRSRV_ERROR
102 PVRSRVSyncPrimServerSecureExportKM(CONNECTION_DATA *psConnection,
103                                                                    SERVER_SYNC_PRIMITIVE *psSync,
104                                                                    IMG_SECURE_TYPE *phSecure,
105                                                                    SERVER_SYNC_EXPORT **ppsExport,
106                                                                    CONNECTION_DATA **ppsSecureConnection);
107
108 PVRSRV_ERROR
109 PVRSRVSyncPrimServerSecureUnexportKM(SERVER_SYNC_EXPORT *psExport);
110
111 PVRSRV_ERROR
112 PVRSRVSyncPrimServerSecureImportKM(IMG_SECURE_TYPE hSecure,
113                                                                    SERVER_SYNC_PRIMITIVE **ppsSync,
114                                                                    IMG_UINT32 *pui32SyncPrimVAddr);
115 #endif
116
117 IMG_UINT32 PVRSRVServerSyncRequesterRegisterKM(IMG_UINT32 *pui32SyncRequesterID);
118 IMG_VOID PVRSRVServerSyncRequesterUnregisterKM(IMG_UINT32 ui32SyncRequesterID);
119
120 PVRSRV_ERROR
121 PVRSRVSyncRecordAddKM(
122                         SYNC_RECORD_HANDLE * phRecord,
123                         SYNC_PRIMITIVE_BLOCK * hServerSyncPrimBlock,
124                         IMG_UINT32 ui32FwBlockAddr,
125                         IMG_UINT32 ui32SyncOffset,
126                         IMG_BOOL bServerSync,
127                         IMG_UINT32 ui32ClassNameSize,
128                         const IMG_CHAR *pszClassName);
129 PVRSRV_ERROR
130 PVRSRVSyncRecordRemoveByHandleKM(
131                         SYNC_RECORD_HANDLE hRecord);
132
133 PVRSRV_ERROR
134 PVRSRVServerSyncAllocKM(PVRSRV_DEVICE_NODE *psDevNode,
135                                                 SERVER_SYNC_PRIMITIVE **ppsSync,
136                                                 IMG_UINT32 *pui32SyncPrimVAddr,
137                                                 IMG_UINT32 ui32ClassNameSize,
138                                                 const IMG_CHAR *szClassName);
139 PVRSRV_ERROR
140 PVRSRVServerSyncFreeKM(SERVER_SYNC_PRIMITIVE *psSync);
141
142 PVRSRV_ERROR
143 PVRSRVServerSyncGetStatusKM(IMG_UINT32 ui32SyncCount,
144                                                         SERVER_SYNC_PRIMITIVE **papsSyncs,
145                                                         IMG_UINT32 *pui32UID,
146                                                         IMG_UINT32 *pui32FWAddr,
147                                                         IMG_UINT32 *pui32CurrentOp,
148                                                         IMG_UINT32 *pui32NextOp);
149
150 PVRSRV_ERROR
151 PVRSRVServerSyncQueueSWOpKM(SERVER_SYNC_PRIMITIVE *psSync,
152                                                   IMG_UINT32 *pui32FenceValue,
153                                                   IMG_UINT32 *pui32UpdateValue,
154                                                   IMG_UINT32 ui32SyncRequesterID,
155                                                   IMG_BOOL bUpdate,
156                                                   IMG_BOOL *pbFenceRequired);
157
158 PVRSRV_ERROR
159 PVRSRVServerSyncQueueHWOpKM(SERVER_SYNC_PRIMITIVE *psSync,
160                                                            IMG_BOOL bUpdate,
161                                                        IMG_UINT32 *pui32FenceValue,
162                                                        IMG_UINT32 *pui32UpdateValue);
163
164 IMG_BOOL
165 ServerSyncFenceIsMet(SERVER_SYNC_PRIMITIVE *psSync,
166                                          IMG_UINT32 ui32FenceValue);
167
168 IMG_VOID
169 ServerSyncCompleteOp(SERVER_SYNC_PRIMITIVE *psSync,
170                                          IMG_BOOL bDoUpdate,
171                                          IMG_UINT32 ui32UpdateValue);
172
173
174 PVRSRV_ERROR
175 PVRSRVSyncPrimOpCreateKM(IMG_UINT32 ui32SyncBlockCount,
176                                                  SYNC_PRIMITIVE_BLOCK **papsSyncPrimBlock,
177                                                  IMG_UINT32 ui32ClientSyncCount,
178                                                  IMG_UINT32 *paui32SyncBlockIndex,
179                                                  IMG_UINT32 *paui32Index,
180                                                  IMG_UINT32 ui32ServerSyncCount,
181                                                  SERVER_SYNC_PRIMITIVE **papsServerSync,
182                                                  SERVER_OP_COOKIE **ppsServerCookie);
183
184 PVRSRV_ERROR
185 PVRSRVSyncPrimOpTakeKM(SERVER_OP_COOKIE *psServerCookie,
186                                                IMG_UINT32 ui32ClientSyncCount,
187                                                IMG_UINT32 *paui32Flags,
188                                                IMG_UINT32 *paui32FenceValue,
189                                                IMG_UINT32 *paui32UpdateValue,
190                                                IMG_UINT32 ui32ServerSyncCount,
191                                                    IMG_UINT32 *paui32ServerFlags);
192
193 PVRSRV_ERROR
194 PVRSRVSyncPrimOpReadyKM(SERVER_OP_COOKIE *psServerCookie,
195                                                 IMG_BOOL *pbReady);
196
197 PVRSRV_ERROR
198 PVRSRVSyncPrimOpCompleteKM(SERVER_OP_COOKIE *psServerCookie);
199
200 PVRSRV_ERROR
201 PVRSRVSyncPrimOpDestroyKM(SERVER_OP_COOKIE *psServerCookie);
202
203 IMG_UINT32 ServerSyncGetId(SERVER_SYNC_PRIMITIVE *psSync);
204
205 IMG_UINT32 ServerSyncGetFWAddr(SERVER_SYNC_PRIMITIVE *psSync);
206
207 IMG_UINT32 ServerSyncGetValue(SERVER_SYNC_PRIMITIVE *psSync);
208
209 IMG_UINT32 ServerSyncGetNextValue(SERVER_SYNC_PRIMITIVE *psSync);
210
211 IMG_VOID ServerSyncDumpPending(IMG_VOID);
212
213 PVRSRV_ERROR SyncRegisterConnection(SYNC_CONNECTION_DATA **ppsSyncConnectionData);
214 IMG_VOID SyncUnregisterConnection(SYNC_CONNECTION_DATA *ppsSyncConnectionData);
215 IMG_VOID SyncConnectionPDumpSyncBlocks(SYNC_CONNECTION_DATA *ppsSyncConnectionData);
216
217 PVRSRV_ERROR ServerSyncInit(IMG_VOID);
218 IMG_VOID ServerSyncDeinit(IMG_VOID);
219
220 #if defined(PDUMP)
221 PVRSRV_ERROR
222 PVRSRVSyncPrimPDumpKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset);
223
224 PVRSRV_ERROR
225 PVRSRVSyncPrimPDumpValueKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset, 
226                                                         IMG_UINT32 ui32Value);
227
228 PVRSRV_ERROR
229 PVRSRVSyncPrimPDumpPolKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset,
230                                                  IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask,
231                                                  PDUMP_POLL_OPERATOR eOperator,
232                                                  PDUMP_FLAGS_T uiDumpFlags);
233
234 PVRSRV_ERROR
235 PVRSRVSyncPrimOpPDumpPolKM(SERVER_OP_COOKIE *psServerCookie,
236                                                  PDUMP_POLL_OPERATOR eOperator,
237                                                  PDUMP_FLAGS_T ui32PDumpFlags);
238
239 PVRSRV_ERROR
240 PVRSRVSyncPrimPDumpCBPKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT64 ui32Offset,
241                                                  IMG_UINT64 uiWriteOffset, IMG_UINT64 uiPacketSize,
242                                                  IMG_UINT64 uiBufferSize);
243
244 #else   /* PDUMP */
245
246 #ifdef INLINE_IS_PRAGMA
247 #pragma inline(PVRSRVSyncPrimPDumpKM)
248 #endif
249 static INLINE PVRSRV_ERROR
250 PVRSRVSyncPrimPDumpKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset)
251 {
252         PVR_UNREFERENCED_PARAMETER(psSyncBlk);
253         PVR_UNREFERENCED_PARAMETER(ui32Offset);
254         return PVRSRV_OK;
255 }
256
257 #ifdef INLINE_IS_PRAGMA
258 #pragma inline(PVRSRVSyncPrimPDumpValueKM)
259 #endif
260 static INLINE PVRSRV_ERROR
261 PVRSRVSyncPrimPDumpValueKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset, 
262                                                         IMG_UINT32 ui32Value)
263 {
264         PVR_UNREFERENCED_PARAMETER(psSyncBlk);
265         PVR_UNREFERENCED_PARAMETER(ui32Offset);
266         PVR_UNREFERENCED_PARAMETER(ui32Value);
267         return PVRSRV_OK;
268 }
269
270 #ifdef INLINE_IS_PRAGMA
271 #pragma inline(PVRSRVSyncPrimPDumpPolKM)
272 #endif
273 static INLINE PVRSRV_ERROR
274 PVRSRVSyncPrimPDumpPolKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT32 ui32Offset,
275                                                  IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask,
276                                                  PDUMP_POLL_OPERATOR eOperator,
277                                                  PDUMP_FLAGS_T uiDumpFlags)
278 {
279         PVR_UNREFERENCED_PARAMETER(psSyncBlk);
280         PVR_UNREFERENCED_PARAMETER(ui32Offset);
281         PVR_UNREFERENCED_PARAMETER(ui32Value);
282         PVR_UNREFERENCED_PARAMETER(ui32Mask);
283         PVR_UNREFERENCED_PARAMETER(eOperator);
284         PVR_UNREFERENCED_PARAMETER(uiDumpFlags);
285         return PVRSRV_OK;
286 }
287
288 #ifdef INLINE_IS_PRAGMA
289 #pragma inline(PVRSRVSyncPrimOpPDumpPolKM)
290 #endif
291 static INLINE PVRSRV_ERROR
292 PVRSRVSyncPrimOpPDumpPolKM(SERVER_OP_COOKIE *psServerCookie,
293                                                  PDUMP_POLL_OPERATOR eOperator,
294                                                  PDUMP_FLAGS_T uiDumpFlags)
295 {
296         PVR_UNREFERENCED_PARAMETER(psServerCookie);
297         PVR_UNREFERENCED_PARAMETER(eOperator);
298         PVR_UNREFERENCED_PARAMETER(uiDumpFlags);
299         return PVRSRV_OK;
300 }
301
302 #ifdef INLINE_IS_PRAGMA
303 #pragma inline(PVRSRVSyncPrimPDumpCBPKM)
304 #endif
305 static INLINE PVRSRV_ERROR
306 PVRSRVSyncPrimPDumpCBPKM(SYNC_PRIMITIVE_BLOCK *psSyncBlk, IMG_UINT64 ui32Offset,
307                                                  IMG_UINT64 uiWriteOffset, IMG_UINT64 uiPacketSize,
308                                                  IMG_UINT64 uiBufferSize)
309 {
310         PVR_UNREFERENCED_PARAMETER(psSyncBlk);
311         PVR_UNREFERENCED_PARAMETER(ui32Offset);
312         PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
313         PVR_UNREFERENCED_PARAMETER(uiPacketSize);
314         PVR_UNREFERENCED_PARAMETER(uiBufferSize);
315         return PVRSRV_OK;
316 }
317 #endif  /* PDUMP */
318 #endif  /*_SYNC_SERVER_H_ */