Lines Matching refs:sa_manager
48 static void radeon_sa_bo_try_free(struct radeon_sa_manager *sa_manager);
51 struct radeon_sa_manager *sa_manager, in radeon_sa_bo_manager_init() argument
56 init_waitqueue_head(&sa_manager->wq); in radeon_sa_bo_manager_init()
57 sa_manager->bo = NULL; in radeon_sa_bo_manager_init()
58 sa_manager->size = size; in radeon_sa_bo_manager_init()
59 sa_manager->domain = domain; in radeon_sa_bo_manager_init()
60 sa_manager->align = align; in radeon_sa_bo_manager_init()
61 sa_manager->hole = &sa_manager->olist; in radeon_sa_bo_manager_init()
62 INIT_LIST_HEAD(&sa_manager->olist); in radeon_sa_bo_manager_init()
64 INIT_LIST_HEAD(&sa_manager->flist[i]); in radeon_sa_bo_manager_init()
68 domain, flags, NULL, NULL, &sa_manager->bo); in radeon_sa_bo_manager_init()
78 struct radeon_sa_manager *sa_manager) in radeon_sa_bo_manager_fini() argument
82 if (!list_empty(&sa_manager->olist)) { in radeon_sa_bo_manager_fini()
83 sa_manager->hole = &sa_manager->olist, in radeon_sa_bo_manager_fini()
84 radeon_sa_bo_try_free(sa_manager); in radeon_sa_bo_manager_fini()
85 if (!list_empty(&sa_manager->olist)) { in radeon_sa_bo_manager_fini()
89 list_for_each_entry_safe(sa_bo, tmp, &sa_manager->olist, olist) { in radeon_sa_bo_manager_fini()
92 radeon_bo_unref(&sa_manager->bo); in radeon_sa_bo_manager_fini()
93 sa_manager->size = 0; in radeon_sa_bo_manager_fini()
97 struct radeon_sa_manager *sa_manager) in radeon_sa_bo_manager_start() argument
101 if (sa_manager->bo == NULL) { in radeon_sa_bo_manager_start()
107 r = radeon_bo_reserve(sa_manager->bo, false); in radeon_sa_bo_manager_start()
112 r = radeon_bo_pin(sa_manager->bo, sa_manager->domain, &sa_manager->gpu_addr); in radeon_sa_bo_manager_start()
114 radeon_bo_unreserve(sa_manager->bo); in radeon_sa_bo_manager_start()
118 r = radeon_bo_kmap(sa_manager->bo, &sa_manager->cpu_ptr); in radeon_sa_bo_manager_start()
119 radeon_bo_unreserve(sa_manager->bo); in radeon_sa_bo_manager_start()
124 struct radeon_sa_manager *sa_manager) in radeon_sa_bo_manager_suspend() argument
128 if (sa_manager->bo == NULL) { in radeon_sa_bo_manager_suspend()
133 r = radeon_bo_reserve(sa_manager->bo, false); in radeon_sa_bo_manager_suspend()
135 radeon_bo_kunmap(sa_manager->bo); in radeon_sa_bo_manager_suspend()
136 radeon_bo_unpin(sa_manager->bo); in radeon_sa_bo_manager_suspend()
137 radeon_bo_unreserve(sa_manager->bo); in radeon_sa_bo_manager_suspend()
144 struct radeon_sa_manager *sa_manager = sa_bo->manager; in radeon_sa_bo_remove_locked() local
145 if (sa_manager->hole == &sa_bo->olist) { in radeon_sa_bo_remove_locked()
146 sa_manager->hole = sa_bo->olist.prev; in radeon_sa_bo_remove_locked()
154 static void radeon_sa_bo_try_free(struct radeon_sa_manager *sa_manager) in radeon_sa_bo_try_free() argument
158 if (sa_manager->hole->next == &sa_manager->olist) in radeon_sa_bo_try_free()
161 sa_bo = list_entry(sa_manager->hole->next, struct radeon_sa_bo, olist); in radeon_sa_bo_try_free()
162 list_for_each_entry_safe_from(sa_bo, tmp, &sa_manager->olist, olist) { in radeon_sa_bo_try_free()
170 static inline unsigned radeon_sa_bo_hole_soffset(struct radeon_sa_manager *sa_manager) in radeon_sa_bo_hole_soffset() argument
172 struct list_head *hole = sa_manager->hole; in radeon_sa_bo_hole_soffset()
174 if (hole != &sa_manager->olist) { in radeon_sa_bo_hole_soffset()
180 static inline unsigned radeon_sa_bo_hole_eoffset(struct radeon_sa_manager *sa_manager) in radeon_sa_bo_hole_eoffset() argument
182 struct list_head *hole = sa_manager->hole; in radeon_sa_bo_hole_eoffset()
184 if (hole->next != &sa_manager->olist) { in radeon_sa_bo_hole_eoffset()
187 return sa_manager->size; in radeon_sa_bo_hole_eoffset()
190 static bool radeon_sa_bo_try_alloc(struct radeon_sa_manager *sa_manager, in radeon_sa_bo_try_alloc() argument
196 soffset = radeon_sa_bo_hole_soffset(sa_manager); in radeon_sa_bo_try_alloc()
197 eoffset = radeon_sa_bo_hole_eoffset(sa_manager); in radeon_sa_bo_try_alloc()
203 sa_bo->manager = sa_manager; in radeon_sa_bo_try_alloc()
206 list_add(&sa_bo->olist, sa_manager->hole); in radeon_sa_bo_try_alloc()
208 sa_manager->hole = &sa_bo->olist; in radeon_sa_bo_try_alloc()
224 static bool radeon_sa_event(struct radeon_sa_manager *sa_manager, in radeon_sa_event() argument
231 if (!list_empty(&sa_manager->flist[i])) { in radeon_sa_event()
236 soffset = radeon_sa_bo_hole_soffset(sa_manager); in radeon_sa_event()
237 eoffset = radeon_sa_bo_hole_eoffset(sa_manager); in radeon_sa_event()
247 static bool radeon_sa_bo_next_hole(struct radeon_sa_manager *sa_manager, in radeon_sa_bo_next_hole() argument
255 if (sa_manager->hole->next == &sa_manager->olist) { in radeon_sa_bo_next_hole()
257 sa_manager->hole = &sa_manager->olist; in radeon_sa_bo_next_hole()
261 soffset = radeon_sa_bo_hole_soffset(sa_manager); in radeon_sa_bo_next_hole()
263 best = sa_manager->size * 2; in radeon_sa_bo_next_hole()
270 if (list_empty(&sa_manager->flist[i])) { in radeon_sa_bo_next_hole()
274 sa_bo = list_first_entry(&sa_manager->flist[i], in radeon_sa_bo_next_hole()
290 tmp += sa_manager->size; in radeon_sa_bo_next_hole()
302 sa_manager->hole = best_bo->olist.prev; in radeon_sa_bo_next_hole()
313 struct radeon_sa_manager *sa_manager, in radeon_sa_bo_new() argument
321 BUG_ON(align > sa_manager->align); in radeon_sa_bo_new()
322 BUG_ON(size > sa_manager->size); in radeon_sa_bo_new()
328 (*sa_bo)->manager = sa_manager; in radeon_sa_bo_new()
333 spin_lock(&sa_manager->wq.lock); in radeon_sa_bo_new()
341 radeon_sa_bo_try_free(sa_manager); in radeon_sa_bo_new()
343 if (radeon_sa_bo_try_alloc(sa_manager, *sa_bo, in radeon_sa_bo_new()
345 spin_unlock(&sa_manager->wq.lock); in radeon_sa_bo_new()
350 } while (radeon_sa_bo_next_hole(sa_manager, fences, tries)); in radeon_sa_bo_new()
355 spin_unlock(&sa_manager->wq.lock); in radeon_sa_bo_new()
359 spin_lock(&sa_manager->wq.lock); in radeon_sa_bo_new()
363 sa_manager->wq, in radeon_sa_bo_new()
364 radeon_sa_event(sa_manager, size, align) in radeon_sa_bo_new()
370 spin_unlock(&sa_manager->wq.lock); in radeon_sa_bo_new()
379 struct radeon_sa_manager *sa_manager; in radeon_sa_bo_free() local
385 sa_manager = (*sa_bo)->manager; in radeon_sa_bo_free()
386 spin_lock(&sa_manager->wq.lock); in radeon_sa_bo_free()
390 &sa_manager->flist[fence->ring]); in radeon_sa_bo_free()
394 wake_up_all_locked(&sa_manager->wq); in radeon_sa_bo_free()
395 spin_unlock(&sa_manager->wq.lock); in radeon_sa_bo_free()
400 void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager, in radeon_sa_bo_dump_debug_info() argument
405 spin_lock(&sa_manager->wq.lock); in radeon_sa_bo_dump_debug_info()
406 list_for_each_entry(i, &sa_manager->olist, olist) { in radeon_sa_bo_dump_debug_info()
407 uint64_t soffset = i->soffset + sa_manager->gpu_addr; in radeon_sa_bo_dump_debug_info()
408 uint64_t eoffset = i->eoffset + sa_manager->gpu_addr; in radeon_sa_bo_dump_debug_info()
409 if (&i->olist == sa_manager->hole) { in radeon_sa_bo_dump_debug_info()
422 spin_unlock(&sa_manager->wq.lock); in radeon_sa_bo_dump_debug_info()