Lines Matching refs:cursor

332 static void dma_resv_iter_restart_unlocked(struct dma_resv_iter *cursor)  in dma_resv_iter_restart_unlocked()  argument
334 cursor->seq = read_seqcount_begin(&cursor->obj->seq); in dma_resv_iter_restart_unlocked()
335 cursor->index = -1; in dma_resv_iter_restart_unlocked()
336 cursor->shared_count = 0; in dma_resv_iter_restart_unlocked()
337 if (cursor->all_fences) { in dma_resv_iter_restart_unlocked()
338 cursor->fences = dma_resv_shared_list(cursor->obj); in dma_resv_iter_restart_unlocked()
339 if (cursor->fences) in dma_resv_iter_restart_unlocked()
340 cursor->shared_count = cursor->fences->shared_count; in dma_resv_iter_restart_unlocked()
342 cursor->fences = NULL; in dma_resv_iter_restart_unlocked()
344 cursor->is_restarted = true; in dma_resv_iter_restart_unlocked()
355 static void dma_resv_iter_walk_unlocked(struct dma_resv_iter *cursor) in dma_resv_iter_walk_unlocked() argument
357 struct dma_resv *obj = cursor->obj; in dma_resv_iter_walk_unlocked()
361 dma_fence_put(cursor->fence); in dma_resv_iter_walk_unlocked()
363 if (cursor->index == -1) { in dma_resv_iter_walk_unlocked()
364 cursor->fence = dma_resv_excl_fence(obj); in dma_resv_iter_walk_unlocked()
365 cursor->index++; in dma_resv_iter_walk_unlocked()
366 if (!cursor->fence) in dma_resv_iter_walk_unlocked()
369 } else if (!cursor->fences || in dma_resv_iter_walk_unlocked()
370 cursor->index >= cursor->shared_count) { in dma_resv_iter_walk_unlocked()
371 cursor->fence = NULL; in dma_resv_iter_walk_unlocked()
375 struct dma_resv_list *fences = cursor->fences; in dma_resv_iter_walk_unlocked()
376 unsigned int idx = cursor->index++; in dma_resv_iter_walk_unlocked()
378 cursor->fence = rcu_dereference(fences->shared[idx]); in dma_resv_iter_walk_unlocked()
380 cursor->fence = dma_fence_get_rcu(cursor->fence); in dma_resv_iter_walk_unlocked()
381 if (!cursor->fence || !dma_fence_is_signaled(cursor->fence)) in dma_resv_iter_walk_unlocked()
392 struct dma_fence *dma_resv_iter_first_unlocked(struct dma_resv_iter *cursor) in dma_resv_iter_first_unlocked() argument
396 dma_resv_iter_restart_unlocked(cursor); in dma_resv_iter_first_unlocked()
397 dma_resv_iter_walk_unlocked(cursor); in dma_resv_iter_first_unlocked()
398 } while (read_seqcount_retry(&cursor->obj->seq, cursor->seq)); in dma_resv_iter_first_unlocked()
401 return cursor->fence; in dma_resv_iter_first_unlocked()
411 struct dma_fence *dma_resv_iter_next_unlocked(struct dma_resv_iter *cursor) in dma_resv_iter_next_unlocked() argument
416 cursor->is_restarted = false; in dma_resv_iter_next_unlocked()
417 restart = read_seqcount_retry(&cursor->obj->seq, cursor->seq); in dma_resv_iter_next_unlocked()
420 dma_resv_iter_restart_unlocked(cursor); in dma_resv_iter_next_unlocked()
421 dma_resv_iter_walk_unlocked(cursor); in dma_resv_iter_next_unlocked()
423 } while (read_seqcount_retry(&cursor->obj->seq, cursor->seq)); in dma_resv_iter_next_unlocked()
426 return cursor->fence; in dma_resv_iter_next_unlocked()
437 struct dma_fence *dma_resv_iter_first(struct dma_resv_iter *cursor) in dma_resv_iter_first() argument
441 dma_resv_assert_held(cursor->obj); in dma_resv_iter_first()
443 cursor->index = 0; in dma_resv_iter_first()
444 if (cursor->all_fences) in dma_resv_iter_first()
445 cursor->fences = dma_resv_shared_list(cursor->obj); in dma_resv_iter_first()
447 cursor->fences = NULL; in dma_resv_iter_first()
449 fence = dma_resv_excl_fence(cursor->obj); in dma_resv_iter_first()
451 fence = dma_resv_iter_next(cursor); in dma_resv_iter_first()
453 cursor->is_restarted = true; in dma_resv_iter_first()
465 struct dma_fence *dma_resv_iter_next(struct dma_resv_iter *cursor) in dma_resv_iter_next() argument
469 dma_resv_assert_held(cursor->obj); in dma_resv_iter_next()
471 cursor->is_restarted = false; in dma_resv_iter_next()
472 if (!cursor->fences || cursor->index >= cursor->fences->shared_count) in dma_resv_iter_next()
475 idx = cursor->index++; in dma_resv_iter_next()
476 return rcu_dereference_protected(cursor->fences->shared[idx], in dma_resv_iter_next()
477 dma_resv_held(cursor->obj)); in dma_resv_iter_next()
490 struct dma_resv_iter cursor; in dma_resv_copy_fences() local
499 dma_resv_iter_begin(&cursor, src, true); in dma_resv_copy_fences()
500 dma_resv_for_each_fence_unlocked(&cursor, f) { in dma_resv_copy_fences()
502 if (dma_resv_iter_is_restarted(&cursor)) { in dma_resv_copy_fences()
506 if (cursor.shared_count) { in dma_resv_copy_fences()
507 list = dma_resv_list_alloc(cursor.shared_count); in dma_resv_copy_fences()
509 dma_resv_iter_end(&cursor); in dma_resv_copy_fences()
522 if (dma_resv_iter_is_exclusive(&cursor)) in dma_resv_copy_fences()
527 dma_resv_iter_end(&cursor); in dma_resv_copy_fences()
557 struct dma_resv_iter cursor; in dma_resv_get_fences() local
566 dma_resv_iter_begin(&cursor, obj, true); in dma_resv_get_fences()
567 dma_resv_for_each_fence_unlocked(&cursor, fence) { in dma_resv_get_fences()
569 if (dma_resv_iter_is_restarted(&cursor)) { in dma_resv_get_fences()
578 count = cursor.shared_count; in dma_resv_get_fences()
586 dma_resv_iter_end(&cursor); in dma_resv_get_fences()
592 if (dma_resv_iter_is_exclusive(&cursor) && fence_excl) in dma_resv_get_fences()
597 dma_resv_iter_end(&cursor); in dma_resv_get_fences()
621 struct dma_resv_iter cursor; in dma_resv_wait_timeout() local
624 dma_resv_iter_begin(&cursor, obj, wait_all); in dma_resv_wait_timeout()
625 dma_resv_for_each_fence_unlocked(&cursor, fence) { in dma_resv_wait_timeout()
629 dma_resv_iter_end(&cursor); in dma_resv_wait_timeout()
633 dma_resv_iter_end(&cursor); in dma_resv_wait_timeout()
656 struct dma_resv_iter cursor; in dma_resv_test_signaled() local
659 dma_resv_iter_begin(&cursor, obj, test_all); in dma_resv_test_signaled()
660 dma_resv_for_each_fence_unlocked(&cursor, fence) { in dma_resv_test_signaled()
661 dma_resv_iter_end(&cursor); in dma_resv_test_signaled()
664 dma_resv_iter_end(&cursor); in dma_resv_test_signaled()