hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/arm/bifrost/mali_kbase_mem_pool_group.h
....@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22 /*
33 *
4
- * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2019-2022 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -25,22 +25,52 @@
2525 #include <mali_kbase_defs.h>
2626
2727 /**
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
3057 *
3158 * This function sets the initial configuration for every memory pool so that
3259 * the maximum amount of free memory that each pool can hold is identical.
3360 * The equivalent number of 2 MiB pages is calculated automatically for the
3461 * 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
3862 */
3963 void kbase_mem_pool_group_config_set_max_size(
4064 struct kbase_mem_pool_group_config *configs, size_t max_size);
4165
4266 /**
4367 * 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
4474 *
4575 * Initializes a complete set of physical memory pools. Memory pools are used to
4676 * allow efficient reallocation of previously-freed physical pages. A pair of
....@@ -54,37 +84,30 @@
5484 * is full in @mem_pools. Pages are zeroed before they spill over to another
5585 * pool, to prevent leaking information between applications.
5686 *
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
- *
6387 * Return: 0 on success, otherwise a negative error code
6488 */
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);
6992
7093 /**
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
7297 *
7398 * Marks a complete set of physical memory pools previously initialized by
7499 * @kbase_mem_pool_group_init as dying. This will cause any ongoing allocation
75100 * operations (eg growing on page fault) to be terminated.
76
- *
77
- * @mem_pools: Set of memory pools to mark
78101 */
79102 void kbase_mem_pool_group_mark_dying(struct kbase_mem_pool_group *mem_pools);
80103
81104 /**
82105 * kbase_mem_pool_group_term - Terminate a set of memory pools
83106 *
107
+ * @mem_pools: Set of memory pools to terminate
108
+ *
84109 * Terminates a complete set of physical memory pools previously initialized by
85110 * @kbase_mem_pool_group_init.
86
- *
87
- * @mem_pools: Set of memory pools to terminate
88111 */
89112 void kbase_mem_pool_group_term(struct kbase_mem_pool_group *mem_pools);
90113