Lines Matching refs:bufmgr_fake
57 if (bufmgr_fake->bufmgr.debug) \
228 static int clear_fenced(drm_intel_bufmgr_fake *bufmgr_fake,
255 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_set_fence_callback() local
257 bufmgr_fake->fence_emit = emit; in drm_intel_bufmgr_fake_set_fence_callback()
258 bufmgr_fake->fence_wait = wait; in drm_intel_bufmgr_fake_set_fence_callback()
259 bufmgr_fake->fence_priv = priv; in drm_intel_bufmgr_fake_set_fence_callback()
263 _fence_emit_internal(drm_intel_bufmgr_fake *bufmgr_fake) in _fence_emit_internal() argument
268 if (bufmgr_fake->fence_emit != NULL) { in _fence_emit_internal()
269 seq = bufmgr_fake->fence_emit(bufmgr_fake->fence_priv); in _fence_emit_internal()
274 ret = drmCommandWriteRead(bufmgr_fake->fd, DRM_I915_IRQ_EMIT, in _fence_emit_internal()
286 _fence_wait_internal(drm_intel_bufmgr_fake *bufmgr_fake, int seq) in _fence_wait_internal() argument
293 if (bufmgr_fake->fence_wait != NULL) { in _fence_wait_internal()
294 bufmgr_fake->fence_wait(seq, bufmgr_fake->fence_priv); in _fence_wait_internal()
295 clear_fenced(bufmgr_fake, seq); in _fence_wait_internal()
378 hw_seq = *bufmgr_fake->last_dispatch; in _fence_wait_internal()
384 ret = drmCommandWrite(bufmgr_fake->fd, DRM_I915_IRQ_WAIT, in _fence_wait_internal()
387 kernel_lied = (ret == 0) && (seq - *bufmgr_fake->last_dispatch < in _fence_wait_internal()
392 && (seq - *bufmgr_fake->last_dispatch > 0x40000000)) in _fence_wait_internal()
396 if ((ret == -EBUSY) && (hw_seq != *bufmgr_fake->last_dispatch)) in _fence_wait_internal()
408 clear_fenced(bufmgr_fake, seq); in _fence_wait_internal()
412 _fence_test(drm_intel_bufmgr_fake *bufmgr_fake, unsigned fence) in _fence_test() argument
416 return fence == 0 || FENCE_LTE(fence, bufmgr_fake->last_fence); in _fence_test()
426 drm_intel_bufmgr_fake *bufmgr_fake = in alloc_block() local
437 block->mem = mmAllocMem(bufmgr_fake->heap, sz, align_log2, 0); in alloc_block()
446 DRMLISTADDTAIL(block, &bufmgr_fake->lru); in alloc_block()
448 block->virtual = (uint8_t *) bufmgr_fake->virtual + in alloc_block()
449 block->mem->ofs - bufmgr_fake->low_offset; in alloc_block()
460 free_block(drm_intel_bufmgr_fake *bufmgr_fake, struct block *block, in free_block() argument
497 drm_intel_bufmgr_fake *bufmgr_fake = in alloc_backing_store() local
525 drm_intel_bufmgr_fake *bufmgr_fake = in set_dirty() local
540 evict_lru(drm_intel_bufmgr_fake *bufmgr_fake, unsigned int max_fence) in evict_lru() argument
546 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { in evict_lru()
559 free_block(bufmgr_fake, block, 0); in evict_lru()
567 evict_mru(drm_intel_bufmgr_fake *bufmgr_fake) in evict_mru() argument
573 DRMLISTFOREACHSAFEREVERSE(block, tmp, &bufmgr_fake->lru) { in evict_mru()
582 free_block(bufmgr_fake, block, 0); in evict_mru()
593 clear_fenced(drm_intel_bufmgr_fake *bufmgr_fake, unsigned int fence_cookie) in clear_fenced() argument
598 bufmgr_fake->last_fence = fence_cookie; in clear_fenced()
599 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->fenced) { in clear_fenced()
602 if (_fence_test(bufmgr_fake, block->fence)) { in clear_fenced()
616 DRMLISTADDTAIL(block, &bufmgr_fake->lru); in clear_fenced()
626 bufmgr_fake->last_fence); in clear_fenced()
636 fence_blocks(drm_intel_bufmgr_fake *bufmgr_fake, unsigned fence) in fence_blocks() argument
640 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->on_hardware) { in fence_blocks()
651 DRMLISTADDTAIL(block, &bufmgr_fake->fenced); in fence_blocks()
654 assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); in fence_blocks()
660 drm_intel_bufmgr_fake *bufmgr_fake = in evict_and_alloc_block() local
674 if (!bufmgr_fake->thrashing) { in evict_and_alloc_block()
675 while (evict_lru(bufmgr_fake, 0)) in evict_and_alloc_block()
682 if (bufmgr_fake->thrashing) in evict_and_alloc_block()
683 bufmgr_fake->thrashing = 20; in evict_and_alloc_block()
689 while (!DRMLISTEMPTY(&bufmgr_fake->fenced)) { in evict_and_alloc_block()
690 uint32_t fence = bufmgr_fake->fenced.next->fence; in evict_and_alloc_block()
691 _fence_wait_internal(bufmgr_fake, fence); in evict_and_alloc_block()
697 if (!DRMLISTEMPTY(&bufmgr_fake->on_hardware)) { in evict_and_alloc_block()
698 while (!DRMLISTEMPTY(&bufmgr_fake->fenced)) { in evict_and_alloc_block()
699 uint32_t fence = bufmgr_fake->fenced.next->fence; in evict_and_alloc_block()
700 _fence_wait_internal(bufmgr_fake, fence); in evict_and_alloc_block()
703 if (!bufmgr_fake->thrashing) { in evict_and_alloc_block()
706 bufmgr_fake->thrashing = 20; in evict_and_alloc_block()
712 while (evict_mru(bufmgr_fake)) in evict_and_alloc_block()
729 drm_intel_bufmgr_fake_wait_idle(drm_intel_bufmgr_fake *bufmgr_fake) in drm_intel_bufmgr_fake_wait_idle() argument
733 cookie = _fence_emit_internal(bufmgr_fake); in drm_intel_bufmgr_fake_wait_idle()
734 _fence_wait_internal(bufmgr_fake, cookie); in drm_intel_bufmgr_fake_wait_idle()
746 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_wait_rendering_locked() local
753 _fence_wait_internal(bufmgr_fake, bo_fake->block->fence); in drm_intel_fake_bo_wait_rendering_locked()
759 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_wait_rendering() local
762 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_wait_rendering()
764 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_wait_rendering()
774 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_contended_lock_take() local
777 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_contended_lock_take()
779 bufmgr_fake->need_fence = 1; in drm_intel_bufmgr_fake_contended_lock_take()
780 bufmgr_fake->fail = 0; in drm_intel_bufmgr_fake_contended_lock_take()
786 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_bufmgr_fake_contended_lock_take()
791 assert(DRMLISTEMPTY(&bufmgr_fake->fenced)); in drm_intel_bufmgr_fake_contended_lock_take()
792 assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); in drm_intel_bufmgr_fake_contended_lock_take()
794 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { in drm_intel_bufmgr_fake_contended_lock_take()
795 assert(_fence_test(bufmgr_fake, block->fence)); in drm_intel_bufmgr_fake_contended_lock_take()
799 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_contended_lock_take()
808 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_fake_bo_alloc() local
811 bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_fake_bo_alloc()
830 bo_fake->id = ++bufmgr_fake->buf_nr; in drm_intel_fake_bo_alloc()
873 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_bo_fake_alloc_static() local
876 bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bo_fake_alloc_static()
889 bo_fake->id = ++bufmgr_fake->buf_nr; in drm_intel_bo_fake_alloc_static()
903 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_reference() local
907 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_reference()
909 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_reference()
923 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unreference_locked() local
932 free_block(bufmgr_fake, bo_fake->block, 1); in drm_intel_fake_bo_unreference_locked()
950 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unreference() local
953 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_unreference()
955 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_unreference()
968 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_bo_fake_disable_backing_store() local
972 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_bo_fake_disable_backing_store()
991 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_bo_fake_disable_backing_store()
1001 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_map_locked() local
1008 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_fake_bo_map_locked()
1032 bufmgr_fake->fail = 1; in drm_intel_fake_bo_map_locked()
1074 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_map() local
1078 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_map()
1080 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_map()
1088 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unmap_locked() local
1110 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unmap() local
1114 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_unmap()
1116 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_unmap()
1139 drm_intel_fake_kick_all_locked(drm_intel_bufmgr_fake *bufmgr_fake) in drm_intel_fake_kick_all_locked() argument
1143 bufmgr_fake->performed_rendering = 0; in drm_intel_fake_kick_all_locked()
1146 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->on_hardware) { in drm_intel_fake_kick_all_locked()
1150 free_block(bufmgr_fake, block, 0); in drm_intel_fake_kick_all_locked()
1162 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_fake_bo_validate() local
1165 bufmgr_fake = (drm_intel_bufmgr_fake *) bo->bufmgr; in drm_intel_fake_bo_validate()
1178 bufmgr_fake->need_fence = 1; in drm_intel_fake_bo_validate()
1184 bufmgr_fake->fail = 1; in drm_intel_fake_bo_validate()
1206 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_fake_bo_validate()
1223 DRMLISTADDTAIL(bo_fake->block, &bufmgr_fake->on_hardware); in drm_intel_fake_bo_validate()
1226 bufmgr_fake->need_fence = 1; in drm_intel_fake_bo_validate()
1234 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_fake_fence_validated() local
1237 cookie = _fence_emit_internal(bufmgr_fake); in drm_intel_fake_fence_validated()
1238 fence_blocks(bufmgr_fake, cookie); in drm_intel_fake_fence_validated()
1246 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_fake_destroy() local
1248 pthread_mutex_destroy(&bufmgr_fake->lock); in drm_intel_fake_destroy()
1249 mmDestroy(bufmgr_fake->heap); in drm_intel_fake_destroy()
1258 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_emit_reloc() local
1265 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_emit_reloc()
1293 if (bufmgr_fake->debug) { in drm_intel_fake_emit_reloc()
1304 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_emit_reloc()
1335 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_reloc_and_validate_buffer() local
1382 bufmgr_fake->performed_rendering = 1; in drm_intel_fake_reloc_and_validate_buffer()
1391 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_bo_fake_post_submit() local
1423 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_set_exec_callback() local
1425 bufmgr_fake->exec = exec; in drm_intel_bufmgr_fake_set_exec_callback()
1426 bufmgr_fake->exec_priv = priv; in drm_intel_bufmgr_fake_set_exec_callback()
1433 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_exec() local
1440 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1442 bufmgr_fake->performed_rendering = 0; in drm_intel_fake_bo_exec()
1451 if (bufmgr_fake->fail == 1) { in drm_intel_fake_bo_exec()
1454 drm_intel_fake_kick_all_locked(bufmgr_fake); in drm_intel_fake_bo_exec()
1455 bufmgr_fake->fail = 0; in drm_intel_fake_bo_exec()
1458 mmDumpMemInfo(bufmgr_fake->heap); in drm_intel_fake_bo_exec()
1463 if (bufmgr_fake->exec != NULL) { in drm_intel_fake_bo_exec()
1464 ret = bufmgr_fake->exec(bo, used, bufmgr_fake->exec_priv); in drm_intel_fake_bo_exec()
1466 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1478 (bufmgr_fake->fd, DRM_I915_BATCHBUFFER, &batch, in drm_intel_fake_bo_exec()
1481 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1490 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1505 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_check_aperture_space() local
1521 if (sz > bufmgr_fake->size) { in drm_intel_fake_check_aperture_space()
1523 sz / 1024, bufmgr_fake->size / 1024); in drm_intel_fake_check_aperture_space()
1528 bufmgr_fake->size / 1024); in drm_intel_fake_check_aperture_space()
1542 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_evict_all() local
1545 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_evict_all()
1547 bufmgr_fake->need_fence = 1; in drm_intel_bufmgr_fake_evict_all()
1548 bufmgr_fake->fail = 0; in drm_intel_bufmgr_fake_evict_all()
1554 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_bufmgr_fake_evict_all()
1559 assert(DRMLISTEMPTY(&bufmgr_fake->fenced)); in drm_intel_bufmgr_fake_evict_all()
1560 assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); in drm_intel_bufmgr_fake_evict_all()
1562 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { in drm_intel_bufmgr_fake_evict_all()
1567 free_block(bufmgr_fake, block, 0); in drm_intel_bufmgr_fake_evict_all()
1571 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_evict_all()
1579 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_set_last_dispatch() local
1581 bufmgr_fake->last_dispatch = (volatile int *)last_dispatch; in drm_intel_bufmgr_fake_set_last_dispatch()
1589 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_bufmgr_fake_init() local
1591 bufmgr_fake = calloc(1, sizeof(*bufmgr_fake)); in drm_intel_bufmgr_fake_init()
1593 if (pthread_mutex_init(&bufmgr_fake->lock, NULL) != 0) { in drm_intel_bufmgr_fake_init()
1594 free(bufmgr_fake); in drm_intel_bufmgr_fake_init()
1599 DRMINITLISTHEAD(&bufmgr_fake->fenced); in drm_intel_bufmgr_fake_init()
1600 DRMINITLISTHEAD(&bufmgr_fake->on_hardware); in drm_intel_bufmgr_fake_init()
1601 DRMINITLISTHEAD(&bufmgr_fake->lru); in drm_intel_bufmgr_fake_init()
1603 bufmgr_fake->low_offset = low_offset; in drm_intel_bufmgr_fake_init()
1604 bufmgr_fake->virtual = low_virtual; in drm_intel_bufmgr_fake_init()
1605 bufmgr_fake->size = size; in drm_intel_bufmgr_fake_init()
1606 bufmgr_fake->heap = mmInit(low_offset, size); in drm_intel_bufmgr_fake_init()
1609 bufmgr_fake->bufmgr.bo_alloc = drm_intel_fake_bo_alloc; in drm_intel_bufmgr_fake_init()
1610 bufmgr_fake->bufmgr.bo_alloc_for_render = drm_intel_fake_bo_alloc; in drm_intel_bufmgr_fake_init()
1611 bufmgr_fake->bufmgr.bo_alloc_tiled = drm_intel_fake_bo_alloc_tiled; in drm_intel_bufmgr_fake_init()
1612 bufmgr_fake->bufmgr.bo_reference = drm_intel_fake_bo_reference; in drm_intel_bufmgr_fake_init()
1613 bufmgr_fake->bufmgr.bo_unreference = drm_intel_fake_bo_unreference; in drm_intel_bufmgr_fake_init()
1614 bufmgr_fake->bufmgr.bo_map = drm_intel_fake_bo_map; in drm_intel_bufmgr_fake_init()
1615 bufmgr_fake->bufmgr.bo_unmap = drm_intel_fake_bo_unmap; in drm_intel_bufmgr_fake_init()
1616 bufmgr_fake->bufmgr.bo_subdata = drm_intel_fake_bo_subdata; in drm_intel_bufmgr_fake_init()
1617 bufmgr_fake->bufmgr.bo_wait_rendering = in drm_intel_bufmgr_fake_init()
1619 bufmgr_fake->bufmgr.bo_emit_reloc = drm_intel_fake_emit_reloc; in drm_intel_bufmgr_fake_init()
1620 bufmgr_fake->bufmgr.destroy = drm_intel_fake_destroy; in drm_intel_bufmgr_fake_init()
1621 bufmgr_fake->bufmgr.bo_exec = drm_intel_fake_bo_exec; in drm_intel_bufmgr_fake_init()
1622 bufmgr_fake->bufmgr.check_aperture_space = in drm_intel_bufmgr_fake_init()
1624 bufmgr_fake->bufmgr.debug = 0; in drm_intel_bufmgr_fake_init()
1626 bufmgr_fake->fd = fd; in drm_intel_bufmgr_fake_init()
1627 bufmgr_fake->last_dispatch = (volatile int *)last_dispatch; in drm_intel_bufmgr_fake_init()
1629 return &bufmgr_fake->bufmgr; in drm_intel_bufmgr_fake_init()