Merge tag 'lsk-v3.10-android-15.02'
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_memory_types.h
1 /*
2  * Copyright (C) 2013-2014 ARM Limited. All rights reserved.
3  * 
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  * 
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 #ifndef __MALI_MEMORY_TYPES_H__
12 #define __MALI_MEMORY_TYPES_H__
13
14 #if defined(CONFIG_MALI400_UMP)
15 #include "ump_kernel_interface.h"
16 #endif
17
18 typedef u32 mali_address_t;
19
20 typedef enum mali_mem_type {
21         MALI_MEM_OS,
22         MALI_MEM_EXTERNAL,
23         MALI_MEM_DMA_BUF,
24         MALI_MEM_UMP,
25         MALI_MEM_BLOCK,
26         MALI_MEM_TYPE_MAX,
27 } mali_mem_type;
28
29 typedef struct mali_mem_os_mem {
30         struct list_head pages;
31         u32 count;
32 } mali_mem_os_mem;
33
34 typedef struct mali_mem_dma_buf {
35 #if defined(CONFIG_DMA_SHARED_BUFFER)
36         struct mali_dma_buf_attachment *attachment;
37 #endif
38 } mali_mem_dma_buf;
39
40 typedef struct mali_mem_external {
41         dma_addr_t phys;
42         u32 size;
43 } mali_mem_external;
44
45 typedef struct mali_mem_ump {
46 #if defined(CONFIG_MALI400_UMP)
47         ump_dd_handle handle;
48 #endif
49 } mali_mem_ump;
50
51 typedef struct block_allocator_allocation {
52         /* The list will be released in reverse order */
53         struct block_info *last_allocated;
54         u32 mapping_length;
55         struct block_allocator *info;
56 } block_allocator_allocation;
57
58 typedef struct mali_mem_block_mem {
59         block_allocator_allocation mem;
60 } mali_mem_block_mem;
61
62 typedef struct mali_mem_virt_mali_mapping {
63         mali_address_t addr; /* Virtual Mali address */
64         u32 properties;      /* MMU Permissions + cache, must match MMU HW */
65 } mali_mem_virt_mali_mapping;
66
67 typedef struct mali_mem_virt_cpu_mapping {
68         void __user *addr;
69         u32 ref;
70 } mali_mem_virt_cpu_mapping;
71
72 #define MALI_MEM_ALLOCATION_VALID_MAGIC 0xdeda110c
73 #define MALI_MEM_ALLOCATION_FREED_MAGIC 0x10101010
74
75 typedef struct mali_mem_allocation {
76         MALI_DEBUG_CODE(u32 magic);
77         mali_mem_type type;                /**< Type of memory */
78         int id;                            /**< ID in the descriptor map for this allocation */
79
80         u32 size;                          /**< Size of the allocation */
81         u32 flags;                         /**< Flags for this allocation */
82
83         struct mali_session_data *session; /**< Pointer to session that owns the allocation */
84
85         /* Union selected by type. */
86         union {
87                 mali_mem_os_mem os_mem;       /**< MALI_MEM_OS */
88                 mali_mem_external ext_mem;    /**< MALI_MEM_EXTERNAL */
89                 mali_mem_dma_buf dma_buf;     /**< MALI_MEM_DMA_BUF */
90                 mali_mem_ump ump_mem;         /**< MALI_MEM_UMP */
91                 mali_mem_block_mem block_mem; /**< MALI_MEM_BLOCK */
92         };
93
94         mali_mem_virt_cpu_mapping cpu_mapping; /**< CPU mapping */
95         mali_mem_virt_mali_mapping mali_mapping; /**< Mali mapping */
96 } mali_mem_allocation;
97
98 #define MALI_MEM_FLAG_MALI_GUARD_PAGE (1 << 0)
99 #define MALI_MEM_FLAG_DONT_CPU_MAP    (1 << 1)
100
101 #endif /* __MALI_MEMORY_TYPES__ */