MALI: rockchip: upgrade utgard DDK to r6p0-01rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / linux / mali_memory_swap_alloc.h
1 /*\r
2  * Copyright (C) 2013-2015 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  */\r
10 \r
11 #ifndef __MALI_MEMORY_SWAP_ALLOC_H__\r
12 #define __MALI_MEMORY_SWAP_ALLOC_H__\r
13 \r
14 #include "mali_osk.h"\r
15 #include "mali_session.h"\r
16 \r
17 #include "mali_memory_types.h"\r
18 #include "mali_pp_job.h"\r
19 \r
20 /**\r
21  * Initialize memory swapping module.\r
22  */\r
23 _mali_osk_errcode_t mali_mem_swap_init(void);\r
24 \r
25 void mali_mem_swap_term(void);\r
26 \r
27 /**\r
28  * Return global share memory file to other modules.\r
29  */\r
30 struct file *mali_mem_swap_get_global_swap_file(void);\r
31 \r
32 /**\r
33  * Unlock the given memory backend and pages in it could be swapped out by kernel.\r
34  */\r
35 void mali_mem_swap_unlock_single_mem_backend(mali_mem_backend *mem_bkend);\r
36 \r
37 /**\r
38  * Remove the given memory backend from global swap list.\r
39  */\r
40 void mali_memory_swap_list_backend_delete(mali_mem_backend *mem_bkend);\r
41 \r
42 /**\r
43  * Add the given memory backend to global swap list.\r
44  */\r
45 void mali_memory_swap_list_backend_add(mali_mem_backend *mem_bkend);\r
46 \r
47 /**\r
48  * Allocate 1 index from bitmap used as page index in global swap file.\r
49  */\r
50 u32 mali_mem_swap_idx_alloc(void);\r
51 \r
52 void mali_mem_swap_idx_free(u32 idx);\r
53 \r
54 /**\r
55  * Allocate a new swap item without page index.\r
56  */\r
57 struct mali_swap_item *mali_mem_swap_alloc_swap_item(void);\r
58 \r
59 /**\r
60  * Free a swap item, truncate the corresponding space in page cache and free index of page.\r
61  */\r
62 void mali_mem_swap_free_swap_item(mali_swap_item *swap_item);\r
63 \r
64 /**\r
65  * Allocate a page node with swap item.\r
66  */\r
67 struct mali_page_node *_mali_mem_swap_page_node_allocate(void);\r
68 \r
69 /**\r
70  * Reduce the reference count of given page node and if return 0, just free this page node.\r
71  */\r
72 _mali_osk_errcode_t _mali_mem_swap_put_page_node(struct mali_page_node *m_page);\r
73 \r
74 void _mali_mem_swap_page_node_free(struct mali_page_node *m_page);\r
75 \r
76 /**\r
77  * Free a swappable memory backend.\r
78  */\r
79 u32 mali_mem_swap_free(mali_mem_swap *swap_mem);\r
80 \r
81 /**\r
82  * Ummap and free.\r
83  */\r
84 u32 mali_mem_swap_release(mali_mem_backend *mem_bkend, mali_bool is_mali_mapped);\r
85 \r
86 /**\r
87  * Read in a page from global swap file with the pre-allcated page index.\r
88  */\r
89 mali_bool mali_mem_swap_in_page_node(struct mali_page_node *page_node);\r
90 \r
91 int mali_mem_swap_alloc_pages(mali_mem_swap *swap_mem, u32 size, u32 *bkend_idx);\r
92 \r
93 _mali_osk_errcode_t mali_mem_swap_mali_map(mali_mem_swap *swap_mem, struct mali_session_data *session, u32 vaddr, u32 props);\r
94 \r
95 void mali_mem_swap_mali_unmap(mali_mem_allocation *alloc);\r
96 \r
97 /**\r
98  * When pp job created, we need swap in all of memory backend needed by this pp job.\r
99  */\r
100 int mali_mem_swap_in_pages(struct mali_pp_job *job);\r
101 \r
102 /**\r
103  * Put all of memory backends used this pp job to the global swap list.\r
104  */\r
105 int mali_mem_swap_out_pages(struct mali_pp_job *job);\r
106 \r
107 /**\r
108  * This will be called in page fault to process CPU read&write.\r
109  */\r
110 int mali_mem_swap_allocate_page_on_demand(mali_mem_backend *mem_bkend, u32 offset, struct page **pagep) ;\r
111 \r
112 /**\r
113  * Used to process cow on demand for swappable memory backend.\r
114  */\r
115 int mali_mem_swap_cow_page_on_demand(mali_mem_backend *mem_bkend, u32 offset, struct page **pagep);\r
116 \r
117 #ifdef MALI_MEM_SWAP_TRACKING\r
118 void mali_mem_swap_tracking(u32 *swap_pool_size, u32 *unlock_size);\r
119 #endif\r
120 #endif /* __MALI_MEMORY_SWAP_ALLOC_H__ */\r
121 \r