diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-31 12:58:19 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-31 23:09:38 +0100 |
commit | 8b358076f2b2d6a6d69e7511735316dc51dd9ec5 (patch) | |
tree | af7665a67e704a049475a0253d7245444143b898 /src | |
parent | ef24cb1b223486d7dfe57f33c28d8692f9857c98 (diff) |
sna: Query the engine residency on foreign bo before use
Since knowing which ring the bo is currently active on is important when
considering the impact of semaphores on the next operation, be sure to
query it on foreign bo before we use them.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_accel.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index b6510e75..0bd3bb60 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -52,6 +52,7 @@ #include <sys/time.h> #include <sys/mman.h> +#include <sys/ioctl.h> #include <unistd.h> #ifdef HAVE_VALGRIND @@ -3270,6 +3271,35 @@ __sna_pixmap_for_gpu(struct sna *sna, PixmapPtr pixmap, unsigned flags) return priv; } +inline static void sna_pixmap_unclean(struct sna *sna, struct sna_pixmap *priv) +{ + struct drm_i915_gem_busy busy; + + assert(DAMAGE_IS_ALL(priv->gpu_damage)); + assert(priv->gpu_bo); + assert(priv->gpu_bo->proxy == NULL); + assert_pixmap_map(priv->pixmap, priv); + + sna_damage_destroy(&priv->cpu_damage); + list_del(&priv->flush_list); + + if ((priv->gpu_bo->needs_flush & priv->flush) == 0 || + priv->gpu_bo->exec == NULL) + return; + + busy.handle = priv->gpu_bo->handle; + busy.busy = 0; + ioctl(sna->kgem.fd, DRM_IOCTL_I915_GEM_BUSY, &busy); + + if (busy.busy) { + unsigned mode = KGEM_RENDER; + if (busy.busy & (0xfffe << 16)) + mode = KGEM_BLT; + kgem_bo_mark_busy(&sna->kgem, priv->gpu_bo, mode); + } else + __kgem_bo_clear_busy(priv->gpu_bo); +} + struct sna_pixmap * sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int flags) { @@ -3347,10 +3377,8 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl if (sna_damage_is_all(&priv->gpu_damage, pixmap->drawable.width, pixmap->drawable.height)) { - assert(priv->gpu_bo); - assert(priv->gpu_bo->proxy == NULL); - sna_damage_destroy(&priv->cpu_damage); - list_del(&priv->flush_list); + DBG(("%s: already all-damaged\n", __FUNCTION__)); + sna_pixmap_unclean(sna, priv); goto done; } @@ -4168,12 +4196,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) pixmap->drawable.width, pixmap->drawable.height)) { DBG(("%s: already all-damaged\n", __FUNCTION__)); - assert(DAMAGE_IS_ALL(priv->gpu_damage)); - assert(priv->gpu_bo); - assert(priv->gpu_bo->proxy == NULL); - assert_pixmap_map(pixmap, priv); - sna_damage_destroy(&priv->cpu_damage); - list_del(&priv->flush_list); + sna_pixmap_unclean(sna, priv); goto active; } |