RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / generated / syncsexport_bridge / server_syncsexport_bridge.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          Server bridge for syncsexport
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the server side of the bridge for syncsexport
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 "sync_server.h"
50
51
52 #include "common_syncsexport_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 #if defined (SUPPORT_AUTH)
63 #include "osauth.h"
64 #endif
65
66 #include <linux/slab.h>
67
68
69
70
71 /* ***************************************************************************
72  * Server-side bridge entry points
73  */
74  
75 static IMG_INT
76 PVRSRVBridgeSyncPrimServerSecureExport(IMG_UINT32 ui32DispatchTableEntry,
77                                           PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREEXPORT *psSyncPrimServerSecureExportIN,
78                                           PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREEXPORT *psSyncPrimServerSecureExportOUT,
79                                          CONNECTION_DATA *psConnection)
80 {
81         SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL;
82         SERVER_SYNC_EXPORT * psExportInt = IMG_NULL;
83         IMG_HANDLE hExportInt = IMG_NULL;
84         CONNECTION_DATA *psSecureConnection;
85
86
87
88
89
90
91
92                                 {
93                                         /* Look up the address from the handle */
94                                         psSyncPrimServerSecureExportOUT->eError =
95                                                 PVRSRVLookupHandle(psConnection->psHandleBase,
96                                                                                         (IMG_VOID **) &psSyncHandleInt,
97                                                                                         psSyncPrimServerSecureExportIN->hSyncHandle,
98                                                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE);
99                                         if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
100                                         {
101                                                 goto SyncPrimServerSecureExport_exit;
102                                         }
103                                 }
104
105
106         psSyncPrimServerSecureExportOUT->eError =
107                 PVRSRVSyncPrimServerSecureExportKM(psConnection,
108                                         psSyncHandleInt,
109                                         &psSyncPrimServerSecureExportOUT->Export,
110                                         &psExportInt, &psSecureConnection);
111         /* Exit early if bridged call fails */
112         if(psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
113         {
114                 goto SyncPrimServerSecureExport_exit;
115         }
116
117
118         psSyncPrimServerSecureExportOUT->eError = PVRSRVAllocHandle(psSecureConnection->psHandleBase,
119                                                         &hExportInt,
120                                                         (IMG_VOID *) psExportInt,
121                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_EXPORT,
122                                                         PVRSRV_HANDLE_ALLOC_FLAG_SHARED
123                                                         ,(PFN_HANDLE_RELEASE)&PVRSRVSyncPrimServerSecureUnexportKM);
124         if (psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
125         {
126                 goto SyncPrimServerSecureExport_exit;
127         }
128
129
130
131
132 SyncPrimServerSecureExport_exit:
133         if (psSyncPrimServerSecureExportOUT->eError != PVRSRV_OK)
134         {
135                 if (psExportInt)
136                 {
137                         PVRSRVSyncPrimServerSecureUnexportKM(psExportInt);
138                 }
139         }
140
141
142         return 0;
143 }
144
145 static IMG_INT
146 PVRSRVBridgeSyncPrimServerSecureUnexport(IMG_UINT32 ui32DispatchTableEntry,
147                                           PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREUNEXPORT *psSyncPrimServerSecureUnexportIN,
148                                           PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREUNEXPORT *psSyncPrimServerSecureUnexportOUT,
149                                          CONNECTION_DATA *psConnection)
150 {
151
152
153
154
155
156
157
158
159
160         psSyncPrimServerSecureUnexportOUT->eError =
161                 PVRSRVReleaseHandle(psConnection->psHandleBase,
162                                         (IMG_HANDLE) psSyncPrimServerSecureUnexportIN->hExport,
163                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_EXPORT);
164         if ((psSyncPrimServerSecureUnexportOUT->eError != PVRSRV_OK) && (psSyncPrimServerSecureUnexportOUT->eError != PVRSRV_ERROR_RETRY))
165         {
166                 PVR_ASSERT(0);
167                 goto SyncPrimServerSecureUnexport_exit;
168         }
169
170
171
172 SyncPrimServerSecureUnexport_exit:
173
174         return 0;
175 }
176
177 static IMG_INT
178 PVRSRVBridgeSyncPrimServerSecureImport(IMG_UINT32 ui32DispatchTableEntry,
179                                           PVRSRV_BRIDGE_IN_SYNCPRIMSERVERSECUREIMPORT *psSyncPrimServerSecureImportIN,
180                                           PVRSRV_BRIDGE_OUT_SYNCPRIMSERVERSECUREIMPORT *psSyncPrimServerSecureImportOUT,
181                                          CONNECTION_DATA *psConnection)
182 {
183         SERVER_SYNC_PRIMITIVE * psSyncHandleInt = IMG_NULL;
184
185
186
187
188
189
190
191         psSyncPrimServerSecureImportOUT->eError =
192                 PVRSRVSyncPrimServerSecureImportKM(
193                                         psSyncPrimServerSecureImportIN->Export,
194                                         &psSyncHandleInt,
195                                         &psSyncPrimServerSecureImportOUT->ui32SyncPrimVAddr);
196         /* Exit early if bridged call fails */
197         if(psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
198         {
199                 goto SyncPrimServerSecureImport_exit;
200         }
201
202
203         psSyncPrimServerSecureImportOUT->eError = PVRSRVAllocHandle(psConnection->psHandleBase,
204                                                         &psSyncPrimServerSecureImportOUT->hSyncHandle,
205                                                         (IMG_VOID *) psSyncHandleInt,
206                                                         PVRSRV_HANDLE_TYPE_SERVER_SYNC_PRIMITIVE,
207                                                         PVRSRV_HANDLE_ALLOC_FLAG_MULTI
208                                                         ,(PFN_HANDLE_RELEASE)&PVRSRVServerSyncFreeKM);
209         if (psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
210         {
211                 goto SyncPrimServerSecureImport_exit;
212         }
213
214
215
216
217 SyncPrimServerSecureImport_exit:
218         if (psSyncPrimServerSecureImportOUT->eError != PVRSRV_OK)
219         {
220                 if (psSyncHandleInt)
221                 {
222                         PVRSRVServerSyncFreeKM(psSyncHandleInt);
223                 }
224         }
225
226
227         return 0;
228 }
229
230
231
232 /* *************************************************************************** 
233  * Server bridge dispatch related glue 
234  */
235
236
237 PVRSRV_ERROR InitSYNCSEXPORTBridge(IMG_VOID);
238 PVRSRV_ERROR DeinitSYNCSEXPORTBridge(IMG_VOID);
239
240 /*
241  * Register all SYNCSEXPORT functions with services
242  */
243 PVRSRV_ERROR InitSYNCSEXPORTBridge(IMG_VOID)
244 {
245
246         SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREEXPORT, PVRSRVBridgeSyncPrimServerSecureExport,
247                                         IMG_NULL, IMG_NULL,
248                                         0, 0);
249
250         SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREUNEXPORT, PVRSRVBridgeSyncPrimServerSecureUnexport,
251                                         IMG_NULL, IMG_NULL,
252                                         0, 0);
253
254         SetDispatchTableEntry(PVRSRV_BRIDGE_SYNCSEXPORT, PVRSRV_BRIDGE_SYNCSEXPORT_SYNCPRIMSERVERSECUREIMPORT, PVRSRVBridgeSyncPrimServerSecureImport,
255                                         IMG_NULL, IMG_NULL,
256                                         0, 0);
257
258
259         return PVRSRV_OK;
260 }
261
262 /*
263  * Unregister all syncsexport functions with services
264  */
265 PVRSRV_ERROR DeinitSYNCSEXPORTBridge(IMG_VOID)
266 {
267         return PVRSRV_OK;
268 }
269