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

Chris Wilson ickle at kemper.freedesktop.org
Tue Sep 4 03:08:37 PDT 2012


 src/sna/kgem.c      |   44 +++++++++++++++++++++++++++++++++++++++++++-
 src/sna/kgem.h      |    1 +
 src/sna/sna_accel.c |   19 +++++++++++--------
 3 files changed, 55 insertions(+), 9 deletions(-)

New commits:
commit d0684d55e3a62c231c92a68403cf100c9e18351b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 4 11:05:43 2012 +0100

    sna: Fixup CREATE_USAGE_SHARED
    
    The DRI2 code tries to create pixmaps with non-zero width/height,
    whoops.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index d073c9f..ae0a604 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -3808,6 +3808,48 @@ static void kgem_trim_vma_cache(struct kgem *kgem, int type, int bucket)
 	}
 }
 
+void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo)
+{
+	void *ptr;
+
+	DBG(("%s: handle=%d, offset=%d, tiling=%d, map=%p, domain=%d\n", __FUNCTION__,
+	     bo->handle, bo->presumed_offset, bo->tiling, bo->map, bo->domain));
+
+	assert(!bo->purged);
+	assert(bo->proxy == NULL);
+	assert(list_is_empty(&bo->list));
+
+	if (bo->tiling == I915_TILING_NONE && !bo->scanout && kgem->has_llc) {
+		DBG(("%s: converting request for GTT map into CPU map\n",
+		     __FUNCTION__));
+		return kgem_bo_map__cpu(kgem, bo);
+	}
+
+	if (IS_CPU_MAP(bo->map))
+		kgem_bo_release_map(kgem, bo);
+
+	ptr = bo->map;
+	if (ptr == NULL) {
+		assert(kgem_bo_size(bo) <= kgem->aperture_mappable / 2);
+
+		kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo));
+
+		ptr = __kgem_bo_map__gtt(kgem, bo);
+		if (ptr == NULL)
+			return NULL;
+
+		/* Cache this mapping to avoid the overhead of an
+		 * excruciatingly slow GTT pagefault. This is more an
+		 * issue with compositing managers which need to frequently
+		 * flush CPU damage to their GPU bo.
+		 */
+		bo->map = ptr;
+		DBG(("%s: caching GTT vma for %d\n", __FUNCTION__, bo->handle));
+	}
+
+	return ptr;
+}
+
 void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 {
 	void *ptr;
@@ -3817,8 +3859,8 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 
 	assert(!bo->purged);
 	assert(bo->proxy == NULL);
-	assert(bo->exec == NULL);
 	assert(list_is_empty(&bo->list));
+	assert(bo->exec == NULL);
 
 	if (bo->tiling == I915_TILING_NONE && !bo->scanout &&
 	    (kgem->has_llc || bo->domain == DOMAIN_CPU)) {
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 33cd3ff..0d5384b 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -410,6 +410,7 @@ uint32_t kgem_add_reloc(struct kgem *kgem,
 			uint32_t delta);
 
 void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo);
+void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo);
 void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo);
 void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo);
 void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo);
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index b9bf93b..21d0ef8 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -943,8 +943,7 @@ sna_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave, void **fd_handle)
 	assert(priv->gpu_bo->tiling == I915_TILING_NONE);
 
 	/* And export the bo->pitch via pixmap->devKind */
-	pixmap->devPrivate.ptr =
-		kgem_bo_map(&sna->kgem, priv->gpu_bo);
+	pixmap->devPrivate.ptr = kgem_bo_map__async(&sna->kgem, priv->gpu_bo);
 	if (pixmap->devPrivate.ptr == NULL)
 		return FALSE;
 
@@ -1038,19 +1037,23 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 	DBG(("%s(%d, %d, %d, usage=%x)\n", __FUNCTION__,
 	     width, height, depth, usage));
 
+	if ((width|height) == 0) {
 #ifdef CREATE_PIXMAP_USAGE_SHARED
-	if (usage == CREATE_PIXMAP_USAGE_SHARED) {
-		assert((width|height) == 0);
-		return sna_create_pixmap_shared(sna, screen, depth);
-	}
+		if (usage == CREATE_PIXMAP_USAGE_SHARED)
+			return sna_create_pixmap_shared(sna, screen, depth);
 #endif
-
-	if ((width|height) == 0) {
 		usage = -1;
 		goto fallback;
 	}
 	assert(width && height);
 
+#ifdef CREATE_PIXMAP_USAGE_SHARED
+	if (usage == CREATE_PIXMAP_USAGE_SHARED)
+		return sna_pixmap_create_scratch(screen,
+						 width, height, depth,
+						 I915_TILING_NONE);
+#endif
+
 	flags = kgem_can_create_2d(&sna->kgem, width, height, depth);
 	if (flags == 0) {
 		DBG(("%s: can not use GPU, just creating shadow\n",


More information about the xorg-commit mailing list