| .. | .. |
|---|
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * |
|---|
| 4 | | - * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved. |
|---|
| 4 | + * (C) COPYRIGHT 2019-2022 ARM Limited. All rights reserved. |
|---|
| 5 | 5 | * |
|---|
| 6 | 6 | * This program is free software and is provided to you under the terms of the |
|---|
| 7 | 7 | * GNU General Public License version 2 as published by the Free Software |
|---|
| .. | .. |
|---|
| 25 | 25 | #include <mali_kbase_defs.h> |
|---|
| 26 | 26 | |
|---|
| 27 | 27 | /** |
|---|
| 28 | | - * kbase_mem_pool_group_config_init - Set the initial configuration for a |
|---|
| 29 | | - * set of memory pools |
|---|
| 28 | + * kbase_mem_pool_group_select() - Select the memory pool to use. |
|---|
| 29 | + * |
|---|
| 30 | + * @kbdev: Device pointer. |
|---|
| 31 | + * @mem_group_id: Physical memory group ID to use. |
|---|
| 32 | + * @is_small_page: Flag used to select between the small and |
|---|
| 33 | + * large memory pool. |
|---|
| 34 | + * |
|---|
| 35 | + * Return: A pointer to the selected memory pool. |
|---|
| 36 | + */ |
|---|
| 37 | +static inline struct kbase_mem_pool *kbase_mem_pool_group_select( |
|---|
| 38 | + struct kbase_device *kbdev, u32 mem_group_id, bool is_small_page) |
|---|
| 39 | +{ |
|---|
| 40 | + if (WARN_ON(unlikely(kbdev == NULL))) |
|---|
| 41 | + return NULL; |
|---|
| 42 | + |
|---|
| 43 | + WARN_ON(mem_group_id > BASE_MEM_GROUP_COUNT); |
|---|
| 44 | + |
|---|
| 45 | + if (is_small_page) |
|---|
| 46 | + return &kbdev->mem_pools.small[mem_group_id]; |
|---|
| 47 | + |
|---|
| 48 | + return &kbdev->mem_pools.large[mem_group_id]; |
|---|
| 49 | +} |
|---|
| 50 | + |
|---|
| 51 | +/** |
|---|
| 52 | + * kbase_mem_pool_group_config_set_max_size - Set the initial configuration for |
|---|
| 53 | + * a set of memory pools |
|---|
| 54 | + * |
|---|
| 55 | + * @configs: Initial configuration for the set of memory pools |
|---|
| 56 | + * @max_size: Maximum number of free 4 KiB pages each pool can hold |
|---|
| 30 | 57 | * |
|---|
| 31 | 58 | * This function sets the initial configuration for every memory pool so that |
|---|
| 32 | 59 | * the maximum amount of free memory that each pool can hold is identical. |
|---|
| 33 | 60 | * The equivalent number of 2 MiB pages is calculated automatically for the |
|---|
| 34 | 61 | * purpose of configuring the large page pools. |
|---|
| 35 | | - * |
|---|
| 36 | | - * @configs: Initial configuration for the set of memory pools |
|---|
| 37 | | - * @max_size: Maximum number of free 4 KiB pages each pool can hold |
|---|
| 38 | 62 | */ |
|---|
| 39 | 63 | void kbase_mem_pool_group_config_set_max_size( |
|---|
| 40 | 64 | struct kbase_mem_pool_group_config *configs, size_t max_size); |
|---|
| 41 | 65 | |
|---|
| 42 | 66 | /** |
|---|
| 43 | 67 | * kbase_mem_pool_group_init - Initialize a set of memory pools |
|---|
| 68 | + * |
|---|
| 69 | + * @mem_pools: Set of memory pools to initialize |
|---|
| 70 | + * @kbdev: Kbase device where memory is used |
|---|
| 71 | + * @configs: Initial configuration for the set of memory pools |
|---|
| 72 | + * @next_pools: Set of memory pools from which to allocate memory if there |
|---|
| 73 | + * is no free memory in one of the @mem_pools |
|---|
| 44 | 74 | * |
|---|
| 45 | 75 | * Initializes a complete set of physical memory pools. Memory pools are used to |
|---|
| 46 | 76 | * allow efficient reallocation of previously-freed physical pages. A pair of |
|---|
| .. | .. |
|---|
| 54 | 84 | * is full in @mem_pools. Pages are zeroed before they spill over to another |
|---|
| 55 | 85 | * pool, to prevent leaking information between applications. |
|---|
| 56 | 86 | * |
|---|
| 57 | | - * @mem_pools: Set of memory pools to initialize |
|---|
| 58 | | - * @kbdev: Kbase device where memory is used |
|---|
| 59 | | - * @configs: Initial configuration for the set of memory pools |
|---|
| 60 | | - * @next_pools: Set of memory pools from which to allocate memory if there |
|---|
| 61 | | - * is no free memory in one of the @mem_pools |
|---|
| 62 | | - * |
|---|
| 63 | 87 | * Return: 0 on success, otherwise a negative error code |
|---|
| 64 | 88 | */ |
|---|
| 65 | | -int kbase_mem_pool_group_init(struct kbase_mem_pool_group *mem_pools, |
|---|
| 66 | | - struct kbase_device *kbdev, |
|---|
| 67 | | - const struct kbase_mem_pool_group_config *configs, |
|---|
| 68 | | - struct kbase_mem_pool_group *next_pools); |
|---|
| 89 | +int kbase_mem_pool_group_init(struct kbase_mem_pool_group *mem_pools, struct kbase_device *kbdev, |
|---|
| 90 | + const struct kbase_mem_pool_group_config *configs, |
|---|
| 91 | + struct kbase_mem_pool_group *next_pools); |
|---|
| 69 | 92 | |
|---|
| 70 | 93 | /** |
|---|
| 71 | | - * kbase_mem_pool_group_term - Mark a set of memory pools as dying |
|---|
| 94 | + * kbase_mem_pool_group_mark_dying - Mark a set of memory pools as dying |
|---|
| 95 | + * |
|---|
| 96 | + * @mem_pools: Set of memory pools to mark |
|---|
| 72 | 97 | * |
|---|
| 73 | 98 | * Marks a complete set of physical memory pools previously initialized by |
|---|
| 74 | 99 | * @kbase_mem_pool_group_init as dying. This will cause any ongoing allocation |
|---|
| 75 | 100 | * operations (eg growing on page fault) to be terminated. |
|---|
| 76 | | - * |
|---|
| 77 | | - * @mem_pools: Set of memory pools to mark |
|---|
| 78 | 101 | */ |
|---|
| 79 | 102 | void kbase_mem_pool_group_mark_dying(struct kbase_mem_pool_group *mem_pools); |
|---|
| 80 | 103 | |
|---|
| 81 | 104 | /** |
|---|
| 82 | 105 | * kbase_mem_pool_group_term - Terminate a set of memory pools |
|---|
| 83 | 106 | * |
|---|
| 107 | + * @mem_pools: Set of memory pools to terminate |
|---|
| 108 | + * |
|---|
| 84 | 109 | * Terminates a complete set of physical memory pools previously initialized by |
|---|
| 85 | 110 | * @kbase_mem_pool_group_init. |
|---|
| 86 | | - * |
|---|
| 87 | | - * @mem_pools: Set of memory pools to terminate |
|---|
| 88 | 111 | */ |
|---|
| 89 | 112 | void kbase_mem_pool_group_term(struct kbase_mem_pool_group *mem_pools); |
|---|
| 90 | 113 | |
|---|