intel: Don't call the SW_FINISH ioctl unless a CPU-mapped write was done.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
main
Eric Anholt 2011-10-28 13:12:16 -07:00
parent 77dc16f33d
commit 4cb01eeccf
1 changed files with 21 additions and 9 deletions

View File

@ -196,6 +196,9 @@ struct _drm_intel_bo_gem {
* relocations. * relocations.
*/ */
int reloc_tree_fences; int reloc_tree_fences;
/** Flags that we may need to do the SW_FINSIH ioctl on unmap. */
bool mapped_cpu_write;
}; };
static unsigned int static unsigned int
@ -1051,6 +1054,9 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable)
strerror(errno)); strerror(errno));
} }
if (write_enable)
bo_gem->mapped_cpu_write = true;
pthread_mutex_unlock(&bufmgr_gem->lock); pthread_mutex_unlock(&bufmgr_gem->lock);
return 0; return 0;
@ -1148,21 +1154,27 @@ static int drm_intel_gem_bo_unmap(drm_intel_bo *bo)
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
struct drm_i915_gem_sw_finish sw_finish; struct drm_i915_gem_sw_finish sw_finish;
int ret; int ret = 0;
if (bo == NULL) if (bo == NULL)
return 0; return 0;
pthread_mutex_lock(&bufmgr_gem->lock); pthread_mutex_lock(&bufmgr_gem->lock);
/* Cause a flush to happen if the buffer's pinned for scanout, so the if (bo_gem->mapped_cpu_write) {
* results show up in a timely manner. /* Cause a flush to happen if the buffer's pinned for
*/ * scanout, so the results show up in a timely manner.
sw_finish.handle = bo_gem->gem_handle; * Unlike GTT set domains, this only does work if the
ret = drmIoctl(bufmgr_gem->fd, * buffer should be scanout-related.
DRM_IOCTL_I915_GEM_SW_FINISH, */
&sw_finish); sw_finish.handle = bo_gem->gem_handle;
ret = ret == -1 ? -errno : 0; ret = drmIoctl(bufmgr_gem->fd,
DRM_IOCTL_I915_GEM_SW_FINISH,
&sw_finish);
ret = ret == -1 ? -errno : 0;
bo_gem->mapped_cpu_write = false;
}
bo->virtual = NULL; bo->virtual = NULL;
pthread_mutex_unlock(&bufmgr_gem->lock); pthread_mutex_unlock(&bufmgr_gem->lock);