1 /*************************************************************************/ /*!
3 @Title RGX TA and 3D Functionality
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Header for the RGX TA and 3D Functionality
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 */ /**************************************************************************/
44 #if !defined(__RGXTA3D_H__)
47 #include "devicemem.h"
48 #include "devicemem_server.h"
50 #include "rgxdevice.h"
51 #include "rgx_fwif_shared.h"
52 #include "rgx_fwif_resetframework.h"
53 #include "sync_server.h"
54 #include "connection_server.h"
56 #include "pvr_notifier.h"
58 typedef struct _RGX_SERVER_RENDER_CONTEXT_ RGX_SERVER_RENDER_CONTEXT;
59 typedef struct _RGX_FREELIST_ RGX_FREELIST;
60 typedef struct _RGX_PMR_NODE_ RGX_PMR_NODE;
63 PVRSRV_DEVICE_NODE *psDeviceNode;
64 DEVMEM_MEMDESC *psFWHWRTDataMemDesc;
65 DEVMEM_MEMDESC *psRTACtlMemDesc;
66 DEVMEM_MEMDESC *psRTArrayMemDesc;
67 DEVMEM_MEMDESC *psRendersAccArrayMemDesc;
68 RGX_FREELIST *apsFreeLists[RGXFW_MAX_FREELISTS];
69 PVRSRV_CLIENT_SYNC_PRIM *psCleanupSync;
70 } RGX_RTDATA_CLEANUP_DATA;
72 struct _RGX_FREELIST_ {
73 PVRSRV_RGXDEV_INFO *psDevInfo;
77 IMG_DEVMEM_OFFSET_T uiFreeListPMROffset;
80 IMG_UINT32 ui32MaxFLPages;
81 IMG_UINT32 ui32InitFLPages;
82 IMG_UINT32 ui32CurrentFLPages;
83 IMG_UINT32 ui32GrowFLPages;
84 IMG_UINT32 ui32FreelistID;
85 IMG_UINT32 ui32FreelistGlobalID; /* related global freelist for this freelist */
86 IMG_UINT64 ui64FreelistChecksum; /* checksum over freelist content */
87 IMG_BOOL bCheckFreelist; /* freelist check enabled */
88 IMG_UINT32 ui32RefCount; /* freelist reference counting */
90 IMG_UINT32 ui32NumGrowReqByApp; /* Total number of grow requests by Application*/
91 IMG_UINT32 ui32NumGrowReqByFW; /* Total Number of grow requests by Firmware */
92 IMG_UINT32 ui32NumHighPages; /* High Mark of pages in the freelist */
94 IMG_PID ownerPid; /* Pid of the owner of the list */
97 DLLIST_NODE sMemoryBlockHead;
98 DLLIST_NODE sMemoryBlockInitHead;
101 /* FW data structures */
102 DEVMEM_MEMDESC *psFWFreelistMemDesc;
103 RGXFWIF_DEV_VIRTADDR sFreeListFWDevVAddr;
105 PVRSRV_CLIENT_SYNC_PRIM *psCleanupSync;
107 #if defined(SUPPORT_WORKLOAD_ESTIMATION)
108 HASH_TABLE* psWorkloadHashTable;
112 struct _RGX_PMR_NODE_ {
113 RGX_FREELIST *psFreeList;
115 PMR_PAGELIST *psPageList;
116 DLLIST_NODE sMemoryBlock;
117 IMG_UINT32 ui32NumPages;
119 #if defined(PVR_RI_DEBUG)
125 PVRSRV_DEVICE_NODE *psDeviceNode;
126 DEVMEM_MEMDESC *psRenderTargetMemDesc;
127 } RGX_RT_CLEANUP_DATA;
130 PVRSRV_RGXDEV_INFO *psDevInfo;
131 DEVMEM_MEMDESC *psZSBufferMemDesc;
132 RGXFWIF_DEV_VIRTADDR sZSBufferFWDevVAddr;
134 DEVMEMINT_RESERVATION *psReservation;
136 DEVMEMINT_MAPPING *psMapping;
137 PVRSRV_MEMALLOCFLAGS_T uiMapFlags;
138 IMG_UINT32 ui32ZSBufferID;
139 IMG_UINT32 ui32RefCount;
142 IMG_BOOL ui32NumReqByApp; /* Number of Backing Requests from Application */
143 IMG_BOOL ui32NumReqByFW; /* Number of Backing Requests from Firmware */
149 PVRSRV_CLIENT_SYNC_PRIM *psCleanupSync;
153 RGX_ZSBUFFER_DATA *psZSBuffer;
156 /* Dump the physical pages of a freelist */
157 IMG_BOOL RGXDumpFreeListPageList(RGX_FREELIST *psFreeList);
160 /* Create HWRTDataSet */
162 PVRSRV_ERROR RGXCreateHWRTData(CONNECTION_DATA *psConnection,
163 PVRSRV_DEVICE_NODE *psDeviceNode,
164 IMG_UINT32 psRenderTarget,
165 IMG_DEV_VIRTADDR psPMMListDevVAddr,
166 IMG_DEV_VIRTADDR psVFPPageTableAddr,
167 RGX_FREELIST *apsFreeLists[RGXFW_MAX_FREELISTS],
168 RGX_RTDATA_CLEANUP_DATA **ppsCleanupData,
169 DEVMEM_MEMDESC **ppsRTACtlMemDesc,
170 IMG_UINT32 ui32PPPScreen,
171 IMG_UINT32 ui32PPPGridOffset,
172 IMG_UINT64 ui64PPPMultiSampleCtl,
173 IMG_UINT32 ui32TPCStride,
174 IMG_DEV_VIRTADDR sTailPtrsDevVAddr,
175 IMG_UINT32 ui32TPCSize,
176 IMG_UINT32 ui32TEScreen,
178 IMG_UINT32 ui32TEMTILE1,
179 IMG_UINT32 ui32TEMTILE2,
180 IMG_UINT32 ui32MTileStride,
181 IMG_UINT32 ui32ISPMergeLowerX,
182 IMG_UINT32 ui32ISPMergeLowerY,
183 IMG_UINT32 ui32ISPMergeUpperX,
184 IMG_UINT32 ui32ISPMergeUpperY,
185 IMG_UINT32 ui32ISPMergeScaleX,
186 IMG_UINT32 ui32ISPMergeScaleY,
187 IMG_UINT16 ui16MaxRTs,
188 DEVMEM_MEMDESC **psMemDesc,
189 IMG_UINT32 *puiHWRTData);
191 /* Destroy HWRTData */
193 PVRSRV_ERROR RGXDestroyHWRTData(RGX_RTDATA_CLEANUP_DATA *psCleanupData);
195 /* Create Render Target */
197 PVRSRV_ERROR RGXCreateRenderTarget(CONNECTION_DATA *psConnection,
198 PVRSRV_DEVICE_NODE *psDeviceNode,
199 IMG_DEV_VIRTADDR psVHeapTableDevVAddr,
200 RGX_RT_CLEANUP_DATA **ppsCleanupData,
201 IMG_UINT32 *sRenderTargetFWDevVAddr);
203 /* Destroy render target */
205 PVRSRV_ERROR RGXDestroyRenderTarget(RGX_RT_CLEANUP_DATA *psCleanupData);
212 PVRSRV_ERROR RGXCreateZSBufferKM(CONNECTION_DATA * psConnection,
213 PVRSRV_DEVICE_NODE * psDeviceNode,
214 DEVMEMINT_RESERVATION *psReservation,
216 PVRSRV_MEMALLOCFLAGS_T uiMapFlags,
217 RGX_ZSBUFFER_DATA **ppsZSBuffer,
218 IMG_UINT32 *sRenderTargetFWDevVAddr);
224 PVRSRV_ERROR RGXDestroyZSBufferKM(RGX_ZSBUFFER_DATA *psZSBuffer);
228 * RGXBackingZSBuffer()
230 * Backs ZS-Buffer with physical pages
233 RGXBackingZSBuffer(RGX_ZSBUFFER_DATA *psZSBuffer);
236 * RGXPopulateZSBufferKM()
238 * Backs ZS-Buffer with physical pages (called by Bridge calls)
241 PVRSRV_ERROR RGXPopulateZSBufferKM(RGX_ZSBUFFER_DATA *psZSBuffer,
242 RGX_POPULATION **ppsPopulation);
245 * RGXUnbackingZSBuffer()
247 * Frees ZS-Buffer's physical pages
250 PVRSRV_ERROR RGXUnbackingZSBuffer(RGX_ZSBUFFER_DATA *psZSBuffer);
253 * RGXUnpopulateZSBufferKM()
255 * Frees ZS-Buffer's physical pages (called by Bridge calls )
258 PVRSRV_ERROR RGXUnpopulateZSBufferKM(RGX_POPULATION *psPopulation);
261 RGXProcessRequestZSBufferBacking
264 void RGXProcessRequestZSBufferBacking(PVRSRV_RGXDEV_INFO *psDevInfo,
265 IMG_UINT32 ui32ZSBufferID);
268 RGXProcessRequestZSBufferUnbacking
271 void RGXProcessRequestZSBufferUnbacking(PVRSRV_RGXDEV_INFO *psDevInfo,
272 IMG_UINT32 ui32ZSBufferID);
278 PVRSRV_ERROR RGXGrowFreeList(RGX_FREELIST *psFreeList,
279 IMG_UINT32 ui32NumPages,
280 PDLLIST_NODE pListHeader);
282 /* Create free list */
284 PVRSRV_ERROR RGXCreateFreeList(CONNECTION_DATA *psConnection,
285 PVRSRV_DEVICE_NODE *psDeviceNode,
286 IMG_UINT32 ui32MaxFLPages,
287 IMG_UINT32 ui32InitFLPages,
288 IMG_UINT32 ui32GrowFLPages,
289 RGX_FREELIST *psGlobalFreeList,
290 IMG_BOOL bCheckFreelist,
291 IMG_DEV_VIRTADDR sFreeListDevVAddr,
293 IMG_DEVMEM_OFFSET_T uiFreeListPMROffset,
294 RGX_FREELIST **ppsFreeList);
296 /* Destroy free list */
298 PVRSRV_ERROR RGXDestroyFreeList(RGX_FREELIST *psFreeList);
301 RGXProcessRequestGrow
304 void RGXProcessRequestGrow(PVRSRV_RGXDEV_INFO *psDevInfo,
305 IMG_UINT32 ui32FreelistID);
310 PVRSRV_ERROR RGXAddBlockToFreeListKM(RGX_FREELIST *psFreeList,
311 IMG_UINT32 ui32NumPages);
313 /* Shrink free list */
315 PVRSRV_ERROR RGXRemoveBlockFromFreeListKM(RGX_FREELIST *psFreeList);
318 /* Reconstruct free list after Hardware Recovery */
319 void RGXProcessRequestFreelistsReconstruction(PVRSRV_RGXDEV_INFO *psDevInfo,
320 IMG_UINT32 ui32FreelistsCount,
321 IMG_UINT32 *paui32Freelists);
324 *******************************************************************************
326 @Function PVRSRVRGXCreateRenderContextKM
329 Server-side implementation of RGXCreateRenderContext
331 @Input pvDeviceNode - device node
332 @Input psTACCBMemDesc - TA CCB Memory descriptor
333 @Input psTACCBCtlMemDesc - TA CCB Ctrl Memory descriptor
334 @Input ps3DCCBMemDesc - 3D CCB Memory descriptor
335 @Input ps3DCCBCtlMemDesc - 3D CCB Ctrl Memory descriptor
336 @Input ui32Priority - context priority
337 @Input sMCUFenceAddr - MCU Fence device virtual address
338 @Input psVDMStackPointer - VDM call stack device virtual address
339 @Input ui32FrameworkRegisterSize - framework register size
340 @Input pbyFrameworkRegisters - ptr to framework register
341 @Input hMemCtxPrivData - memory context private data
342 @Output ppsCleanupData - clean up data
343 @Output ppsFWRenderContextMemDesc - firmware render context memory descriptor
344 @Output ppsFWContextStateMemDesc - firmware context state memory descriptor
348 ******************************************************************************/
350 PVRSRV_ERROR PVRSRVRGXCreateRenderContextKM(CONNECTION_DATA *psConnection,
351 PVRSRV_DEVICE_NODE *psDeviceNode,
352 IMG_UINT32 ui32Priority,
353 IMG_DEV_VIRTADDR sMCUFenceAddr,
354 IMG_DEV_VIRTADDR sVDMCallStackAddr,
355 IMG_UINT32 ui32FrameworkCommandSize,
356 IMG_PBYTE pabyFrameworkCommand,
357 IMG_HANDLE hMemCtxPrivData,
358 RGX_SERVER_RENDER_CONTEXT **ppsRenderContext);
362 *******************************************************************************
364 @Function PVRSRVRGXDestroyRenderContextKM
367 Server-side implementation of RGXDestroyRenderContext
369 @Input psCleanupData - clean up data
373 ******************************************************************************/
375 PVRSRV_ERROR PVRSRVRGXDestroyRenderContextKM(RGX_SERVER_RENDER_CONTEXT *psRenderContext);
379 *******************************************************************************
381 @Function PVRSRVRGXKickTA3DKM
384 Server-side implementation of RGXKickTA3D
386 @Input psRTDataCleanup - RT data associated with the kick (or NULL)
387 @Input psZBuffer - Z-buffer associated with the kick (or NULL)
388 @Input psSBuffer - S-buffer associated with the kick (or NULL)
392 ******************************************************************************/
394 PVRSRV_ERROR PVRSRVRGXKickTA3DKM(RGX_SERVER_RENDER_CONTEXT *psRenderContext,
395 IMG_UINT32 ui32ClientCacheOpSeqNum,
396 IMG_UINT32 ui32ClientTAFenceCount,
397 SYNC_PRIMITIVE_BLOCK **apsClientTAFenceSyncPrimBlock,
398 IMG_UINT32 *paui32ClientTAFenceSyncOffset,
399 IMG_UINT32 *paui32ClientTAFenceValue,
400 IMG_UINT32 ui32ClientTAUpdateCount,
401 SYNC_PRIMITIVE_BLOCK **apsClientUpdateSyncPrimBlock,
402 IMG_UINT32 *paui32ClientUpdateSyncOffset,
403 IMG_UINT32 *paui32ClientTAUpdateValue,
404 IMG_UINT32 ui32ServerTASyncPrims,
405 IMG_UINT32 *paui32ServerTASyncFlags,
406 SERVER_SYNC_PRIMITIVE **pasServerTASyncs,
407 IMG_UINT32 ui32Client3DFenceCount,
408 SYNC_PRIMITIVE_BLOCK **apsClient3DFenceSyncPrimBlock,
409 IMG_UINT32 *pauiClient3DFenceSyncOffset,
410 IMG_UINT32 *paui32Client3DFenceValue,
411 IMG_UINT32 ui32Client3DUpdateCount,
412 SYNC_PRIMITIVE_BLOCK **apsClient3DUpdateSyncPrimBlock,
413 IMG_UINT32 *paui32Client3DUpdateSyncOffset,
414 IMG_UINT32 *paui32Client3DUpdateValue,
415 IMG_UINT32 ui32Server3DSyncPrims,
416 IMG_UINT32 *paui32Server3DSyncFlags,
417 SERVER_SYNC_PRIMITIVE **pasServer3DSyncs,
418 SYNC_PRIMITIVE_BLOCK *psPRSyncPrimBlock,
419 IMG_UINT32 ui32PRSyncOffset,
420 IMG_UINT32 ui32PRFenceValue,
421 IMG_INT32 i32CheckFenceFD,
422 IMG_INT32 i32UpdateTimelineFD,
423 IMG_INT32 *pi32UpdateFenceFD,
424 IMG_CHAR szFenceName[32],
425 IMG_UINT32 ui32TACmdSize,
426 IMG_PBYTE pui8TADMCmd,
427 IMG_UINT32 ui323DPRCmdSize,
428 IMG_PBYTE pui83DPRDMCmd,
429 IMG_UINT32 ui323DCmdSize,
430 IMG_PBYTE pui83DDMCmd,
431 IMG_UINT32 ui32ExtJobRef,
432 IMG_BOOL bLastTAInScene,
437 IMG_UINT32 ui32PDumpFlags,
438 RGX_RTDATA_CLEANUP_DATA *psRTDataCleanup,
439 RGX_ZSBUFFER_DATA *psZBuffer,
440 RGX_ZSBUFFER_DATA *psSBuffer,
441 IMG_BOOL bCommitRefCountsTA,
442 IMG_BOOL bCommitRefCounts3D,
443 IMG_BOOL *pbCommittedRefCountsTA,
444 IMG_BOOL *pbCommittedRefCounts3D,
445 IMG_UINT32 ui32SyncPMRCount,
446 IMG_UINT32 *paui32SyncPMRFlags,
448 IMG_UINT32 ui32RenderTargetSize,
449 IMG_UINT32 ui32NumberOfDrawCalls,
450 IMG_UINT32 ui32NumberOfIndices,
451 IMG_UINT32 ui32NumberOfMRTs,
452 IMG_UINT64 ui64DeadlineInus);
455 PVRSRV_ERROR PVRSRVRGXSetRenderContextPriorityKM(CONNECTION_DATA *psConnection,
456 PVRSRV_DEVICE_NODE * psDevNode,
457 RGX_SERVER_RENDER_CONTEXT *psRenderContext,
458 IMG_UINT32 ui32Priority);
460 PVRSRV_ERROR PVRSRVRGXGetLastRenderContextResetReasonKM(RGX_SERVER_RENDER_CONTEXT *psRenderContext,
461 IMG_UINT32 *peLastResetReason,
462 IMG_UINT32 *pui32LastResetJobRef);
464 PVRSRV_ERROR PVRSRVRGXGetPartialRenderCountKM(DEVMEM_MEMDESC *psHWRTDataMemDesc,
465 IMG_UINT32 *pui32NumPartialRenders);
467 /* Debug - check if render context is waiting on a fence */
468 void CheckForStalledRenderCtxt(PVRSRV_RGXDEV_INFO *psDevInfo,
469 DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf,
470 void *pvDumpDebugFile);
472 /* Debug/Watchdog - check if client contexts are stalled */
473 IMG_UINT32 CheckForStalledClientRenderCtxt(PVRSRV_RGXDEV_INFO *psDevInfo);
475 #endif /* __RGXTA3D_H__ */