1 /*************************************************************************/ /*!
3 @Title RGX sync kick routines
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description RGX sync kick routines
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
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:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
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.
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.
32 This License is also included in this distribution in the file called
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 */ /**************************************************************************/
46 #include "pvr_debug.h"
48 #include "rgxfwutils.h"
51 #include "devicemem.h"
52 #include "devicemem_pdump.h"
56 #include "sync_server.h"
57 #include "sync_internal.h"
61 PVRSRV_ERROR RGXKickSyncKM(PVRSRV_DEVICE_NODE *psDeviceNode,
62 RGX_SERVER_COMMON_CONTEXT *psServerCommonContext,
64 IMG_CHAR *pszCommandName,
65 IMG_UINT32 ui32ClientFenceCount,
66 PRGXFWIF_UFO_ADDR *pauiClientFenceUFOAddress,
67 IMG_UINT32 *paui32ClientFenceValue,
68 IMG_UINT32 ui32ClientUpdateCount,
69 PRGXFWIF_UFO_ADDR *pauiClientUpdateUFOAddress,
70 IMG_UINT32 *paui32ClientUpdateValue,
71 IMG_UINT32 ui32ServerSyncPrims,
72 IMG_UINT32 *paui32ServerSyncFlags,
73 SERVER_SYNC_PRIMITIVE **pasServerSyncs,
74 IMG_BOOL bPDumpContinuous)
76 RGXFWIF_KCCB_CMD sCmpKCCBCmd;
77 RGX_CCB_CMD_HELPER_DATA asCmdHelperData[1];
78 IMG_BOOL bKickRequired;
83 /* Sanity check the server fences */
84 for (i=0;i<ui32ServerSyncPrims;i++)
86 if (!(paui32ServerSyncFlags[i] & PVRSRV_CLIENT_SYNC_PRIM_OP_CHECK))
88 PVR_DPF((PVR_DBG_ERROR, "%s: Server fence (on %s) must fence", __FUNCTION__, pszCommandName));
89 return PVRSRV_ERROR_INVALID_SYNC_PRIM_OP;
93 eError = RGXCmdHelperInitCmdCCB(FWCommonContextGetClientCCB(psServerCommonContext),
95 pauiClientFenceUFOAddress,
96 paui32ClientFenceValue,
97 ui32ClientUpdateCount,
98 pauiClientUpdateUFOAddress,
99 paui32ClientUpdateValue,
101 paui32ServerSyncFlags,
104 IMG_NULL, /* pui8DMCmd */
105 IMG_NULL, /* ppPreAddr */
106 IMG_NULL, /* ppPostAddr */
107 IMG_NULL, /* ppRMWUFOAddr */
108 RGXFWIF_CCB_CMD_TYPE_NULL,
112 if (eError != PVRSRV_OK)
117 eError = RGXCmdHelperAcquireCmdCCB(IMG_ARR_NUM_ELEMS(asCmdHelperData),
118 asCmdHelperData, &bKickRequired);
119 if ((eError != PVRSRV_OK) && (!bKickRequired))
122 Only bail if no new data was submitted into the client CCB, we might
123 have already submitted a padding packet which we should flush through
126 PVR_DPF((PVR_DBG_ERROR, "%s: Failed to create client CCB command", __FUNCTION__));
132 We should reserved space in the kernel CCB here and fill in the command
134 This is so if there isn't space in the kernel CCB we can return with
135 retry back to services client before we take any operations
139 We might only be kicking for flush out a padding packet so only submit
140 the command if the create was successful
142 if (eError == PVRSRV_OK)
145 All the required resources are ready at this point, we can't fail so
146 take the required server sync operations and commit all the resources
148 RGXCmdHelperReleaseCmdCCB(1, asCmdHelperData, pszCommandName, FWCommonContextGetFWAddress(psServerCommonContext).ui32Addr);
151 /* Construct the kernel compute CCB command. */
152 sCmpKCCBCmd.eCmdType = RGXFWIF_KCCB_CMD_KICK;
153 sCmpKCCBCmd.uCmdData.sCmdKickData.psContext = FWCommonContextGetFWAddress(psServerCommonContext);
154 sCmpKCCBCmd.uCmdData.sCmdKickData.ui32CWoffUpdate = RGXGetHostWriteOffsetCCB(FWCommonContextGetClientCCB(psServerCommonContext));
155 sCmpKCCBCmd.uCmdData.sCmdKickData.ui32NumCleanupCtl = 0;
158 * Submit the compute command to the firmware.
160 LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US)
162 eError2 = RGXScheduleCommand(psDeviceNode->pvDevice,
167 if (eError2 != PVRSRV_ERROR_RETRY)
171 OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT);
172 } END_LOOP_UNTIL_TIMEOUT();
174 if (eError2 != PVRSRV_OK)
176 PVR_DPF((PVR_DBG_ERROR, "%s failed to schedule kernel CCB command. (0x%x)", __FUNCTION__, eError));
179 * Now check eError (which may have returned an error from our earlier call
180 * to RGXCmdHelperAcquireCmdCCB) - we needed to process any flush command first
181 * so we check it now...
183 if (eError != PVRSRV_OK )
196 /******************************************************************************
197 End of file (rgxsync.c)
198 ******************************************************************************/