Lines Matching +full:sg +full:- +full:micro
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
3 * Copyright 2020 Advanced Micro Devices, Inc.
54 mgr = ttm_manager_type(res->bo->bdev, res->mem_type); in xe_res_get_buddy()
55 return &to_xe_ttm_vram_mgr(mgr)->mm; in xe_res_get_buddy()
59 * xe_res_first - initialize a xe_res_cursor
72 cur->sgl = NULL; in xe_res_first()
76 XE_WARN_ON(start + size > res->size); in xe_res_first()
78 cur->mem_type = res->mem_type; in xe_res_first()
80 switch (cur->mem_type) { in xe_res_first()
88 head = &to_xe_ttm_vram_mgr_resource(res)->blocks; in xe_res_first()
97 start -= drm_buddy_block_size(mm, block); in xe_res_first()
99 next = block->link.next; in xe_res_first()
105 cur->mm = mm; in xe_res_first()
106 cur->start = drm_buddy_block_offset(block) + start; in xe_res_first()
107 cur->size = min(drm_buddy_block_size(mm, block) - start, in xe_res_first()
109 cur->remaining = size; in xe_res_first()
110 cur->node = block; in xe_res_first()
120 cur->start = start; in xe_res_first()
121 cur->size = size; in xe_res_first()
122 cur->remaining = size; in xe_res_first()
123 cur->node = NULL; in xe_res_first()
124 cur->mem_type = XE_PL_TT; in xe_res_first()
125 XE_WARN_ON(res && start + size > res->size); in xe_res_first()
130 struct scatterlist *sgl = cur->sgl; in __xe_res_sg_next()
131 u64 start = cur->start; in __xe_res_sg_next()
134 start -= sg_dma_len(sgl); in __xe_res_sg_next()
139 cur->start = start; in __xe_res_sg_next()
140 cur->size = sg_dma_len(sgl) - start; in __xe_res_sg_next()
141 cur->sgl = sgl; in __xe_res_sg_next()
145 * xe_res_first_sg - initialize a xe_res_cursor with a scatter gather table
147 * @sg: scatter gather table to walk
154 static inline void xe_res_first_sg(const struct sg_table *sg, in xe_res_first_sg() argument
158 XE_WARN_ON(!sg); in xe_res_first_sg()
159 cur->node = NULL; in xe_res_first_sg()
160 cur->start = start; in xe_res_first_sg()
161 cur->remaining = size; in xe_res_first_sg()
162 cur->size = 0; in xe_res_first_sg()
163 cur->sgl = sg->sgl; in xe_res_first_sg()
164 cur->mem_type = XE_PL_TT; in xe_res_first_sg()
169 * xe_res_next - advance the cursor
182 XE_WARN_ON(size > cur->remaining); in xe_res_next()
184 cur->remaining -= size; in xe_res_next()
185 if (!cur->remaining) in xe_res_next()
188 if (cur->size > size) { in xe_res_next()
189 cur->size -= size; in xe_res_next()
190 cur->start += size; in xe_res_next()
194 if (cur->sgl) { in xe_res_next()
195 cur->start += size; in xe_res_next()
200 switch (cur->mem_type) { in xe_res_next()
204 start = size - cur->size; in xe_res_next()
205 block = cur->node; in xe_res_next()
207 next = block->link.next; in xe_res_next()
211 while (start >= drm_buddy_block_size(cur->mm, block)) { in xe_res_next()
212 start -= drm_buddy_block_size(cur->mm, block); in xe_res_next()
214 next = block->link.next; in xe_res_next()
218 cur->start = drm_buddy_block_offset(block) + start; in xe_res_next()
219 cur->size = min(drm_buddy_block_size(cur->mm, block) - start, in xe_res_next()
220 cur->remaining); in xe_res_next()
221 cur->node = block; in xe_res_next()
229 * xe_res_dma - return dma address of cursor at current position
235 return cur->sgl ? sg_dma_address(cur->sgl) + cur->start : cur->start; in xe_res_dma()