diff options
author | Eric Anholt <eric@anholt.net> | 2008-06-05 08:44:46 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2008-06-05 08:45:39 -0700 |
commit | d198e9b091e919a90895e551e48fb30d36a849ef (patch) | |
tree | cce21f597944a58aa74f56b41df312c1dc2274ce /libdrm | |
parent | 0903de0c8f7d2566c1bd65600142a71572eec07e (diff) |
Add a function to bufmgr_fake to evict all buffers in the GTT.
This will be used by the X Server for VT switch.
Diffstat (limited to 'libdrm')
-rw-r--r-- | libdrm/intel/intel_bufmgr.h | 1 | ||||
-rw-r--r-- | libdrm/intel/intel_bufmgr_fake.c | 35 |
2 files changed, 35 insertions, 1 deletions
diff --git a/libdrm/intel/intel_bufmgr.h b/libdrm/intel/intel_bufmgr.h index b9542eab..1cf0d518 100644 --- a/libdrm/intel/intel_bufmgr.h +++ b/libdrm/intel/intel_bufmgr.h @@ -85,6 +85,7 @@ void intel_bo_fake_disable_backing_store(dri_bo *bo, void (*invalidate_cb)(dri_bo *bo, void *ptr), void *ptr); +void intel_bufmgr_fake_evict_all(dri_bufmgr *bufmgr); int intel_bo_emit_reloc(dri_bo *reloc_buf, uint32_t read_domains, uint32_t write_domain, diff --git a/libdrm/intel/intel_bufmgr_fake.c b/libdrm/intel/intel_bufmgr_fake.c index 1bddbeab..3f5a22d3 100644 --- a/libdrm/intel/intel_bufmgr_fake.c +++ b/libdrm/intel/intel_bufmgr_fake.c @@ -125,7 +125,6 @@ typedef struct _bufmgr_fake { * List of blocks which have an expired fence and are ready to be evicted. */ struct block lru; - /* then to bufmgr->lru or free() */ unsigned int last_fence; @@ -1141,6 +1140,40 @@ dri_fake_check_aperture_space(dri_bo *bo) return 0; } +/** + * Evicts all buffers, waiting for fences to pass and copying contents out + * as necessary. + * + * Used by the X Server on LeaveVT, when the card memory is no longer our + * own. + */ +void +intel_bufmgr_fake_evict_all(dri_bufmgr *bufmgr) +{ + dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bufmgr; + struct block *block, *tmp; + + bufmgr_fake->need_fence = 1; + bufmgr_fake->fail = 0; + + /* Wait for hardware idle. We don't know where acceleration has been + * happening, so we'll need to wait anyway before letting anything get + * put on the card again. + */ + dri_bufmgr_fake_wait_idle(bufmgr_fake); + + /* Check that we hadn't released the lock without having fenced the last + * set of buffers. + */ + assert(DRMLISTEMPTY(&bufmgr_fake->fenced)); + assert(DRMLISTEMPTY(&bufmgr_fake->on_hardware)); + + DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->lru) { + /* Releases the memory, and memcpys dirty contents out if necessary. */ + free_block(bufmgr_fake, block); + } +} + dri_bufmgr * intel_bufmgr_fake_init(unsigned long low_offset, void *low_virtual, unsigned long size, |