sync_checkpoint_internal.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /*************************************************************************/ /*!
  2. @File
  3. @Title Services internal synchronisation checkpoint interface header
  4. @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  5. @Description Defines the internal server interface for services
  6. synchronisation checkpoints.
  7. @License Dual MIT/GPLv2
  8. The contents of this file are subject to the MIT license as set out below.
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights
  12. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. Alternatively, the contents of this file may be used under the terms of
  18. the GNU General Public License Version 2 ("GPL") in which case the provisions
  19. of GPL are applicable instead of those above.
  20. If you wish to allow use of your version of this file only under the terms of
  21. GPL, and not to allow others to use your version of this file under the terms
  22. of the MIT license, indicate your decision by deleting the provisions above
  23. and replace them with the notice and other provisions required by GPL as set
  24. out in the file called "GPL-COPYING" included in this distribution. If you do
  25. not delete the provisions above, a recipient may use your version of this file
  26. under the terms of either the MIT license or GPL.
  27. This License is also included in this distribution in the file called
  28. "MIT-COPYING".
  29. EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  30. PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  31. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  32. PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  33. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  34. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  35. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  36. */ /**************************************************************************/
  37. #ifndef SYNC_CHECKPOINT_INTERNAL_H
  38. #define SYNC_CHECKPOINT_INTERNAL_H
  39. #include "img_types.h"
  40. #include "opaque_types.h"
  41. #include "sync_checkpoint_external.h"
  42. #include "sync_checkpoint.h"
  43. #include "ra.h"
  44. #include "dllist.h"
  45. #include "lock.h"
  46. #include "devicemem.h"
  47. #include "rgx_fwif_shared.h"
  48. #include "rgx_fwif_km.h"
  49. struct SYNC_CHECKPOINT_RECORD;
  50. /*
  51. Private structures
  52. */
  53. typedef struct _SYNC_CHECKPOINT_CONTEXT_CTL_ _SYNC_CHECKPOINT_CONTEXT_CTL, *_PSYNC_CHECKPOINT_CONTEXT_CTL;
  54. typedef struct _SYNC_CHECKPOINT_CONTEXT_
  55. {
  56. PPVRSRV_DEVICE_NODE psDevNode;
  57. IMG_CHAR azName[PVRSRV_SYNC_NAME_LENGTH]; /*!< Name of the RA */
  58. RA_ARENA *psSubAllocRA; /*!< RA context */
  59. IMG_CHAR azSpanName[PVRSRV_SYNC_NAME_LENGTH]; /*!< Name of the span RA */
  60. RA_ARENA *psSpanRA; /*!< RA used for span management of SubAllocRA */
  61. ATOMIC_T hRefCount; /*!< Ref count for this context */
  62. ATOMIC_T hCheckpointCount; /*!< Checkpoint count for this context */
  63. POS_LOCK hLock;
  64. _PSYNC_CHECKPOINT_CONTEXT_CTL psContextCtl;
  65. #if defined(PDUMP)
  66. DLLIST_NODE sSyncCheckpointBlockListHead; /*!< List head for the sync chkpt blocks in this context*/
  67. POS_LOCK hSyncCheckpointBlockListLock; /*!< sync chkpt blocks list lock*/
  68. DLLIST_NODE sListNode; /*!< List node for the sync chkpt context list*/
  69. #endif
  70. } _SYNC_CHECKPOINT_CONTEXT;
  71. typedef struct _SYNC_CHECKPOINT_BLOCK_
  72. {
  73. ATOMIC_T hRefCount; /*!< Ref count for this sync block */
  74. POS_LOCK hLock;
  75. _SYNC_CHECKPOINT_CONTEXT *psContext; /*!< Our copy of the services connection */
  76. PPVRSRV_DEVICE_NODE psDevNode;
  77. IMG_UINT32 ui32SyncBlockSize; /*!< Size of the sync checkpoint block */
  78. IMG_UINT32 ui32FirmwareAddr; /*!< Firmware address */
  79. DEVMEM_MEMDESC *hMemDesc; /*!< DevMem allocation for block */
  80. volatile IMG_UINT32 *pui32LinAddr; /*!< Server-code CPU mapping */
  81. IMG_UINT64 uiSpanBase; /*!< Base of this import (FW DevMem) in the span RA */
  82. #if defined(PDUMP)
  83. DLLIST_NODE sListNode; /*!< List node for the sync chkpt blocks */
  84. #endif
  85. } SYNC_CHECKPOINT_BLOCK;
  86. typedef struct SYNC_CHECKPOINT_RECORD* PSYNC_CHECKPOINT_RECORD_HANDLE;
  87. typedef struct _SYNC_CHECKPOINT_
  88. {
  89. //_SYNC_CHECKPOINT_CONTEXT *psContext; /*!< pointer to the parent context of this checkpoint */
  90. /* A sync checkpoint is assigned a unique ID, to avoid any confusion should
  91. * the same memory be re-used later for a different checkpoint
  92. */
  93. IMG_UINT32 ui32UID; /*!< Unique ID assigned to sync checkpoint (to distinguish checkpoints if memory is re-used)*/
  94. ATOMIC_T hRefCount; /*!< Ref count for this sync */
  95. ATOMIC_T hEnqueuedCCBCount; /*!< Num times sync has been put in CCBs */
  96. SYNC_CHECKPOINT_BLOCK *psSyncCheckpointBlock; /*!< Synchronisation block this checkpoint is allocated on */
  97. IMG_UINT64 uiSpanAddr; /*!< Span address of the sync */
  98. volatile SYNC_CHECKPOINT_FW_OBJ *psSyncCheckpointFwObj; /*!< CPU view of the data held in the sync block */
  99. PRGXFWIF_UFO_ADDR sCheckpointUFOAddr; /*!< PRGXFWIF_UFO_ADDR struct used to pass update address to FW */
  100. IMG_CHAR azName[PVRSRV_SYNC_NAME_LENGTH]; /*!< Name of the checkpoint */
  101. PVRSRV_TIMELINE hTimeline; /*!< Timeline on which this sync checkpoint was created */
  102. IMG_UINT32 ui32ValidationCheck;
  103. IMG_PID uiProcess; /*!< The Process ID of the process which created this sync checkpoint */
  104. PSYNC_CHECKPOINT_RECORD_HANDLE hRecord; /*!< Sync record handle */
  105. DLLIST_NODE sListNode; /*!< List node for the global sync chkpt list */
  106. DLLIST_NODE sDeferredFreeListNode; /*!< List node for the deferred free sync chkpt list */
  107. IMG_UINT32 ui32FWAddr; /*!< FWAddr stored at sync checkpoint alloc time */
  108. PDUMP_FLAGS_T ui32PDumpFlags; /*!< Pdump Capture mode to be used for POL*/
  109. } _SYNC_CHECKPOINT;
  110. typedef struct _SYNC_CHECKPOINT_SIGNAL_
  111. {
  112. _SYNC_CHECKPOINT asSyncCheckpoint; /*!< Store sync checkpt for deferred signal */
  113. IMG_UINT32 ui32Status; /*!< sync checkpt status signal/errored */
  114. } _SYNC_CHECKPOINT_DEFERRED_SIGNAL;
  115. #define GET_CP_CB_NEXT_IDX(_curridx) (((_curridx) + 1) % SYNC_CHECKPOINT_MAX_DEFERRED_SIGNAL)
  116. #define GET_CP_CB_BASE(_idx) (IMG_OFFSET_ADDR(psDevNode->pui8DeferredSyncCPSignal, \
  117. ((_idx) * sizeof(_SYNC_CHECKPOINT_DEFERRED_SIGNAL))))
  118. /*************************************************************************/ /*!
  119. @Function SyncCheckpointGetFirmwareAddr
  120. @Description .
  121. @Input psSyncCheckpoint Synchronisation checkpoint to get
  122. the firmware address of
  123. @Return The firmware address of the sync checkpoint
  124. */
  125. /*****************************************************************************/
  126. IMG_UINT32
  127. SyncCheckpointGetFirmwareAddr(PSYNC_CHECKPOINT psSyncCheckpoint);
  128. /*************************************************************************/ /*!
  129. @Function SyncCheckpointCCBEnqueued
  130. @Description Increment the CCB enqueued reference count for a
  131. synchronisation checkpoint. This indicates how many FW
  132. operations (checks/update) have been placed into CCBs for the
  133. sync checkpoint.
  134. When the FW services these operation, it increments its own
  135. reference count. When these two values are equal, we know
  136. there are not outstanding FW operating for the checkpoint
  137. in any CCB.
  138. @Input psSyncCheckpoint Synchronisation checkpoint for which
  139. to increment the enqueued reference
  140. count
  141. @Return None
  142. */
  143. /*****************************************************************************/
  144. void
  145. SyncCheckpointCCBEnqueued(PSYNC_CHECKPOINT psSyncCheckpoint);
  146. /*************************************************************************/ /*!
  147. @Function SyncCheckpointGetEnqueuedCount
  148. @Description .
  149. @Input psSyncCheckpoint Synchronisation checkpoint to get
  150. the enqueued count of
  151. @Return The enqueued count of the sync checkpoint
  152. (i.e. the number of FW operations (checks or updates)
  153. currently enqueued in CCBs for the sync checkpoint)
  154. */
  155. /*****************************************************************************/
  156. IMG_UINT32
  157. SyncCheckpointGetEnqueuedCount(PSYNC_CHECKPOINT psSyncCheckpoint);
  158. /*************************************************************************/ /*!
  159. @Function SyncCheckpointGetReferenceCount
  160. @Description .
  161. @Input psSyncCheckpoint Synchronisation checkpoint to get
  162. the reference count of
  163. @Return The host reference count of the sync checkpoint
  164. */
  165. /*****************************************************************************/
  166. IMG_UINT32
  167. SyncCheckpointGetReferenceCount(PSYNC_CHECKPOINT psSyncCheckpoint);
  168. /*************************************************************************/ /*!
  169. @Function SyncCheckpointGetCreator
  170. @Description .
  171. @Input psSyncCheckpoint Synchronisation checkpoint to get
  172. the creating process of
  173. @Return The process id of the process which created this sync checkpoint.
  174. */
  175. /*****************************************************************************/
  176. IMG_PID
  177. SyncCheckpointGetCreator(PSYNC_CHECKPOINT psSyncCheckpoint);
  178. /*************************************************************************/ /*!
  179. @Function SyncCheckpointGetId
  180. @Description .
  181. @Input psSyncCheckpoint Synchronisation checkpoint to get
  182. the unique Id of
  183. @Return The unique Id of the sync checkpoint
  184. */
  185. /*****************************************************************************/
  186. IMG_UINT32
  187. SyncCheckpointGetId(PSYNC_CHECKPOINT psSyncCheckpoint);
  188. /*************************************************************************/ /*!
  189. @Function SyncCheckpointGetTimeline
  190. @Description .
  191. @Input psSyncCheckpoint Synchronisation checkpoint to get
  192. the parent timeline of
  193. @Return The parent timeline of the sync checkpoint
  194. */
  195. /*****************************************************************************/
  196. PVRSRV_TIMELINE
  197. SyncCheckpointGetTimeline(PSYNC_CHECKPOINT psSyncCheckpoint);
  198. /*************************************************************************/ /*!
  199. @Function SyncCheckpointGetRGXFWIFUFOAddr
  200. @Description .
  201. @Input psSyncCheckpoint Synchronisation checkpoint to get
  202. the PRGXFWIF_UFO_ADDR of
  203. @Return The PRGXFWIF_UFO_ADDR of the sync checkpoint, used when
  204. providing the update in server kick code.
  205. */
  206. /*****************************************************************************/
  207. PRGXFWIF_UFO_ADDR*
  208. SyncCheckpointGetRGXFWIFUFOAddr(PSYNC_CHECKPOINT psSyncCheckpoint);
  209. #if !defined(SUPPORT_NATIVE_FENCE_SYNC)
  210. /*************************************************************************/ /*!
  211. @Function SyncCheckpointGetAssociatedDevice
  212. @Description .
  213. @Input psSyncCheckpointContext Synchronisation Checkpoint context
  214. to get the device node of
  215. @Return The PVRSRV_DEVICE_NODE of the device on which the sync
  216. checkpoint context was created.
  217. */
  218. /*****************************************************************************/
  219. PPVRSRV_DEVICE_NODE
  220. SyncCheckpointGetAssociatedDevice(PSYNC_CHECKPOINT_CONTEXT psSyncCheckpointContext);
  221. #endif /* !defined(SUPPORT_NATIVE_FENCE_SYNC) */
  222. #endif /* SYNC_CHECKPOINT_INTERNAL_H */