forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_tiler_heap.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
....@@ -23,7 +23,6 @@
2323 #define _KBASE_CSF_TILER_HEAP_H_
2424
2525 #include <mali_kbase.h>
26
-
2726 /**
2827 * kbase_csf_tiler_heap_context_init - Initialize the tiler heaps context for a
2928 * GPU address space
....@@ -38,10 +37,10 @@
3837 * kbase_csf_tiler_heap_context_term - Terminate the tiler heaps context for a
3938 * GPU address space
4039 *
40
+ * @kctx: Pointer to the kbase context being terminated.
41
+ *
4142 * This function deletes any chunked tiler heaps that weren't deleted before
4243 * context termination.
43
- *
44
- * @kctx: Pointer to the kbase context being terminated.
4544 */
4645 void kbase_csf_tiler_heap_context_term(struct kbase_context *kctx);
4746
....@@ -58,6 +57,12 @@
5857 * @target_in_flight: Number of render-passes that the driver should attempt to
5958 * keep in flight for which allocation of new chunks is
6059 * allowed. Must not be zero.
60
+ * @buf_desc_va: Buffer descriptor GPU virtual address. This is a hint for
61
+ * indicating that the caller is intending to perform tiler heap
62
+ * chunks reclaim for those that are hoarded with hardware while
63
+ * the associated shader activites are suspended and the CSGs are
64
+ * off slots. If the referred reclaiming is not desired, can
65
+ * set it to 0.
6166 * @gpu_heap_va: Where to store the GPU virtual address of the context that was
6267 * set up for the tiler heap.
6368 * @first_chunk_va: Where to store the GPU virtual address of the first chunk
....@@ -66,22 +71,21 @@
6671 *
6772 * Return: 0 if successful or a negative error code on failure.
6873 */
69
-int kbase_csf_tiler_heap_init(struct kbase_context *kctx,
70
- u32 chunk_size, u32 initial_chunks, u32 max_chunks,
71
- u16 target_in_flight, u64 *gpu_heap_va,
72
- u64 *first_chunk_va);
74
+int kbase_csf_tiler_heap_init(struct kbase_context *kctx, u32 chunk_size, u32 initial_chunks,
75
+ u32 max_chunks, u16 target_in_flight, u64 const buf_desc_va,
76
+ u64 *gpu_heap_va, u64 *first_chunk_va);
7377
7478 /**
75
- * kbasep_cs_tiler_heap_term - Terminate a chunked tiler memory heap.
79
+ * kbase_csf_tiler_heap_term - Terminate a chunked tiler memory heap.
80
+ *
81
+ * @kctx: Pointer to the kbase context in which the tiler heap was initialized.
82
+ * @gpu_heap_va: The GPU virtual address of the context that was set up for the
83
+ * tiler heap.
7684 *
7785 * This function will terminate a chunked tiler heap and cause all the chunks
7886 * (initial and those added during out-of-memory processing) to be freed.
7987 * It is the caller's responsibility to ensure no further operations on this
8088 * heap will happen before calling this function.
81
- *
82
- * @kctx: Pointer to the kbase context in which the tiler heap was initialized.
83
- * @gpu_heap_va: The GPU virtual address of the context that was set up for the
84
- * tiler heap.
8589 *
8690 * Return: 0 if successful or a negative error code on failure.
8791 */
....@@ -89,12 +93,6 @@
8993
9094 /**
9195 * kbase_csf_tiler_heap_alloc_new_chunk - Allocate a new chunk for tiler heap.
92
- *
93
- * This function will allocate a new chunk for the chunked tiler heap depending
94
- * on the settings provided by userspace when the heap was created and the
95
- * heap's statistics (like number of render passes in-flight).
96
- * It would return an appropriate error code if a new chunk couldn't be
97
- * allocated.
9896 *
9997 * @kctx: Pointer to the kbase context in which the tiler heap was initialized.
10098 * @gpu_heap_va: GPU virtual address of the heap context.
....@@ -105,6 +103,12 @@
105103 * @new_chunk_ptr: Where to store the GPU virtual address & size of the new
106104 * chunk allocated for the heap.
107105 *
106
+ * This function will allocate a new chunk for the chunked tiler heap depending
107
+ * on the settings provided by userspace when the heap was created and the
108
+ * heap's statistics (like number of render passes in-flight).
109
+ * It would return an appropriate error code if a new chunk couldn't be
110
+ * allocated.
111
+ *
108112 * Return: 0 if a new chunk was allocated otherwise an appropriate negative
109113 * error code (like -EBUSY when a free chunk is expected to be
110114 * available upon completion of a render pass and -EINVAL when
....@@ -112,4 +116,27 @@
112116 */
113117 int kbase_csf_tiler_heap_alloc_new_chunk(struct kbase_context *kctx,
114118 u64 gpu_heap_va, u32 nr_in_flight, u32 pending_frag_count, u64 *new_chunk_ptr);
119
+
120
+/**
121
+ * kbase_csf_tiler_heap_scan_kctx_unused_pages - Performs the tiler heap shrinker calim's scan
122
+ * functionality.
123
+ *
124
+ * @kctx: Pointer to the kbase context for which the tiler heap recalim is to be
125
+ * operated with.
126
+ * @to_free: Number of pages suggested for the reclaim scan (free) method to reach.
127
+ *
128
+ * Return: the actual number of pages the scan method has freed from the call.
129
+ */
130
+u32 kbase_csf_tiler_heap_scan_kctx_unused_pages(struct kbase_context *kctx, u32 to_free);
131
+
132
+/**
133
+ * kbase_csf_tiler_heap_count_kctx_unused_pages - Performs the tiler heap shrinker calim's count
134
+ * functionality.
135
+ *
136
+ * @kctx: Pointer to the kbase context for which the tiler heap recalim is to be
137
+ * operated with.
138
+ *
139
+ * Return: a number of pages that could likely be freed on the subsequent scan method call.
140
+ */
141
+u32 kbase_csf_tiler_heap_count_kctx_unused_pages(struct kbase_context *kctx);
115142 #endif