Lines Matching refs:bufmgr_fake
53 if (bufmgr_fake->bufmgr.debug) \
224 static int clear_fenced(drm_intel_bufmgr_fake *bufmgr_fake,
251 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_set_fence_callback() local
253 bufmgr_fake->fence_emit = emit; in drm_intel_bufmgr_fake_set_fence_callback()
254 bufmgr_fake->fence_wait = wait; in drm_intel_bufmgr_fake_set_fence_callback()
255 bufmgr_fake->fence_priv = priv; in drm_intel_bufmgr_fake_set_fence_callback()
259 _fence_emit_internal(drm_intel_bufmgr_fake *bufmgr_fake) in _fence_emit_internal() argument
264 if (bufmgr_fake->fence_emit != NULL) { in _fence_emit_internal()
265 seq = bufmgr_fake->fence_emit(bufmgr_fake->fence_priv); in _fence_emit_internal()
270 ret = drmCommandWriteRead(bufmgr_fake->fd, DRM_I915_IRQ_EMIT, in _fence_emit_internal()
282 _fence_wait_internal(drm_intel_bufmgr_fake *bufmgr_fake, int seq) in _fence_wait_internal() argument
289 if (bufmgr_fake->fence_wait != NULL) { in _fence_wait_internal()
290 bufmgr_fake->fence_wait(seq, bufmgr_fake->fence_priv); in _fence_wait_internal()
291 clear_fenced(bufmgr_fake, seq); in _fence_wait_internal()
374 hw_seq = *bufmgr_fake->last_dispatch; in _fence_wait_internal()
380 ret = drmCommandWrite(bufmgr_fake->fd, DRM_I915_IRQ_WAIT, in _fence_wait_internal()
383 kernel_lied = (ret == 0) && (seq - *bufmgr_fake->last_dispatch < in _fence_wait_internal()
388 && (seq - *bufmgr_fake->last_dispatch > 0x40000000)) in _fence_wait_internal()
392 if ((ret == -EBUSY) && (hw_seq != *bufmgr_fake->last_dispatch)) in _fence_wait_internal()
404 clear_fenced(bufmgr_fake, seq); in _fence_wait_internal()
408 _fence_test(drm_intel_bufmgr_fake *bufmgr_fake, unsigned fence) in _fence_test() argument
412 return fence == 0 || FENCE_LTE(fence, bufmgr_fake->last_fence); in _fence_test()
422 drm_intel_bufmgr_fake *bufmgr_fake = in alloc_block() local
433 block->mem = mmAllocMem(bufmgr_fake->heap, sz, align_log2, 0); in alloc_block()
442 DRMLISTADDTAIL(block, &bufmgr_fake->lru); in alloc_block()
444 block->virtual = (uint8_t *) bufmgr_fake->virtual + in alloc_block()
445 block->mem->ofs - bufmgr_fake->low_offset; in alloc_block()
456 free_block(drm_intel_bufmgr_fake *bufmgr_fake, struct block *block, in free_block() argument
493 drm_intel_bufmgr_fake *bufmgr_fake = in alloc_backing_store() local
521 drm_intel_bufmgr_fake *bufmgr_fake = in set_dirty() local
536 evict_lru(drm_intel_bufmgr_fake *bufmgr_fake, unsigned int max_fence) in evict_lru() argument
542 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { in evict_lru()
555 free_block(bufmgr_fake, block, 0); in evict_lru()
563 evict_mru(drm_intel_bufmgr_fake *bufmgr_fake) in evict_mru() argument
569 DRMLISTFOREACHSAFEREVERSE(block, tmp, &bufmgr_fake->lru) { in evict_mru()
578 free_block(bufmgr_fake, block, 0); in evict_mru()
589 clear_fenced(drm_intel_bufmgr_fake *bufmgr_fake, unsigned int fence_cookie) in clear_fenced() argument
594 bufmgr_fake->last_fence = fence_cookie; in clear_fenced()
595 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->fenced) { in clear_fenced()
598 if (_fence_test(bufmgr_fake, block->fence)) { in clear_fenced()
612 DRMLISTADDTAIL(block, &bufmgr_fake->lru); in clear_fenced()
622 bufmgr_fake->last_fence); in clear_fenced()
632 fence_blocks(drm_intel_bufmgr_fake *bufmgr_fake, unsigned fence) in fence_blocks() argument
636 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->on_hardware) { in fence_blocks()
647 DRMLISTADDTAIL(block, &bufmgr_fake->fenced); in fence_blocks()
650 assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); in fence_blocks()
656 drm_intel_bufmgr_fake *bufmgr_fake = in evict_and_alloc_block() local
670 if (!bufmgr_fake->thrashing) { in evict_and_alloc_block()
671 while (evict_lru(bufmgr_fake, 0)) in evict_and_alloc_block()
678 if (bufmgr_fake->thrashing) in evict_and_alloc_block()
679 bufmgr_fake->thrashing = 20; in evict_and_alloc_block()
685 while (!DRMLISTEMPTY(&bufmgr_fake->fenced)) { in evict_and_alloc_block()
686 uint32_t fence = bufmgr_fake->fenced.next->fence; in evict_and_alloc_block()
687 _fence_wait_internal(bufmgr_fake, fence); in evict_and_alloc_block()
693 if (!DRMLISTEMPTY(&bufmgr_fake->on_hardware)) { in evict_and_alloc_block()
694 while (!DRMLISTEMPTY(&bufmgr_fake->fenced)) { in evict_and_alloc_block()
695 uint32_t fence = bufmgr_fake->fenced.next->fence; in evict_and_alloc_block()
696 _fence_wait_internal(bufmgr_fake, fence); in evict_and_alloc_block()
699 if (!bufmgr_fake->thrashing) { in evict_and_alloc_block()
702 bufmgr_fake->thrashing = 20; in evict_and_alloc_block()
708 while (evict_mru(bufmgr_fake)) in evict_and_alloc_block()
725 drm_intel_bufmgr_fake_wait_idle(drm_intel_bufmgr_fake *bufmgr_fake) in drm_intel_bufmgr_fake_wait_idle() argument
729 cookie = _fence_emit_internal(bufmgr_fake); in drm_intel_bufmgr_fake_wait_idle()
730 _fence_wait_internal(bufmgr_fake, cookie); in drm_intel_bufmgr_fake_wait_idle()
742 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_wait_rendering_locked() local
749 _fence_wait_internal(bufmgr_fake, bo_fake->block->fence); in drm_intel_fake_bo_wait_rendering_locked()
755 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_wait_rendering() local
758 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_wait_rendering()
760 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_wait_rendering()
770 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_contended_lock_take() local
773 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_contended_lock_take()
775 bufmgr_fake->need_fence = 1; in drm_intel_bufmgr_fake_contended_lock_take()
776 bufmgr_fake->fail = 0; in drm_intel_bufmgr_fake_contended_lock_take()
782 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_bufmgr_fake_contended_lock_take()
787 assert(DRMLISTEMPTY(&bufmgr_fake->fenced)); in drm_intel_bufmgr_fake_contended_lock_take()
788 assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); in drm_intel_bufmgr_fake_contended_lock_take()
790 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { in drm_intel_bufmgr_fake_contended_lock_take()
791 assert(_fence_test(bufmgr_fake, block->fence)); in drm_intel_bufmgr_fake_contended_lock_take()
795 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_contended_lock_take()
804 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_fake_bo_alloc() local
807 bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_fake_bo_alloc()
826 bo_fake->id = ++bufmgr_fake->buf_nr; in drm_intel_fake_bo_alloc()
869 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_bo_fake_alloc_static() local
872 bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bo_fake_alloc_static()
885 bo_fake->id = ++bufmgr_fake->buf_nr; in drm_intel_bo_fake_alloc_static()
899 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_reference() local
903 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_reference()
905 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_reference()
919 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unreference_locked() local
928 free_block(bufmgr_fake, bo_fake->block, 1); in drm_intel_fake_bo_unreference_locked()
946 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unreference() local
949 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_unreference()
951 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_unreference()
964 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_bo_fake_disable_backing_store() local
968 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_bo_fake_disable_backing_store()
987 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_bo_fake_disable_backing_store()
997 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_map_locked() local
1004 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_fake_bo_map_locked()
1028 bufmgr_fake->fail = 1; in drm_intel_fake_bo_map_locked()
1070 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_map() local
1074 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_map()
1076 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_map()
1084 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unmap_locked() local
1106 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_unmap() local
1110 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_unmap()
1112 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_unmap()
1135 drm_intel_fake_kick_all_locked(drm_intel_bufmgr_fake *bufmgr_fake) in drm_intel_fake_kick_all_locked() argument
1139 bufmgr_fake->performed_rendering = 0; in drm_intel_fake_kick_all_locked()
1142 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->on_hardware) { in drm_intel_fake_kick_all_locked()
1146 free_block(bufmgr_fake, block, 0); in drm_intel_fake_kick_all_locked()
1158 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_fake_bo_validate() local
1161 bufmgr_fake = (drm_intel_bufmgr_fake *) bo->bufmgr; in drm_intel_fake_bo_validate()
1174 bufmgr_fake->need_fence = 1; in drm_intel_fake_bo_validate()
1180 bufmgr_fake->fail = 1; in drm_intel_fake_bo_validate()
1202 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_fake_bo_validate()
1219 DRMLISTADDTAIL(bo_fake->block, &bufmgr_fake->on_hardware); in drm_intel_fake_bo_validate()
1222 bufmgr_fake->need_fence = 1; in drm_intel_fake_bo_validate()
1230 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_fake_fence_validated() local
1233 cookie = _fence_emit_internal(bufmgr_fake); in drm_intel_fake_fence_validated()
1234 fence_blocks(bufmgr_fake, cookie); in drm_intel_fake_fence_validated()
1242 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_fake_destroy() local
1244 pthread_mutex_destroy(&bufmgr_fake->lock); in drm_intel_fake_destroy()
1245 mmDestroy(bufmgr_fake->heap); in drm_intel_fake_destroy()
1254 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_emit_reloc() local
1261 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_emit_reloc()
1289 if (bufmgr_fake->debug) { in drm_intel_fake_emit_reloc()
1300 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_emit_reloc()
1331 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_reloc_and_validate_buffer() local
1378 bufmgr_fake->performed_rendering = 1; in drm_intel_fake_reloc_and_validate_buffer()
1387 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_bo_fake_post_submit() local
1419 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_set_exec_callback() local
1421 bufmgr_fake->exec = exec; in drm_intel_bufmgr_fake_set_exec_callback()
1422 bufmgr_fake->exec_priv = priv; in drm_intel_bufmgr_fake_set_exec_callback()
1429 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_bo_exec() local
1436 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1438 bufmgr_fake->performed_rendering = 0; in drm_intel_fake_bo_exec()
1447 if (bufmgr_fake->fail == 1) { in drm_intel_fake_bo_exec()
1450 drm_intel_fake_kick_all_locked(bufmgr_fake); in drm_intel_fake_bo_exec()
1451 bufmgr_fake->fail = 0; in drm_intel_fake_bo_exec()
1454 mmDumpMemInfo(bufmgr_fake->heap); in drm_intel_fake_bo_exec()
1459 if (bufmgr_fake->exec != NULL) { in drm_intel_fake_bo_exec()
1460 ret = bufmgr_fake->exec(bo, used, bufmgr_fake->exec_priv); in drm_intel_fake_bo_exec()
1462 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1474 (bufmgr_fake->fd, DRM_I915_BATCHBUFFER, &batch, in drm_intel_fake_bo_exec()
1477 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1486 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_fake_bo_exec()
1501 drm_intel_bufmgr_fake *bufmgr_fake = in drm_intel_fake_check_aperture_space() local
1517 if (sz > bufmgr_fake->size) { in drm_intel_fake_check_aperture_space()
1519 sz / 1024, bufmgr_fake->size / 1024); in drm_intel_fake_check_aperture_space()
1524 bufmgr_fake->size / 1024); in drm_intel_fake_check_aperture_space()
1538 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_evict_all() local
1541 pthread_mutex_lock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_evict_all()
1543 bufmgr_fake->need_fence = 1; in drm_intel_bufmgr_fake_evict_all()
1544 bufmgr_fake->fail = 0; in drm_intel_bufmgr_fake_evict_all()
1550 drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); in drm_intel_bufmgr_fake_evict_all()
1555 assert(DRMLISTEMPTY(&bufmgr_fake->fenced)); in drm_intel_bufmgr_fake_evict_all()
1556 assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); in drm_intel_bufmgr_fake_evict_all()
1558 DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { in drm_intel_bufmgr_fake_evict_all()
1563 free_block(bufmgr_fake, block, 0); in drm_intel_bufmgr_fake_evict_all()
1567 pthread_mutex_unlock(&bufmgr_fake->lock); in drm_intel_bufmgr_fake_evict_all()
1575 drm_intel_bufmgr_fake *bufmgr_fake = (drm_intel_bufmgr_fake *) bufmgr; in drm_intel_bufmgr_fake_set_last_dispatch() local
1577 bufmgr_fake->last_dispatch = (volatile int *)last_dispatch; in drm_intel_bufmgr_fake_set_last_dispatch()
1585 drm_intel_bufmgr_fake *bufmgr_fake; in drm_intel_bufmgr_fake_init() local
1587 bufmgr_fake = calloc(1, sizeof(*bufmgr_fake)); in drm_intel_bufmgr_fake_init()
1589 if (pthread_mutex_init(&bufmgr_fake->lock, NULL) != 0) { in drm_intel_bufmgr_fake_init()
1590 free(bufmgr_fake); in drm_intel_bufmgr_fake_init()
1595 DRMINITLISTHEAD(&bufmgr_fake->fenced); in drm_intel_bufmgr_fake_init()
1596 DRMINITLISTHEAD(&bufmgr_fake->on_hardware); in drm_intel_bufmgr_fake_init()
1597 DRMINITLISTHEAD(&bufmgr_fake->lru); in drm_intel_bufmgr_fake_init()
1599 bufmgr_fake->low_offset = low_offset; in drm_intel_bufmgr_fake_init()
1600 bufmgr_fake->virtual = low_virtual; in drm_intel_bufmgr_fake_init()
1601 bufmgr_fake->size = size; in drm_intel_bufmgr_fake_init()
1602 bufmgr_fake->heap = mmInit(low_offset, size); in drm_intel_bufmgr_fake_init()
1605 bufmgr_fake->bufmgr.bo_alloc = drm_intel_fake_bo_alloc; in drm_intel_bufmgr_fake_init()
1606 bufmgr_fake->bufmgr.bo_alloc_for_render = drm_intel_fake_bo_alloc; in drm_intel_bufmgr_fake_init()
1607 bufmgr_fake->bufmgr.bo_alloc_tiled = drm_intel_fake_bo_alloc_tiled; in drm_intel_bufmgr_fake_init()
1608 bufmgr_fake->bufmgr.bo_reference = drm_intel_fake_bo_reference; in drm_intel_bufmgr_fake_init()
1609 bufmgr_fake->bufmgr.bo_unreference = drm_intel_fake_bo_unreference; in drm_intel_bufmgr_fake_init()
1610 bufmgr_fake->bufmgr.bo_map = drm_intel_fake_bo_map; in drm_intel_bufmgr_fake_init()
1611 bufmgr_fake->bufmgr.bo_unmap = drm_intel_fake_bo_unmap; in drm_intel_bufmgr_fake_init()
1612 bufmgr_fake->bufmgr.bo_subdata = drm_intel_fake_bo_subdata; in drm_intel_bufmgr_fake_init()
1613 bufmgr_fake->bufmgr.bo_wait_rendering = in drm_intel_bufmgr_fake_init()
1615 bufmgr_fake->bufmgr.bo_emit_reloc = drm_intel_fake_emit_reloc; in drm_intel_bufmgr_fake_init()
1616 bufmgr_fake->bufmgr.destroy = drm_intel_fake_destroy; in drm_intel_bufmgr_fake_init()
1617 bufmgr_fake->bufmgr.bo_exec = drm_intel_fake_bo_exec; in drm_intel_bufmgr_fake_init()
1618 bufmgr_fake->bufmgr.check_aperture_space = in drm_intel_bufmgr_fake_init()
1620 bufmgr_fake->bufmgr.debug = 0; in drm_intel_bufmgr_fake_init()
1622 bufmgr_fake->fd = fd; in drm_intel_bufmgr_fake_init()
1623 bufmgr_fake->last_dispatch = (volatile int *)last_dispatch; in drm_intel_bufmgr_fake_init()
1625 return &bufmgr_fake->bufmgr; in drm_intel_bufmgr_fake_init()