RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / devicemem_typedefs.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Device Memory Management
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Client side part of device memory management -- this file
6                 is forked from new_devmem_allocation.h as this one has to
7                 reside in the top level include so that client code is able
8                 to make use of the typedefs.
9 @License        Dual MIT/GPLv2
10
11 The contents of this file are subject to the MIT license as set out below.
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in
21 all copies or substantial portions of the Software.
22
23 Alternatively, the contents of this file may be used under the terms of
24 the GNU General Public License Version 2 ("GPL") in which case the provisions
25 of GPL are applicable instead of those above.
26
27 If you wish to allow use of your version of this file only under the terms of
28 GPL, and not to allow others to use your version of this file under the terms
29 of the MIT license, indicate your decision by deleting the provisions above
30 and replace them with the notice and other provisions required by GPL as set
31 out in the file called "GPL-COPYING" included in this distribution. If you do
32 not delete the provisions above, a recipient may use your version of this file
33 under the terms of either the MIT license or GPL.
34
35 This License is also included in this distribution in the file called
36 "MIT-COPYING".
37
38 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
39 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
40 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
41 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
42 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
43 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 */ /**************************************************************************/
46
47 #ifndef DEVICEMEM_TYPEDEFS_H
48 #define DEVICEMEM_TYPEDEFS_H
49
50 #include <powervr/mem_types.h>
51 #include "img_types.h"
52 #include "pvrsrv_memallocflags.h"
53
54 typedef struct _DEVMEM_CONTEXT_ DEVMEM_CONTEXT;         /*!< Convenience typedef for struct _DEVMEM_CONTEXT_ */
55 typedef struct _DEVMEM_HEAP_ DEVMEM_HEAP;                       /*!< Convenience typedef for struct _DEVMEM_HEAP_ */
56 typedef struct _DEVMEM_MEMDESC_ DEVMEM_MEMDESC;         /*!< Convenience typedef for struct _DEVMEM_MEMDESC_ */
57 typedef struct _DEVMEM_PAGELIST_ DEVMEM_PAGELIST;       /*!< Convenience typedef for struct _DEVMEM_PAGELIST_ */
58 typedef PVRSRV_MEMALLOCFLAGS_T DEVMEM_FLAGS_T;          /*!< Conveneince typedef for PVRSRV_MEMALLOCFLAGS_T */
59
60 typedef IMG_HANDLE /* FIXME: should be a SID */ DEVMEM_EXPORTHANDLE; /*!< Typedef for DeviceMem Export Handle */
61 typedef IMG_UINT64 DEVMEM_EXPORTKEY;                                /*!< Typedef for DeviceMem Export Key */
62 typedef IMG_DEVMEM_SIZE_T DEVMEM_SIZE_T;                            /*!< Typedef for DeviceMem SIZE_T */
63 typedef IMG_DEVMEM_LOG2ALIGN_T DEVMEM_LOG2ALIGN_T;                  /*!< Typedef for DeviceMem LOG2 Alignment */
64
65 typedef struct _DEVMEMX_PHYS_MEMDESC_ DEVMEMX_PHYSDESC;    /*!< Convenience typedef for DevmemX physical */
66 typedef struct _DEVMEMX_VIRT_MEMDESC_ DEVMEMX_VIRTDESC;    /*!< Convenience typedef for DevmemX virtual */
67
68 /*! calling code needs all the info in this struct, to be able to pass it around */
69 typedef struct
70 {
71     /*! A handle to the PMR.  Should be a SID.  FIXME: decide whether
72        this is right... as the PMR would have to be a cross-process
73        handle */
74     IMG_HANDLE hPMRExportHandle;
75     /*! The "key" to prove we have authorization to use this PMR */
76     IMG_UINT64 uiPMRExportPassword;
77     /*! Size and alignment properties for this PMR.  Note, these
78        numbers are not trusted in kernel, but we need to cache them
79        client-side in order to allocate from the VM arena.  The kernel
80        will know the actual alignment and size of the PMR and thus
81        would prevent client code from breaching security here.  Ditto
82        for physmem granularity (aka page size) if this is different
83        from alignment */
84     IMG_DEVMEM_SIZE_T uiSize;
85     /*! We call this "contiguity guarantee" to be more precise than
86        calling it "alignment" or "page size", terms which may seem
87        similar but have different emphasis.  The number reported here
88        is the minimum contiguity guarantee from the creator of the
89        PMR.  Now, there is no requirement to allocate that coarsely
90        from the RA.  The alignment given to the RA simply needs to be
91        at least as coarse as the device page size for the heap we
92        ultimately intend to map into.  What is important is that the
93        device MMU data page size is not greater than the minimum
94        contiguity guarantee from the PMR.  This value is reported to
95        the client in order that it can choose to make early checks and
96        perhaps decide which heap (in a variable page size scenario) it
97        would be safe to map this PMR into.  For convenience, the
98        client may choose to use this argument as the alignment of the
99        virtual range he chooses to allocate, but this is _not_
100        necessary and in many cases would be able to get away with a
101        finer alignment, should the heap into which this PMR will be
102        mapped support it. */
103     IMG_DEVMEM_LOG2ALIGN_T uiLog2ContiguityGuarantee;
104 } DEVMEM_EXPORTCOOKIE;
105
106 /* Enum that describes the operation associated with changing sparse memory*/
107 typedef enum Resize {
108         SPARSE_RESIZE_NONE = 0,
109
110         /* This should be set to indicate the change needs allocation */
111         SPARSE_RESIZE_ALLOC = 1,
112
113         /* This should be set to indicate the change needs free */
114         SPARSE_RESIZE_FREE = 2,
115
116         SPARSE_RESIZE_BOTH = (SPARSE_RESIZE_ALLOC | SPARSE_RESIZE_FREE),
117
118         /* This should be set to silently swap underlying physical memory
119          * without disturbing its device or cpu virtual maps
120          * This flag is not supported in the case of PDUMP and could lead to
121          * PDUMP panic when used */
122         SPARSE_REMAP_MEM = 4,
123
124         /* Should be set to get the sparse changes appear in cpu virtual map */
125         SPARSE_MAP_CPU_ADDR = 8
126 }SPARSE_MEM_RESIZE_FLAGS;
127
128 /* To use with DevmemSubAllocate() as the default factor if no
129  * over-allocation is desired. */
130 #define DEVMEM_NO_PRE_ALLOCATE_MULTIPLIER 1
131
132 #endif /* #ifndef DEVICEMEM_TYPEDEFS_H */
133