xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/mali_kbase_mem_pool_debugfs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2014-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 #ifndef _KBASE_MEM_POOL_DEBUGFS_H_
23 #define _KBASE_MEM_POOL_DEBUGFS_H_
24 
25 #include <mali_kbase.h>
26 
27 /**
28  * kbase_mem_pool_debugfs_init - add debugfs knobs for @pool
29  * @parent:  Parent debugfs dentry
30  * @kctx:    The kbase context
31  *
32  * Adds four debugfs files under @parent:
33  * - mem_pool_size: get/set the current sizes of @kctx: mem_pools
34  * - mem_pool_max_size: get/set the max sizes of @kctx: mem_pools
35  * - lp_mem_pool_size: get/set the current sizes of @kctx: lp_mem_pool
36  * - lp_mem_pool_max_size: get/set the max sizes of @kctx:lp_mem_pool
37  */
38 void kbase_mem_pool_debugfs_init(struct dentry *parent,
39 		struct kbase_context *kctx);
40 
41 /**
42  * kbase_mem_pool_debugfs_trim - Grow or shrink a memory pool to a new size
43  *
44  * @array: Address of the first in an array of physical memory pools.
45  * @index: A memory group ID to be used as an index into the array of memory
46  *         pools. Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
47  * @value: New number of pages in the pool.
48  *
49  * If @value > current size, fill the pool with new pages from the kernel, but
50  * not above the max_size for the pool.
51  * If @value < current size, shrink the pool by freeing pages to the kernel.
52  */
53 void kbase_mem_pool_debugfs_trim(void *array, size_t index, size_t value);
54 
55 /**
56  * kbase_mem_pool_debugfs_set_max_size - Set maximum number of free pages in
57  *                                       memory pool
58  *
59  * @array: Address of the first in an array of physical memory pools.
60  * @index: A memory group ID to be used as an index into the array of memory
61  *         pools. Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
62  * @value: Maximum number of free pages the pool can hold.
63  *
64  * If the maximum size is reduced, the pool will be shrunk to adhere to the
65  * new limit. For details see kbase_mem_pool_shrink().
66  */
67 void kbase_mem_pool_debugfs_set_max_size(void *array, size_t index,
68 	size_t value);
69 
70 /**
71  * kbase_mem_pool_debugfs_size - Get number of free pages in a memory pool
72  *
73  * @array: Address of the first in an array of physical memory pools.
74  * @index: A memory group ID to be used as an index into the array of memory
75  *         pools. Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
76  *
77  * Note: the size of the pool may in certain corner cases exceed @max_size!
78  *
79  * Return: Number of free pages in the pool
80  */
81 size_t kbase_mem_pool_debugfs_size(void *array, size_t index);
82 
83 /**
84  * kbase_mem_pool_debugfs_max_size - Get maximum number of free pages in a
85  *                                   memory pool
86  *
87  * @array: Address of the first in an array of physical memory pools.
88  * @index: A memory group ID to be used as an index into the array of memory
89  *         pools. Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
90  *
91  * Return: Maximum number of free pages in the pool
92  */
93 size_t kbase_mem_pool_debugfs_max_size(void *array, size_t index);
94 
95 /**
96  * kbase_mem_pool_config_debugfs_set_max_size - Set maximum number of free pages
97  *                                              in initial configuration of pool
98  *
99  * @array:  Array of initial configurations for a set of physical memory pools.
100  * @index:  A memory group ID to be used as an index into the array.
101  *          Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
102  * @value : Maximum number of free pages that a memory pool created from the
103  *          selected configuration can hold.
104  */
105 void kbase_mem_pool_config_debugfs_set_max_size(void *array, size_t index,
106 	size_t value);
107 
108 /**
109  * kbase_mem_pool_config_debugfs_max_size - Get maximum number of free pages
110  *                                          from initial configuration of pool
111  *
112  * @array:  Array of initial configurations for a set of physical memory pools.
113  * @index:  A memory group ID to be used as an index into the array.
114  *          Valid range is 0..(MEMORY_GROUP_MANAGER_NR_GROUPS-1).
115  *
116  * Return: Maximum number of free pages that a memory pool created from the
117  *         selected configuration can hold.
118  */
119 size_t kbase_mem_pool_config_debugfs_max_size(void *array, size_t index);
120 
121 #endif  /*_KBASE_MEM_POOL_DEBUGFS_H_ */
122 
123