RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / devicemem_history_server.h
1 /*************************************************************************/ /*!
2 @File                   devicemem_history_server.h
3 @Title          Resource Information abstraction
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Devicemem History functions
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 #ifndef _DEVICEMEM_HISTORY_SERVER_H_
45 #define _DEVICEMEM_HISTORY_SERVER_H_
46
47 #include "img_defs.h"
48 #include "mm_common.h"
49 #include "pvrsrv_error.h"
50 #include "rgxmem.h"
51
52 extern PVRSRV_ERROR
53 DevicememHistoryInitKM(void);
54
55 extern void
56 DevicememHistoryDeInitKM(void);
57
58 extern PVRSRV_ERROR
59 DevicememHistoryMapKM(IMG_DEV_VIRTADDR sDevVAddr, size_t uiSize, const char szText[DEVICEMEM_HISTORY_TEXT_BUFSZ]);
60
61 extern PVRSRV_ERROR
62 DevicememHistoryUnmapKM(IMG_DEV_VIRTADDR sDevVAddr, size_t uiSize, const char szText[DEVICEMEM_HISTORY_TEXT_BUFSZ]);
63
64
65 PVRSRV_ERROR DevicememHistoryMapNewKM(PMR *psPMR,
66                                                         IMG_UINT32 ui32Offset,
67                                                         IMG_DEV_VIRTADDR sDevVAddr,
68                                                         IMG_DEVMEM_SIZE_T uiSize,
69                                                         const char szName[DEVICEMEM_HISTORY_TEXT_BUFSZ],
70                                                         IMG_UINT32 ui32PageSize,
71                                                         IMG_UINT32 ui32AllocationIndex,
72                                                         IMG_UINT32 *pui32AllocationIndexOut);
73
74 PVRSRV_ERROR DevicememHistoryUnmapNewKM(PMR *psPMR,
75                                                         IMG_UINT32 ui32Offset,
76                                                         IMG_DEV_VIRTADDR sDevVAddr,
77                                                         IMG_DEVMEM_SIZE_T uiSize,
78                                                         const char szName[DEVICEMEM_HISTORY_TEXT_BUFSZ],
79                                                         IMG_UINT32 ui32PageSize,
80                                                         IMG_UINT32 ui32AllocationIndex,
81                                                         IMG_UINT32 *pui32AllocationIndexOut);
82
83 PVRSRV_ERROR DevicememHistoryMapVRangeKM(IMG_DEV_VIRTADDR sBaseDevVAddr,
84                                                         IMG_UINT32 ui32StartPage,
85                                                         IMG_UINT32 ui32NumPages,
86                                                         IMG_DEVMEM_SIZE_T uiAllocSize,
87                                                         const IMG_CHAR szName[DEVICEMEM_HISTORY_TEXT_BUFSZ],
88                                                         IMG_UINT32 ui32Log2PageSize,
89                                                         IMG_UINT32 ui32AllocationIndex,
90                                                         IMG_UINT32 *ui32AllocationIndexOut);
91
92 PVRSRV_ERROR DevicememHistoryUnmapVRangeKM(IMG_DEV_VIRTADDR sBaseDevVAddr,
93                                                         IMG_UINT32 ui32StartPage,
94                                                         IMG_UINT32 ui32NumPages,
95                                                         IMG_DEVMEM_SIZE_T uiAllocSize,
96                                                         const IMG_CHAR szName[DEVICEMEM_HISTORY_TEXT_BUFSZ],
97                                                         IMG_UINT32 ui32Log2PageSize,
98                                                         IMG_UINT32 ui32AllocationIndex,
99                                                         IMG_UINT32 *ui32AllocationIndexOut);
100
101 PVRSRV_ERROR DevicememHistorySparseChangeKM(PMR *psPMR,
102                                                         IMG_UINT32 ui32Offset,
103                                                         IMG_DEV_VIRTADDR sDevVAddr,
104                                                         IMG_DEVMEM_SIZE_T uiSize,
105                                                         const char szName[DEVICEMEM_HISTORY_TEXT_BUFSZ],
106                                                         IMG_UINT32 ui32PageSize,
107                                                         IMG_UINT32 ui32AllocPageCount,
108                                                         IMG_UINT32 *paui32AllocPageIndices,
109                                                         IMG_UINT32 ui32FreePageCount,
110                                                         IMG_UINT32 *pauiFreePageIndices,
111                                                         IMG_UINT32 AllocationIndex,
112                                                         IMG_UINT32 *pui32AllocationIndexOut);
113
114 /* used when the PID does not matter */
115 #define DEVICEMEM_HISTORY_PID_ANY 0xFFFFFFFE
116
117 typedef struct _DEVICEMEM_HISTORY_QUERY_IN_
118 {
119         IMG_PID uiPID;
120         IMG_DEV_VIRTADDR sDevVAddr;
121 } DEVICEMEM_HISTORY_QUERY_IN;
122
123 /* Store up to 4 results for a lookup. In the case of the faulting page being
124  * re-mapped between the page fault occurring on HW and the page fault analysis
125  * being done, the second result entry will show the allocation being unmapped.
126  * A further 2 entries are added to cater for multiple buffers in the same page.
127  */
128 #define DEVICEMEM_HISTORY_QUERY_OUT_MAX_RESULTS 4
129
130 typedef struct _DEVICEMEM_HISTORY_QUERY_OUT_RESULT_
131 {
132         IMG_CHAR szString[DEVICEMEM_HISTORY_TEXT_BUFSZ];
133         IMG_DEV_VIRTADDR sBaseDevVAddr;
134         size_t uiSize;
135         IMG_BOOL bMap;
136         IMG_BOOL bRange;
137         IMG_BOOL bAll;
138         IMG_UINT64 ui64When;
139         IMG_UINT64 ui64Age;
140         /* info for sparse map/unmap operations (i.e. bRange=IMG_TRUE) */
141         IMG_UINT32 ui32StartPage;
142         IMG_UINT32 ui32PageCount;
143         IMG_DEV_VIRTADDR sMapStartAddr;
144         IMG_DEV_VIRTADDR sMapEndAddr;
145         RGXMEM_PROCESS_INFO sProcessInfo;
146 } DEVICEMEM_HISTORY_QUERY_OUT_RESULT;
147
148 typedef struct _DEVICEMEM_HISTORY_QUERY_OUT_
149 {
150         IMG_UINT32 ui32NumResults;
151         /* result 0 is the newest */
152         DEVICEMEM_HISTORY_QUERY_OUT_RESULT sResults[DEVICEMEM_HISTORY_QUERY_OUT_MAX_RESULTS];
153 } DEVICEMEM_HISTORY_QUERY_OUT;
154
155 extern IMG_BOOL
156 DevicememHistoryQuery(DEVICEMEM_HISTORY_QUERY_IN *psQueryIn,
157                       DEVICEMEM_HISTORY_QUERY_OUT *psQueryOut,
158                       IMG_UINT32 ui32PageSizeBytes,
159                       IMG_BOOL bMatchAnyAllocInPage);
160
161 #endif