1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved. 5 * 6 * This program is free software and is provided to you under the terms of the 7 * GNU General Public License version 2 as published by the Free Software 8 * Foundation, and any use by you of this program is subject to the terms 9 * of such GNU license. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, you can access it online at 18 * http://www.gnu.org/licenses/gpl-2.0.html. 19 * 20 */ 21 22 #include <mali_kbase.h> 23 24 #ifndef _KBASE_CSF_HEAP_CONTEXT_ALLOC_H_ 25 #define _KBASE_CSF_HEAP_CONTEXT_ALLOC_H_ 26 27 /** 28 * kbase_csf_heap_context_allocator_init - Initialize an allocator for heap 29 * contexts 30 * @ctx_alloc: Pointer to the heap context allocator to initialize. 31 * @kctx: Pointer to the kbase context. 32 * 33 * Return: 0 if successful or a negative error code on failure. 34 */ 35 int kbase_csf_heap_context_allocator_init( 36 struct kbase_csf_heap_context_allocator *const ctx_alloc, 37 struct kbase_context *const kctx); 38 39 /** 40 * kbase_csf_heap_context_allocator_term - Terminate an allocator for heap 41 * contexts 42 * @ctx_alloc: Pointer to the heap context allocator to terminate. 43 */ 44 void kbase_csf_heap_context_allocator_term( 45 struct kbase_csf_heap_context_allocator *const ctx_alloc); 46 47 /** 48 * kbase_csf_heap_context_allocator_alloc - Allocate a heap context structure 49 * 50 * @ctx_alloc: Pointer to the heap context allocator. 51 * 52 * If this function is successful then it returns the address of a 53 * zero-initialized heap context structure for use by the firmware. 54 * 55 * Return: GPU virtual address of the allocated heap context or 0 on failure. 56 */ 57 u64 kbase_csf_heap_context_allocator_alloc( 58 struct kbase_csf_heap_context_allocator *const ctx_alloc); 59 60 /** 61 * kbase_csf_heap_context_allocator_free - Free a heap context structure 62 * 63 * @ctx_alloc: Pointer to the heap context allocator. 64 * @heap_gpu_va: The GPU virtual address of a heap context structure that 65 * was allocated for the firmware. 66 * 67 * This function returns a heap context structure to the free pool of unused 68 * contexts for possible reuse by a future call to 69 * @kbase_csf_heap_context_allocator_alloc. 70 */ 71 void kbase_csf_heap_context_allocator_free( 72 struct kbase_csf_heap_context_allocator *const ctx_alloc, 73 u64 const heap_gpu_va); 74 75 #endif /* _KBASE_CSF_HEAP_CONTEXT_ALLOC_H_ */ 76