353d247802500f3dae690bbe322df9f775457a6b
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / server / devices / rgx / rgxccb.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          RGX Circular Command Buffer functionality.
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Header for the RGX Circular Command Buffer functionality.
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 #if !defined(__RGXCCB_H__)
45 #define __RGXCCB_H__
46
47 #include "devicemem.h"
48 #include "device.h"
49 #include "rgxdevice.h"
50 #include "sync_server.h"
51 #include "connection_server.h"
52 #include "rgx_fwif_shared.h"
53 #include "rgxdebug.h"
54
55 #define MAX_CLIENT_CCB_NAME     30
56
57 typedef struct _RGX_CLIENT_CCB_ RGX_CLIENT_CCB;
58
59 /*
60         This structure is declared here as it's allocated on the heap by
61         the callers
62 */
63
64 typedef struct _RGX_CCB_CMD_HELPER_DATA_ {
65         /* Data setup at command init time */
66         RGX_CLIENT_CCB                  *psClientCCB;
67         IMG_CHAR                                *pszCommandName;
68         IMG_BOOL                                bPDumpContinuous;
69         
70         IMG_UINT32                              ui32ClientFenceCount;
71         PRGXFWIF_UFO_ADDR               *pauiFenceUFOAddress;
72         IMG_UINT32                              *paui32FenceValue;
73         IMG_UINT32                              ui32ClientUpdateCount;
74         PRGXFWIF_UFO_ADDR               *pauiUpdateUFOAddress;
75         IMG_UINT32                              *paui32UpdateValue;
76
77         IMG_UINT32                              ui32ServerSyncCount;
78         IMG_UINT32                              *paui32ServerSyncFlags;
79         SERVER_SYNC_PRIMITIVE   **papsServerSyncs;
80
81         RGXFWIF_CCB_CMD_TYPE    eType;
82         IMG_UINT32                              ui32CmdSize;
83         IMG_UINT8                               *pui8DMCmd;
84         IMG_UINT32                              ui32FenceCmdSize;
85         IMG_UINT32                              ui32DMCmdSize;
86         IMG_UINT32                              ui32UpdateCmdSize;
87         IMG_UINT32                              ui32UnfencedUpdateCmdSize;
88
89         /* timestamp commands */
90         RGXFWIF_DEV_VIRTADDR    pPreTimestamp;
91         IMG_UINT32              ui32PreTimeStampCmdSize;
92         RGXFWIF_DEV_VIRTADDR    pPostTimestamp;
93         IMG_UINT32              ui32PostTimeStampCmdSize;
94         PRGXFWIF_UFO_ADDR       pRMWUFOAddr;
95         IMG_UINT32              ui32RMWUFOCmdSize;
96
97         /* Data setup at command acquire time */
98         IMG_UINT8                               *pui8StartPtr;
99         IMG_UINT8                               *pui8ServerUpdateStart;
100         IMG_UINT8                               *pui8ServerUnfencedUpdateStart;
101         IMG_UINT8                               *pui8ServerFenceStart;
102         IMG_UINT32                              ui32ServerFenceCount;
103         IMG_UINT32                              ui32ServerUpdateCount;
104         IMG_UINT32                              ui32ServerUnfencedUpdateCount;
105
106 } RGX_CCB_CMD_HELPER_DATA;
107
108 #define PADDING_COMMAND_SIZE    (sizeof(RGXFWIF_CCB_CMD_HEADER))
109
110 PVRSRV_ERROR RGXCreateCCB(PVRSRV_DEVICE_NODE    *psDeviceNode,
111                                                   IMG_UINT32                    ui32CCBSizeLog2,
112                                                   CONNECTION_DATA               *psConnectionData,
113                                                   const IMG_CHAR                *pszName,
114                                                   RGX_SERVER_COMMON_CONTEXT *psServerCommonContext,
115                                                   RGX_CLIENT_CCB                **ppsClientCCB,
116                                                   DEVMEM_MEMDESC                **ppsClientCCBMemDesc,
117                                                   DEVMEM_MEMDESC                **ppsClientCCBCtlMemDesc);
118
119 IMG_VOID RGXDestroyCCB(RGX_CLIENT_CCB *psClientCCB);
120
121 PVRSRV_ERROR RGXAcquireCCB(RGX_CLIENT_CCB *psClientCCB,
122                                                                                 IMG_UINT32              ui32CmdSize,
123                                                                                 IMG_PVOID               *ppvBufferSpace,
124                                                                                 IMG_BOOL                bPDumpContinuous);
125
126 IMG_INTERNAL IMG_VOID RGXReleaseCCB(RGX_CLIENT_CCB *psClientCCB,
127                                                                         IMG_UINT32              ui32CmdSize,
128                                                                         IMG_BOOL                bPDumpContinuous);
129
130 IMG_UINT32 RGXGetHostWriteOffsetCCB(RGX_CLIENT_CCB *psClientCCB);
131
132 PVRSRV_ERROR RGXCmdHelperInitCmdCCB(RGX_CLIENT_CCB          *psClientCCB,
133                                     IMG_UINT32              ui32ClientFenceCount,
134                                     PRGXFWIF_UFO_ADDR       *pauiFenceUFOAddress,
135                                     IMG_UINT32              *paui32FenceValue,
136                                     IMG_UINT32              ui32ClientUpdateCount,
137                                     PRGXFWIF_UFO_ADDR       *pauiUpdateUFOAddress,
138                                     IMG_UINT32              *paui32UpdateValue,
139                                     IMG_UINT32              ui32ServerSyncCount,
140                                     IMG_UINT32              *paui32ServerSyncFlags,
141                                     SERVER_SYNC_PRIMITIVE   **pasServerSyncs,
142                                     IMG_UINT32              ui32CmdSize,
143                                     IMG_UINT8               *pui8DMCmd,
144                                     RGXFWIF_DEV_VIRTADDR    *ppPreTimestamp,
145                                     RGXFWIF_DEV_VIRTADDR    *ppPostTimestamp,
146                                     RGXFWIF_DEV_VIRTADDR    *ppRMWUFOAddr,
147                                     RGXFWIF_CCB_CMD_TYPE    eType,
148                                     IMG_BOOL                bPDumpContinuous,
149                                     IMG_CHAR                *pszCommandName,
150                                     RGX_CCB_CMD_HELPER_DATA *psCmdHelperData);
151
152 PVRSRV_ERROR RGXCmdHelperAcquireCmdCCB(IMG_UINT32 ui32CmdCount,
153                                                                            RGX_CCB_CMD_HELPER_DATA *asCmdHelperData,
154                                                                            IMG_BOOL *pbKickRequired);
155
156 IMG_VOID RGXCmdHelperReleaseCmdCCB(IMG_UINT32 ui32CmdCount,
157                                                                    RGX_CCB_CMD_HELPER_DATA *asCmdHelperData,
158                                                                    const IMG_CHAR *pcszDMName,
159                                                                    IMG_UINT32 ui32CtxAddr);
160
161 IMG_UINT32 RGXCmdHelperGetCommandSize(IMG_UINT32 ui32CmdCount,
162                                                                    RGX_CCB_CMD_HELPER_DATA *asCmdHelperData);
163
164 IMG_VOID DumpStalledCCBCommand(PRGXFWIF_FWCOMMONCONTEXT sFWCommonContext, RGX_CLIENT_CCB  *psCurrentClientCCB, DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf);
165 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING) || defined(PVRSRV_ENABLE_FULL_CCB_DUMP)
166 IMG_VOID DumpCCB(PRGXFWIF_FWCOMMONCONTEXT sFWCommonContext, RGX_CLIENT_CCB  *psCurrentClientCCB, DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf);
167 #endif
168
169 PVRSRV_ERROR CheckForStalledCCB(RGX_CLIENT_CCB  *psCurrentClientCCB);
170 #endif /* __RGXCCB_H__ */