| .. | .. |
|---|
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * |
|---|
| 4 | | - * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved. |
|---|
| 4 | + * (C) COPYRIGHT 2020-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 |
|---|
| .. | .. |
|---|
| 56 | 56 | ((CHUNK_HDR_NEXT_ADDR_MASK >> CHUNK_HDR_NEXT_ADDR_POS) << \ |
|---|
| 57 | 57 | CHUNK_HDR_NEXT_ADDR_ENCODE_SHIFT) |
|---|
| 58 | 58 | |
|---|
| 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 | + |
|---|
| 59 | 64 | /** |
|---|
| 60 | 65 | * 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. |
|---|
| 61 | 76 | * |
|---|
| 62 | 77 | * Chunks are allocated upon initialization of a tiler heap or in response to |
|---|
| 63 | 78 | * out-of-memory events from the firmware. Chunks are always fully backed by |
|---|
| 64 | 79 | * physical memory to avoid the overhead of processing GPU page faults. The |
|---|
| 65 | 80 | * allocated GPU memory regions are linked together independent of the list of |
|---|
| 66 | 81 | * 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. |
|---|
| 74 | 82 | */ |
|---|
| 75 | 83 | struct kbase_csf_tiler_heap_chunk { |
|---|
| 76 | 84 | struct list_head link; |
|---|
| 77 | 85 | struct kbase_va_region *region; |
|---|
| 86 | + struct kbase_vmap_struct map; |
|---|
| 78 | 87 | u64 gpu_va; |
|---|
| 79 | 88 | }; |
|---|
| 89 | + |
|---|
| 90 | +#define HEAP_BUF_DESCRIPTOR_CHECKED (1 << 0) |
|---|
| 80 | 91 | |
|---|
| 81 | 92 | /** |
|---|
| 82 | 93 | * struct kbase_csf_tiler_heap - A tiler heap managed by the kernel |
|---|
| .. | .. |
|---|
| 85 | 96 | * associated. |
|---|
| 86 | 97 | * @link: Link to this heap in a list of tiler heaps belonging to |
|---|
| 87 | 98 | * 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. |
|---|
| 88 | 113 | * @chunk_size: Size of each chunk, in bytes. Must be page-aligned. |
|---|
| 89 | 114 | * @chunk_count: The number of chunks currently allocated. Must not be |
|---|
| 90 | 115 | * zero or greater than @max_chunks. |
|---|
| .. | .. |
|---|
| 93 | 118 | * @target_in_flight: Number of render-passes that the driver should attempt |
|---|
| 94 | 119 | * to keep in flight for which allocation of new chunks is |
|---|
| 95 | 120 | * 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. |
|---|
| 102 | 122 | */ |
|---|
| 103 | 123 | struct kbase_csf_tiler_heap { |
|---|
| 104 | 124 | struct kbase_context *kctx; |
|---|
| 105 | 125 | 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; |
|---|
| 106 | 133 | u32 chunk_size; |
|---|
| 107 | 134 | u32 chunk_count; |
|---|
| 108 | 135 | u32 max_chunks; |
|---|
| 109 | 136 | u16 target_in_flight; |
|---|
| 110 | | - u64 gpu_va; |
|---|
| 111 | | - u64 heap_id; |
|---|
| 112 | | - struct list_head chunks_list; |
|---|
| 137 | + bool buf_desc_checked; |
|---|
| 113 | 138 | }; |
|---|
| 139 | + |
|---|
| 114 | 140 | #endif /* !_KBASE_CSF_TILER_HEAP_DEF_H_ */ |
|---|