RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / server / include / physmem.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Physmem header
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Header for common entry point for creation of RAM backed PMR's
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 _SRVSRV_PHYSMEM_H_
45 #define _SRVSRV_PHYSMEM_H_
46
47 /* include/ */
48 #include "img_types.h"
49 #include "pvrsrv_error.h"
50 #include "pvrsrv_memallocflags.h"
51
52 /* services/server/include/ */
53 #include "pmr.h"
54 #include "pmr_impl.h"
55
56 /*
57  * PhysmemNewRamBackedPMR
58  *
59  * This function will create a RAM backed PMR using the device specific
60  * callback, this allows control at a per-devicenode level to select the
61  * memory source thus supporting mixed UMA/LMA systems.
62  *
63  * The size must be a multiple of page size.  The page size is
64  * specified in log2.  It should be regarded as a minimum contiguity
65  * of which the that the resulting memory must be a multiple.  It may
66  * be that this should be a fixed number.  It may be that the
67  * allocation size needs to be a multiple of some coarser "page size"
68  * than that specified in the page size argument.  For example, take
69  * an OS whose page granularity is a fixed 16kB, but the caller
70  * requests memory in page sizes of 4kB.  The request can be satisfied
71  * if and only if the SIZE requested is a multiple of 16kB.  If the
72  * arguments supplied are such that this OS cannot grant the request,
73  * PVRSRV_ERROR_INVALID_PARAMS will be returned.
74  *
75  * The caller should supply storage of a pointer.  Upon successful
76  * return a PMR object will have been created and a pointer to it
77  * returned in the PMROut argument.
78  *
79  * A PMR thusly created should be destroyed with PhysmemUnrefPMR.
80  *
81  * Note that this function may cause memory allocations and on some
82  * OSes this may cause scheduling events, so it is important that this
83  * function be called with interrupts enabled and in a context where
84  * scheduling events and memory allocations are permitted.
85  *
86  * The flags may be used by the implementation to change its behaviour
87  * if required.  The flags will also be stored in the PMR as immutable
88  * metadata and returned to mmu_common when it asks for it.
89  *
90  */
91 extern PVRSRV_ERROR
92 PhysmemNewRamBackedPMR(PVRSRV_DEVICE_NODE *psDevNode,
93                        IMG_DEVMEM_SIZE_T uiSize,
94                        IMG_DEVMEM_SIZE_T uiChunkSize,
95                        IMG_UINT32 ui32NumPhysChunks,
96                        IMG_UINT32 ui32NumVirtChunks,
97                        IMG_BOOL *pabMappingTable,
98                        IMG_UINT32 uiLog2PageSize,
99                        PVRSRV_MEMALLOCFLAGS_T uiFlags,
100                        PMR **ppsPMROut);
101
102 #endif /* _SRVSRV_PHYSMEM_H_ */