hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf_tiler_heap_def.h
....@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22 /*
33 *
4
- * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2020-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
....@@ -56,27 +56,38 @@
5656 ((CHUNK_HDR_NEXT_ADDR_MASK >> CHUNK_HDR_NEXT_ADDR_POS) << \
5757 CHUNK_HDR_NEXT_ADDR_ENCODE_SHIFT)
5858
59
+/* The size of the area needed to be vmapped prior to handing the tiler heap
60
+ * over to the tiler, so that the shrinker could be invoked.
61
+ */
62
+#define NEXT_CHUNK_ADDR_SIZE (sizeof(u64))
63
+
5964 /**
6065 * struct kbase_csf_tiler_heap_chunk - A tiler heap chunk managed by the kernel
66
+ *
67
+ * @link: Link to this chunk in a list of chunks belonging to a
68
+ * @kbase_csf_tiler_heap.
69
+ * @region: Pointer to the GPU memory region allocated for the chunk.
70
+ * @map: Kernel VA mapping so that we would not need to use vmap in the
71
+ * shrinker callback, which can allocate. This maps only the header
72
+ * of the chunk, so it could be traversed.
73
+ * @gpu_va: GPU virtual address of the start of the memory region.
74
+ * This points to the header of the chunk and not to the low address
75
+ * of free memory within it.
6176 *
6277 * Chunks are allocated upon initialization of a tiler heap or in response to
6378 * out-of-memory events from the firmware. Chunks are always fully backed by
6479 * physical memory to avoid the overhead of processing GPU page faults. The
6580 * allocated GPU memory regions are linked together independent of the list of
6681 * kernel objects of this type.
67
- *
68
- * @link: Link to this chunk in a list of chunks belonging to a
69
- * @kbase_csf_tiler_heap.
70
- * @region: Pointer to the GPU memory region allocated for the chunk.
71
- * @gpu_va: GPU virtual address of the start of the memory region.
72
- * This points to the header of the chunk and not to the low address
73
- * of free memory within it.
7482 */
7583 struct kbase_csf_tiler_heap_chunk {
7684 struct list_head link;
7785 struct kbase_va_region *region;
86
+ struct kbase_vmap_struct map;
7887 u64 gpu_va;
7988 };
89
+
90
+#define HEAP_BUF_DESCRIPTOR_CHECKED (1 << 0)
8091
8192 /**
8293 * struct kbase_csf_tiler_heap - A tiler heap managed by the kernel
....@@ -85,6 +96,20 @@
8596 * associated.
8697 * @link: Link to this heap in a list of tiler heaps belonging to
8798 * the @kbase_csf_tiler_heap_context.
99
+ * @chunks_list: Linked list of allocated chunks.
100
+ * @gpu_va: The GPU virtual address of the heap context structure that
101
+ * was allocated for the firmware. This is also used to
102
+ * uniquely identify the heap.
103
+ * @heap_id: Unique id representing the heap, assigned during heap
104
+ * initialization.
105
+ * @buf_desc_va: Buffer descriptor GPU VA. Can be 0 for backward compatible
106
+ * to earlier version base interfaces.
107
+ * @buf_desc_reg: Pointer to the VA region that covers the provided buffer
108
+ * descriptor memory object pointed to by buf_desc_va.
109
+ * @gpu_va_map: Kernel VA mapping of the GPU VA region.
110
+ * @buf_desc_map: Kernel VA mapping of the buffer descriptor, read from
111
+ * during the tiler heap shrinker. Sync operations may need
112
+ * to be done before each read.
88113 * @chunk_size: Size of each chunk, in bytes. Must be page-aligned.
89114 * @chunk_count: The number of chunks currently allocated. Must not be
90115 * zero or greater than @max_chunks.
....@@ -93,22 +118,23 @@
93118 * @target_in_flight: Number of render-passes that the driver should attempt
94119 * to keep in flight for which allocation of new chunks is
95120 * allowed. Must not be zero.
96
- * @gpu_va: The GPU virtual address of the heap context structure that
97
- * was allocated for the firmware. This is also used to
98
- * uniquely identify the heap.
99
- * @heap_id: Unique id representing the heap, assigned during heap
100
- * initialization.
101
- * @chunks_list: Linked list of allocated chunks.
121
+ * @buf_desc_checked: Indicates if runtime check on buffer descriptor has been done.
102122 */
103123 struct kbase_csf_tiler_heap {
104124 struct kbase_context *kctx;
105125 struct list_head link;
126
+ struct list_head chunks_list;
127
+ u64 gpu_va;
128
+ u64 heap_id;
129
+ u64 buf_desc_va;
130
+ struct kbase_va_region *buf_desc_reg;
131
+ struct kbase_vmap_struct buf_desc_map;
132
+ struct kbase_vmap_struct gpu_va_map;
106133 u32 chunk_size;
107134 u32 chunk_count;
108135 u32 max_chunks;
109136 u16 target_in_flight;
110
- u64 gpu_va;
111
- u64 heap_id;
112
- struct list_head chunks_list;
137
+ bool buf_desc_checked;
113138 };
139
+
114140 #endif /* !_KBASE_CSF_TILER_HEAP_DEF_H_ */