2 * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
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.
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.
11 #ifndef __MALI_MEMORY_SWAP_ALLOC_H__
\r
12 #define __MALI_MEMORY_SWAP_ALLOC_H__
\r
14 #include "mali_osk.h"
\r
15 #include "mali_session.h"
\r
17 #include "mali_memory_types.h"
\r
18 #include "mali_pp_job.h"
\r
21 * Initialize memory swapping module.
\r
23 _mali_osk_errcode_t mali_mem_swap_init(void);
\r
25 void mali_mem_swap_term(void);
\r
28 * Return global share memory file to other modules.
\r
30 struct file *mali_mem_swap_get_global_swap_file(void);
\r
33 * Unlock the given memory backend and pages in it could be swapped out by kernel.
\r
35 void mali_mem_swap_unlock_single_mem_backend(mali_mem_backend *mem_bkend);
\r
38 * Remove the given memory backend from global swap list.
\r
40 void mali_memory_swap_list_backend_delete(mali_mem_backend *mem_bkend);
\r
43 * Add the given memory backend to global swap list.
\r
45 void mali_memory_swap_list_backend_add(mali_mem_backend *mem_bkend);
\r
48 * Allocate 1 index from bitmap used as page index in global swap file.
\r
50 u32 mali_mem_swap_idx_alloc(void);
\r
52 void mali_mem_swap_idx_free(u32 idx);
\r
55 * Allocate a new swap item without page index.
\r
57 struct mali_swap_item *mali_mem_swap_alloc_swap_item(void);
\r
60 * Free a swap item, truncate the corresponding space in page cache and free index of page.
\r
62 void mali_mem_swap_free_swap_item(mali_swap_item *swap_item);
\r
65 * Allocate a page node with swap item.
\r
67 struct mali_page_node *_mali_mem_swap_page_node_allocate(void);
\r
70 * Reduce the reference count of given page node and if return 0, just free this page node.
\r
72 _mali_osk_errcode_t _mali_mem_swap_put_page_node(struct mali_page_node *m_page);
\r
74 void _mali_mem_swap_page_node_free(struct mali_page_node *m_page);
\r
77 * Free a swappable memory backend.
\r
79 u32 mali_mem_swap_free(mali_mem_swap *swap_mem);
\r
84 u32 mali_mem_swap_release(mali_mem_backend *mem_bkend, mali_bool is_mali_mapped);
\r
87 * Read in a page from global swap file with the pre-allcated page index.
\r
89 mali_bool mali_mem_swap_in_page_node(struct mali_page_node *page_node);
\r
91 int mali_mem_swap_alloc_pages(mali_mem_swap *swap_mem, u32 size, u32 *bkend_idx);
\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
95 void mali_mem_swap_mali_unmap(mali_mem_allocation *alloc);
\r
98 * When pp job created, we need swap in all of memory backend needed by this pp job.
\r
100 int mali_mem_swap_in_pages(struct mali_pp_job *job);
\r
103 * Put all of memory backends used this pp job to the global swap list.
\r
105 int mali_mem_swap_out_pages(struct mali_pp_job *job);
\r
108 * This will be called in page fault to process CPU read&write.
\r
110 int mali_mem_swap_allocate_page_on_demand(mali_mem_backend *mem_bkend, u32 offset, struct page **pagep) ;
\r
113 * Used to process cow on demand for swappable memory backend.
\r
115 int mali_mem_swap_cow_page_on_demand(mali_mem_backend *mem_bkend, u32 offset, struct page **pagep);
\r
117 #ifdef MALI_MEM_SWAP_TRACKING
\r
118 void mali_mem_swap_tracking(u32 *swap_pool_size, u32 *unlock_size);
\r
120 #endif /* __MALI_MEMORY_SWAP_ALLOC_H__ */
\r