1 /* 2 * Copyright (C) 2013-2017 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 #ifndef __MALI_MEMORY_DEFER_BIND_H_ 11 #define __MALI_MEMORY_DEFER_BIND_H_ 12 13 14 #include "mali_osk.h" 15 #include "mali_session.h" 16 17 #include <linux/list.h> 18 #include <linux/mm.h> 19 #include <linux/rbtree.h> 20 #include <linux/spinlock.h> 21 #include <linux/types.h> 22 23 24 #include "mali_memory_types.h" 25 #include "mali_memory_os_alloc.h" 26 #include "mali_uk_types.h" 27 28 struct mali_gp_job; 29 30 typedef struct mali_defer_mem { 31 struct list_head node; /*dlist node in bind manager */ 32 u32 flag; 33 } mali_defer_mem; 34 35 36 typedef struct mali_defer_mem_block { 37 struct list_head free_pages; /* page pool */ 38 atomic_t num_free_pages; 39 } mali_defer_mem_block; 40 41 /* varying memory list need to bind */ 42 typedef struct mali_backend_bind_list { 43 struct list_head node; 44 struct mali_mem_backend *bkend; 45 u32 vaddr; 46 u32 page_num; 47 struct mali_session_data *session; 48 u32 flag; 49 } mali_backend_bind_lists; 50 51 52 typedef struct mali_defer_bind_manager { 53 atomic_t num_used_pages; 54 atomic_t num_dmem; 55 } mali_defer_bind_manager; 56 57 _mali_osk_errcode_t mali_mem_defer_bind_manager_init(void); 58 void mali_mem_defer_bind_manager_destory(void); 59 _mali_osk_errcode_t mali_mem_defer_bind(struct mali_gp_job *gp, struct mali_defer_mem_block *dmem_block); 60 _mali_osk_errcode_t mali_mem_defer_bind_allocation_prepare(mali_mem_allocation *alloc, struct list_head *list, u32 *required_varying_memsize); 61 _mali_osk_errcode_t mali_mem_prepare_mem_for_job(struct mali_gp_job *next_gp_job, mali_defer_mem_block *dblock); 62 void mali_mem_defer_dmem_free(struct mali_gp_job *gp); 63 64 #endif 65