xf86-video-intel: 3 commits - src/sna/kgem.c src/sna/sna_accel.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Aug 27 12:54:06 PDT 2012


 src/sna/kgem.c      |   10 +++++-
 src/sna/sna_accel.c |   79 +++++++++++++++-------------------------------------
 2 files changed, 31 insertions(+), 58 deletions(-)

New commits:
commit 26c731efc2048663b6a19a7ed7db0e94243ab30f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 27 20:50:08 2012 +0100

    sna: Ensure that we create a GTT mapping for the inplace upload buffer
    
    As the code will optimistically convert a request for a GTT mapping into
    a CPU mapping if the object is still in the CPU domain, we need to
    overrule that in this case where we explicitly want to write directly
    into the GTT and furthermore keep the buffer around in an upload cache.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=51422
    References: https://bugs.freedesktop.org/show_bug.cgi?id=52299
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index c9ab2c2..dc7c95d 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -4377,6 +4377,9 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
 		if (old) {
 			DBG(("%s: reusing handle=%d for buffer\n",
 			     __FUNCTION__, old->handle));
+			assert(kgem_bo_is_mappable(kgem, old));
+			assert(!old->snoop);
+			assert(old->rq == NULL);
 
 			bo = buffer_alloc();
 			if (bo == NULL)
@@ -4388,7 +4391,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
 			assert(bo->mmapped);
 			assert(bo->base.refcnt == 1);
 
-			bo->mem = kgem_bo_map(kgem, &bo->base);
+			bo->mem = kgem_bo_map__gtt(kgem, &bo->base);
 			if (bo->mem) {
 				alloc = num_pages(&bo->base);
 				goto init;
@@ -4398,6 +4401,8 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
 			}
 		}
 	}
+#else
+	flags &= ~KGEM_BUFFER_INPLACE;
 #endif
 	/* Be more parsimonious with pwrite/pread/cacheable buffers */
 	if ((flags & KGEM_BUFFER_INPLACE) == 0)
commit 2cbf88980ede50370b97f32e565dea33db16ac44
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 27 20:07:17 2012 +0100

    sna: Force the stall if using a busy ShmPixmap bo with PutImage
    
    As we will stall in the near future to serialise access with the
    ShmPixmap, we may as well stall first and do a simple copy using the
    CPU in this highly unlikely scenario.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 06b7e26..9c493c2 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3311,59 +3311,28 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 		 * However, we can queue some writes to the GPU bo to avoid
 		 * the wait. Or we can try to replace the CPU bo.
 		 */
-		if (__kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) {
-			if (priv->cpu_bo->flush) {
-				if (sna_put_image_upload_blt(drawable, gc, region,
-							     x, y, w, h, bits, stride)) {
-					if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
-						if (region_subsumes_drawable(region, &pixmap->drawable))
-							sna_damage_destroy(&priv->cpu_damage);
-						else
-							sna_damage_subtract(&priv->cpu_damage, region);
-						if (priv->cpu_damage == NULL) {
-							sna_damage_all(&priv->gpu_damage,
-								       pixmap->drawable.width,
-								       pixmap->drawable.height);
-							list_del(&priv->list);
-							priv->undamaged = false;
-						} else
-							sna_damage_add(&priv->gpu_damage, region);
-					}
-
-					assert_pixmap_damage(pixmap);
-					priv->clear = false;
-					priv->cpu = false;
-					return true;
-				}
-			} else {
-				DBG(("%s: cpu bo will stall, upload damage and discard\n",
-				     __FUNCTION__));
-				if (priv->cpu_damage) {
-					if (!region_subsumes_drawable(region, &pixmap->drawable)) {
-						sna_damage_subtract(&priv->cpu_damage, region);
-						if (!sna_pixmap_move_to_gpu(pixmap,
-									    MOVE_WRITE))
-							return false;
-					} else {
-						sna_damage_destroy(&priv->cpu_damage);
-						priv->undamaged = false;
-					}
-				}
-				if (priv->undamaged) {
-					sna_damage_all(&priv->gpu_damage,
-						       pixmap->drawable.width,
-						       pixmap->drawable.height);
-					list_del(&priv->list);
+		if (!priv->shm && __kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) {
+			assert(!priv->cpu_bo->flush);
+			DBG(("%s: cpu bo will stall, upload damage and discard\n",
+			     __FUNCTION__));
+			if (priv->cpu_damage) {
+				if (!region_subsumes_drawable(region, &pixmap->drawable)) {
+					sna_damage_subtract(&priv->cpu_damage, region);
+					if (!sna_pixmap_move_to_gpu(pixmap,
+								    MOVE_WRITE))
+						return false;
+				} else {
+					sna_damage_destroy(&priv->cpu_damage);
 					priv->undamaged = false;
 				}
-				assert(!priv->cpu_bo->flush);
-				assert(!priv->shm);
-				sna_pixmap_free_cpu(sna, priv);
+				assert(priv->cpu_damage == NULL);
 			}
+			if (!priv->undamaged)
+				sna_damage_all(&priv->gpu_damage,
+					       pixmap->drawable.width,
+					       pixmap->drawable.height);
+			sna_pixmap_free_cpu(sna, priv);
 		}
-
-		if (priv->cpu_bo)
-			kgem_bo_sync__cpu(&sna->kgem, priv->cpu_bo);
 	}
 
 	if (priv->mapped) {
@@ -3376,15 +3345,15 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 	    !sna_pixmap_alloc_cpu(sna, pixmap, priv, false))
 		return true;
 
+	if (priv->cpu_bo) {
+		DBG(("%s: syncing CPU bo\n", __FUNCTION__));
+		kgem_bo_sync__cpu(&sna->kgem, priv->cpu_bo);
+	}
+
 	if (priv->clear) {
 		DBG(("%s: applying clear [%08x]\n",
 		     __FUNCTION__, priv->clear_color));
 
-		if (priv->cpu_bo) {
-			DBG(("%s: syncing CPU bo\n", __FUNCTION__));
-			kgem_bo_sync__cpu(&sna->kgem, priv->cpu_bo);
-		}
-
 		if (priv->clear_color == 0) {
 			memset(pixmap->devPrivate.ptr,
 			       0, pixmap->devKind * pixmap->drawable.height);
@@ -3403,8 +3372,6 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 			       pixmap->drawable.height);
 		sna_pixmap_free_gpu(sna, priv);
 		priv->undamaged = false;
-		priv->clear = false;
-		priv->cpu = false;
 	}
 
 	if (!DAMAGE_IS_ALL(priv->cpu_damage)) {
commit 705103d77e6b80d796a4535cade96cb6e9ebece3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 27 20:07:19 2012 +0100

    sna: Add a modicum of DBG to kgem_is_idle()
    
    Print out the handle of the bo we just checked.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 92ab02f..c9ab2c2 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -353,6 +353,7 @@ kgem_busy(struct kgem *kgem, int handle)
 	busy.handle = handle;
 	busy.busy = !kgem->wedged;
 	(void)drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
+	DBG(("%s: handle=%d, busy=%d, wedged=%d\n", busy.busy, kgem->wedged));
 
 	return busy.busy;
 }
@@ -1769,7 +1770,7 @@ bool __kgem_is_idle(struct kgem *kgem)
 		return false;
 	}
 
-	DBG(("%s: gpu idle\n", __FUNCTION__));
+	DBG(("%s: gpu idle (handle=%d)\n", __FUNCTION__, rq->bo->handle));
 	kgem_retire__requests(kgem);
 	assert(list_is_empty(&kgem->requests));
 	return true;


More information about the xorg-commit mailing list