From e67aece46301ebb77d5fce7ac687a03713956fef Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 5 Mar 2013 21:43:20 +0000 Subject: sna: Assert that the pixmap is not pinned before releasing the GPU bo Nothing suspicious in this set, just an extra dab of paranoia. Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 4 ++++ src/sna/sna_display.c | 2 ++ src/sna/sna_dri.c | 1 + src/sna/sna_io.c | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index e12cb073..25b69c93 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -2659,6 +2659,7 @@ sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box, DBG(("%s: cached upload proxy, discard and revert to GPU\n", __FUNCTION__)); assert(priv->gpu_damage == NULL); + assert(!priv->pinned); kgem_bo_destroy(&to_sna_from_pixmap(pixmap)->kgem, priv->gpu_bo); priv->gpu_bo = NULL; @@ -3100,6 +3101,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) if (flags & MOVE_WRITE && priv->gpu_bo && priv->gpu_bo->proxy) { DBG(("%s: discarding cached upload buffer\n", __FUNCTION__)); assert(priv->gpu_damage == NULL); + assert(!priv->pinned); kgem_bo_destroy(&sna->kgem, priv->gpu_bo); priv->gpu_bo = NULL; } @@ -4274,6 +4276,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc, if (region_subsumes_damage(region, dst_priv->cpu_damage)) { DBG(("%s: discarding existing CPU damage\n", __FUNCTION__)); if (dst_priv->gpu_bo && dst_priv->gpu_bo->proxy) { + assert(!dst_priv->pinned); kgem_bo_destroy(&sna->kgem, dst_priv->gpu_bo); dst_priv->gpu_bo = NULL; } @@ -11815,6 +11818,7 @@ sna_poly_fill_rect(DrawablePtr draw, GCPtr gc, int n, xRectangle *rect) DBG(("%s: discarding existing CPU damage\n", __FUNCTION__)); if (priv->gpu_bo && priv->gpu_bo->proxy) { assert(priv->gpu_damage == NULL); + assert(!priv->pinned); kgem_bo_destroy(&sna->kgem, priv->gpu_bo); priv->gpu_bo = NULL; } diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index e54c9862..27684245 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3282,6 +3282,8 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo) { struct sna_pixmap *priv = sna_pixmap(pixmap); + assert((priv->pinned & PIN_PRIME) == 0); + if (priv->mapped) { assert(!priv->shm && priv->stride); pixmap->devPrivate.ptr = PTR(priv->ptr); diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index e3bca1b1..ebcbdcf6 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -499,6 +499,7 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo) assert(bo->proxy == NULL); assert(bo->flush); assert(priv->pinned & PIN_DRI); + assert((priv->pinned & PIN_PRIME) == 0); assert(priv->flush); /* Post damage on the new front buffer so that listeners, such diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index f89cd89e..41322ad2 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -1388,6 +1388,8 @@ bool sna_replace(struct sna *sna, pixmap->drawable.bitsPerPixel, bo->tiling, busy)); + assert(!sna_pixmap(pixmap)->pinned); + if (!busy && upload_inplace__tiled(kgem, bo)) { BoxRec box; @@ -1490,6 +1492,8 @@ struct kgem_bo *sna_replace__xor(struct sna *sna, pixmap->drawable.bitsPerPixel, bo->tiling)); + assert(!sna_pixmap(pixmap)->pinned); + if (kgem_bo_is_busy(bo)) { struct kgem_bo *new_bo; -- cgit v1.2.3