From 3540554e5a74ccd2ca746482700a9f5657954227 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 11 Feb 2013 11:14:17 +0000 Subject: [PATCH] sna/dri: Couple up the flush pixmap after checking for allocation failures Tidy up the error path not to leave the GPU bo pinned and marked for flushing. Signed-off-by: Chris Wilson --- src/sna/sna_dri.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index 85c2e335..7ad83fc8 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -186,17 +186,6 @@ static struct kgem_bo *sna_pixmap_set_dri(struct sna *sna, if (priv->gpu_bo->tiling != tiling) sna_pixmap_change_tiling(pixmap, tiling); - /* We need to submit any modifications to and reads from this - * buffer before we send any reply to the Client. - * - * As we don't track which Client, we flush for all. - */ - priv->flush = true; - sna_accel_watch_flush(sna, 1); - - /* Don't allow this named buffer to be replaced */ - priv->pinned |= PIN_DRI; - return priv->gpu_bo; } @@ -380,10 +369,29 @@ sna_dri_create_buffer(DrawablePtr draw, goto err; if (pixmap) { + struct sna_pixmap *priv; + assert(attachment == DRI2BufferFrontLeft); + assert(sna_pixmap_get_buffer(pixmap) == NULL); + sna_pixmap_set_buffer(pixmap, buffer); assert(sna_pixmap_get_buffer(pixmap) == buffer); pixmap->refcnt++; + + priv = sna_pixmap(pixmap); + assert(priv->flush == false); + assert((priv->pinned & PIN_DRI) == 0); + + /* Don't allow this named buffer to be replaced */ + priv->pinned |= PIN_DRI; + + /* We need to submit any modifications to and reads from this + * buffer before we send any reply to the Client. + * + * As we don't track which Client, we flush for all. + */ + priv->flush = true; + sna_accel_watch_flush(sna, 1); } assert(bo->flush == true);