RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / server / devices / rgx / rgxbreakpoint.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          RGX Breakpoint routines
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    RGX Breakpoint routines
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 "rgxbreakpoint.h"
45 #include "pvr_debug.h"
46 #include "rgxutils.h"
47 #include "rgxfwutils.h"
48 #include "rgxmem.h"
49 #include "device.h"
50 #include "sync_internal.h"
51 #include "pdump_km.h"
52 #include "pvrsrv.h"
53
54 PVRSRV_ERROR PVRSRVRGXSetBreakpointKM(PVRSRV_DEVICE_NODE        *psDeviceNode,
55                                         IMG_HANDLE              hMemCtxPrivData,
56                                         RGXFWIF_DM              eFWDataMaster,
57                                         IMG_UINT32              ui32BPAddr,
58                                         IMG_UINT32              ui32HandlerAddr,
59                                         IMG_UINT32              ui32DataMaster)
60 {
61         DEVMEM_MEMDESC          *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
62         PVRSRV_ERROR            eError = PVRSRV_OK;
63         RGXFWIF_KCCB_CMD        sBPCmd;
64         
65         if (psDeviceNode->psDevConfig->bBPSet == IMG_TRUE)
66                 return PVRSRV_ERROR_BP_ALREADY_SET;
67         
68         sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
69         sBPCmd.uCmdData.sBPData.ui32BPAddr = ui32BPAddr;
70         sBPCmd.uCmdData.sBPData.ui32HandlerAddr = ui32HandlerAddr;
71         sBPCmd.uCmdData.sBPData.ui32BPDM = ui32DataMaster;
72         sBPCmd.uCmdData.sBPData.bEnable = IMG_TRUE;
73         sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_WRITE;
74
75         RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext, 
76                                 psFWMemContextMemDesc, 
77                                 0 , 
78                                 RFW_FWADDR_NOREF_FLAG);
79                 
80         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
81                                 eFWDataMaster,
82                                 &sBPCmd,
83                                 sizeof(sBPCmd),
84                                 IMG_TRUE);
85         if (eError != PVRSRV_OK)
86         {
87                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
88                 return eError;
89         }
90
91         /* Wait for FW to complete */
92         eError = RGXWaitForFWOp(psDeviceNode->pvDevice, eFWDataMaster, psDeviceNode->psSyncPrim, IMG_TRUE);
93         if (eError != PVRSRV_OK)
94         {
95                 PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXSetBreakpointKM: Wait for completion aborted with error (%u)", eError));
96                 return eError;
97         }
98
99         psDeviceNode->psDevConfig->eBPDM = eFWDataMaster;
100         psDeviceNode->psDevConfig->bBPSet = IMG_TRUE;
101         
102         return eError;
103 }
104
105 PVRSRV_ERROR PVRSRVRGXClearBreakpointKM(PVRSRV_DEVICE_NODE      *psDeviceNode,
106                                         IMG_HANDLE              hMemCtxPrivData)
107 {
108         DEVMEM_MEMDESC          *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
109         PVRSRV_ERROR            eError = PVRSRV_OK;
110         RGXFWIF_KCCB_CMD        sBPCmd;
111         RGXFWIF_DM                      eDataMaster = psDeviceNode->psDevConfig->eBPDM;
112         
113         sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
114         sBPCmd.uCmdData.sBPData.ui32BPAddr = 0;
115         sBPCmd.uCmdData.sBPData.ui32HandlerAddr = 0;
116         sBPCmd.uCmdData.sBPData.bEnable = IMG_FALSE;
117         sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_WRITE | RGXFWIF_BPDATA_FLAGS_CTL;
118         
119         RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext, 
120                                 psFWMemContextMemDesc, 
121                                 0 , 
122                                 RFW_FWADDR_NOREF_FLAG);
123
124         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
125                                 eDataMaster,
126                                 &sBPCmd,
127                                 sizeof(sBPCmd),
128                                 IMG_TRUE);
129         if (eError != PVRSRV_OK)
130         {
131                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
132                 return eError;
133         }
134
135         /* Wait for FW to complete */
136         eError = RGXWaitForFWOp(psDeviceNode->pvDevice, eDataMaster, psDeviceNode->psSyncPrim, IMG_TRUE);
137         if (eError != PVRSRV_OK)
138         {
139                 PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXClearBreakpointKM: Wait for completion aborted with error (%u)", eError));
140                 return eError;
141         }
142
143         psDeviceNode->psDevConfig->bBPSet = IMG_FALSE;
144         
145         return eError;
146 }
147
148 PVRSRV_ERROR PVRSRVRGXEnableBreakpointKM(PVRSRV_DEVICE_NODE     *psDeviceNode,
149                                         IMG_HANDLE              hMemCtxPrivData)
150 {
151         DEVMEM_MEMDESC          *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
152         PVRSRV_ERROR            eError = PVRSRV_OK;
153         RGXFWIF_KCCB_CMD        sBPCmd;
154         RGXFWIF_DM                      eDataMaster = psDeviceNode->psDevConfig->eBPDM;
155         
156         if (psDeviceNode->psDevConfig->bBPSet == IMG_FALSE)
157                 return PVRSRV_ERROR_BP_NOT_SET;
158         
159         sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
160         sBPCmd.uCmdData.sBPData.bEnable = IMG_TRUE;
161         sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_CTL;
162         
163         RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext, 
164                                 psFWMemContextMemDesc, 
165                                 0 , 
166                                 RFW_FWADDR_NOREF_FLAG);
167
168         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
169                                 eDataMaster,
170                                 &sBPCmd,
171                                 sizeof(sBPCmd),
172                                 IMG_TRUE);
173         if (eError != PVRSRV_OK)
174         {
175                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
176                 return eError;
177         }
178
179         /* Wait for FW to complete */
180         eError = RGXWaitForFWOp(psDeviceNode->pvDevice, eDataMaster, psDeviceNode->psSyncPrim, IMG_TRUE);
181         if (eError != PVRSRV_OK)
182         {
183                 PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXEnableBreakpointKM: Wait for completion aborted with error (%u)", eError));
184                 return eError;
185         }
186         
187         return eError;
188 }
189
190 PVRSRV_ERROR PVRSRVRGXDisableBreakpointKM(PVRSRV_DEVICE_NODE    *psDeviceNode,
191                                         IMG_HANDLE              hMemCtxPrivData)
192 {
193         DEVMEM_MEMDESC          *psFWMemContextMemDesc = RGXGetFWMemDescFromMemoryContextHandle(hMemCtxPrivData);
194         PVRSRV_ERROR            eError = PVRSRV_OK;
195         RGXFWIF_KCCB_CMD        sBPCmd;
196         RGXFWIF_DM                      eDataMaster = psDeviceNode->psDevConfig->eBPDM;
197         
198         if (psDeviceNode->psDevConfig->bBPSet == IMG_FALSE)
199                 return PVRSRV_ERROR_BP_NOT_SET;
200         
201         sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
202         sBPCmd.uCmdData.sBPData.bEnable = IMG_FALSE;
203         sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_CTL;
204         
205         RGXSetFirmwareAddress(&sBPCmd.uCmdData.sBPData.psFWMemContext, 
206                                 psFWMemContextMemDesc, 
207                                 0 , 
208                                 RFW_FWADDR_NOREF_FLAG);
209         
210         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
211                                 eDataMaster,
212                                 &sBPCmd,
213                                 sizeof(sBPCmd),
214                                 IMG_TRUE);
215         if (eError != PVRSRV_OK)
216         {
217                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableBreakpointKM: RGXScheduleCommand failed. Error:%u", eError));
218                 return eError;
219         }
220
221         /* Wait for FW to complete */
222         eError = RGXWaitForFWOp(psDeviceNode->pvDevice, eDataMaster, psDeviceNode->psSyncPrim, IMG_TRUE);
223         if (eError != PVRSRV_OK)
224         {
225                 PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXDisableBreakpointKM: Wait for completion aborted with error (%u)", eError));
226                 return eError;
227         }
228                                 
229         return eError;
230 }
231
232 PVRSRV_ERROR PVRSRVRGXOverallocateBPRegistersKM(PVRSRV_DEVICE_NODE      *psDeviceNode,
233                                         IMG_UINT32              ui32TempRegs,
234                                         IMG_UINT32              ui32SharedRegs)
235 {
236         PVRSRV_ERROR            eError = PVRSRV_OK;
237         RGXFWIF_KCCB_CMD        sBPCmd;
238         
239         sBPCmd.eCmdType = RGXFWIF_KCCB_CMD_BP;
240         sBPCmd.uCmdData.sBPData.ui32Flags = RGXFWIF_BPDATA_FLAGS_REGS;
241         sBPCmd.uCmdData.sBPData.ui32TempRegs = ui32TempRegs;
242         sBPCmd.uCmdData.sBPData.ui32SharedRegs = ui32SharedRegs;
243
244         eError = RGXScheduleCommand(psDeviceNode->pvDevice,
245                                 RGXFWIF_DM_GP,
246                                 &sBPCmd,
247                                 sizeof(sBPCmd),
248                                 IMG_TRUE);
249         if (eError != PVRSRV_OK)
250         {
251                 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXOverallocateBPRegistersKM: RGXScheduleCommand failed. Error:%u", eError));
252                 return eError;
253         }
254
255         /* Wait for FW to complete */
256         eError = RGXWaitForFWOp(psDeviceNode->pvDevice, RGXFWIF_DM_GP, psDeviceNode->psSyncPrim, IMG_TRUE);
257         if (eError != PVRSRV_OK)
258         {
259                 PVR_DPF((PVR_DBG_ERROR,"PVRSRVRGXOverallocateBPRegistersKM: Wait for completion aborted with error (%u)", eError));
260                 return eError;
261         }
262
263         return eError;
264 }
265
266
267 /******************************************************************************
268  End of file (rgxbreakpoint.c)
269 ******************************************************************************/