RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / sync_checkpoint_internal.h
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
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
44
45 #ifndef __SYNC_CHECKPOINT__
46 #define __SYNC_CHECKPOINT__
47
48 #include "img_types.h"
49 #include "sync_checkpoint_internal_fw.h"
50 #include "sync_checkpoint.h"
51 #include "ra.h"
52 #include "dllist.h"
53 #include "lock.h"
54 #include "devicemem.h"
55
56 typedef struct _PVRSRV_DEVICE_NODE_ PVRSRV_DEVICE_NODE;
57
58 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
59 struct SYNC_CHECKPOINT_RECORD;
60 #endif
61
62 /*
63         Private structures
64 */
65 #define SYNC_CHECKPOINT_NAME_SIZE       SYNC_CHECKPOINT_MAX_CLASS_NAME_LEN
66
67 typedef struct _SYNC_CHECKPOINT_CONTEXT_
68 {
69         PVRSRV_DEVICE_NODE     *psDevNode;
70         IMG_CHAR               azName[SYNC_CHECKPOINT_NAME_SIZE];     /*!< Name of the RA */
71         RA_ARENA               *psSubAllocRA;                         /*!< RA context */
72         IMG_CHAR               azSpanName[SYNC_CHECKPOINT_NAME_SIZE]; /*!< Name of the span RA */
73         RA_ARENA               *psSpanRA;                             /*!< RA used for span management of SubAllocRA */
74         ATOMIC_T               hRefCount;                             /*!< Ref count for this context */
75         ATOMIC_T               hCheckpointCount;                      /*!< Checkpoint count for this context */
76         POS_LOCK               hCheckpointListLock;                   /*!< Checkpoint list lock */
77         DLLIST_NODE            sCheckpointList;                       /*!< List of checkpoints created on this context */
78         IMG_HANDLE             hCheckpointNotify;                     /*!< Handle for debug notifier callback */
79 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
80         POS_LOCK               hCheckpointRecordLock;
81         DLLIST_NODE            sCheckpointRecordList;
82         struct SYNC_CHECKPOINT_RECORD *apsCheckpointRecordsFreed[PVRSRV_FULL_SYNC_TRACKING_HISTORY_LEN];
83         IMG_UINT32             uiCheckpointRecordFreeIdx;
84         IMG_HANDLE             hCheckpointRecordNotify;
85 #endif
86 } _SYNC_CHECKPOINT_CONTEXT;
87
88 typedef struct _SYNC_CHECKPOINT_BLOCK_
89 {
90         ATOMIC_T                  hRefCount;                  /*!< Ref count for this sync block */
91         _SYNC_CHECKPOINT_CONTEXT  *psContext;                 /*!< Our copy of the services connection */
92         PVRSRV_DEVICE_NODE        *psDevNode;
93         IMG_UINT32                ui32SyncBlockSize;          /*!< Size of the sync checkpoint block */
94         IMG_UINT32                ui32FirmwareAddr;           /*!< Firmware address */
95         DEVMEM_MEMDESC            *hMemDesc;                  /*!< DevMem allocation for block */
96         volatile IMG_UINT32       *pui32LinAddr;              /*!< Server-code CPU mapping */
97         IMG_UINT64                uiSpanBase;                 /*!< Base of this import (FW DevMem) in the span RA */
98         DLLIST_NODE               sListNode;                  /*!< List node for the sync chkpt block list */
99 } SYNC_CHECKPOINT_BLOCK;
100
101 typedef struct SYNC_CHECKPOINT_RECORD* PSYNC_CHECKPOINT_RECORD_HANDLE;
102
103 typedef struct _SYNC_CHECKPOINT_
104 {
105         /* A sync checkpoint is assigned a unique ID, to avoid any confusion should
106          * the same memory be re-used later for a different checkpoint
107          */
108         IMG_UINT32                      ui32UID;                /*!< Unique ID assigned to sync checkpoint (to distinguish checkpoints if memory is re-used)*/
109         ATOMIC_T                        hRefCount;              /*!< Ref count for this sync */
110         ATOMIC_T                        hEnqueuedCCBCount;      /*!< Num times sync has been put in CCBs */
111         SYNC_CHECKPOINT_BLOCK           *psSyncCheckpointBlock; /*!< Synchronisation block this checkpoint is allocated on */
112         IMG_UINT64                      uiSpanAddr;             /*!< Span address of the sync */
113         volatile _SYNC_CHECKPOINT_FW_OBJ *psSyncCheckpointFwObj; /*!< CPU view of the data held in the sync block */
114         IMG_CHAR                        azName[SYNC_CHECKPOINT_NAME_SIZE]; /*!< Name of the checkpoint */
115 #if defined(PVRSRV_ENABLE_FULL_SYNC_TRACKING)
116         PSYNC_CHECKPOINT_RECORD_HANDLE  hRecord;                /*!< Sync record handle */
117 #endif
118         DLLIST_NODE                     sListNode;              /*!< List node for the sync chkpt list */
119 } _SYNC_CHECKPOINT;
120
121 /*************************************************************************/ /*!
122 @Function       SyncCheckpointGetFirmwareAddr
123
124 @Description    .
125
126 @Input          psSyncCheckpoint        Synchronisation checkpoint to get
127                                         the firmware address of
128
129 @Return         None
130
131 */
132 /*****************************************************************************/
133 IMG_UINT32
134 SyncCheckpointGetFirmwareAddr(PSYNC_CHECKPOINT psSyncCheckpoint);
135
136 /*************************************************************************/ /*!
137 @Function       SyncCheckpointCCBEnqueued
138
139 @Description    Increment the CCB enqueued reference count for a
140                 synchronisation checkpoint. This indicates how many FW
141                 operations (checks/update) have been placed into CCBs for the
142                 sync checkpoint.
143                 When the FW services these operation, it increments its own
144                 reference count. When these two values are equal, we know
145                 there are not outstanding FW operating for the checkpoint
146                 in any CCB.
147
148 @Input          psSyncCheckpoint        Synchronisation checkpoint for which
149                                         to increment the enqueued reference
150                                         count
151
152 @Return         None
153
154 */
155 /*****************************************************************************/
156 void
157 SyncCheckpointCCBEnqueued(PSYNC_CHECKPOINT psSyncCheckpoint);
158
159 #endif  /* __SYNC_CHECKPOINT__ */