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

Chris Wilson ickle at kemper.freedesktop.org
Fri May 17 04:12:47 PDT 2013


 src/sna/sna.h       |    3 +++
 src/sna/sna_accel.c |   24 +++++++++++++++++++-----
 src/sna/sna_dri.c   |    7 +++++--
 3 files changed, 27 insertions(+), 7 deletions(-)

New commits:
commit d6c30d1d4df6bcdfa075bd29da7c8aabee20774c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 17 12:11:34 2013 +0100

    sna: Clear the cow_list when discarding the clone upon pixmap destroy
    
    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 a50f4d4..2c78570 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1366,6 +1366,10 @@ static Bool sna_destroy_pixmap(PixmapPtr pixmap)
 
 	if (priv->cow) {
 		struct sna_cow *cow = COW(priv->cow);
+		DBG(("%s: pixmap=%ld discarding cow, refcnt=%d\n",
+		     __FUNCTION__, pixmap->drawable.serialNumber, cow->refcnt));
+		assert(cow->refcnt);
+		list_del(&priv->cow_list);
 		if (!--cow->refcnt)
 			free(cow);
 		priv->cow = NULL;
@@ -1556,8 +1560,9 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 	list_del(&priv->cow_list);
 
 	if (!--cow->refcnt) {
+		assert(list_is_empty(&cow->list));
 		free(cow);
-	} else if (IS_COW_OWNER(priv->cow)) {
+	} else if (IS_COW_OWNER(priv->cow) && priv->pinned) {
 		PixmapPtr pixmap = priv->pixmap;
 		struct kgem_bo *bo;
 		BoxRec box;
@@ -1589,7 +1594,6 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 			return false;
 		}
 
-		cow->bo = bo;
 		assert(!list_is_empty(&cow->list));
 		while (!list_is_empty(&cow->list)) {
 			struct sna_pixmap *clone;
@@ -1598,9 +1602,11 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 						 struct sna_pixmap, cow_list);
 			list_del(&clone->cow_list);
 
+			assert(clone->gpu_bo == cow->bo);
 			kgem_bo_destroy(&sna->kgem, clone->gpu_bo);
 			clone->gpu_bo = kgem_bo_reference(bo);
 		}
+		cow->bo = bo;
 		kgem_bo_destroy(&sna->kgem, bo);
 	} else {
 		struct kgem_bo *bo = NULL;
@@ -1681,6 +1687,9 @@ sna_pixmap_make_cow(struct sna *sna,
 		cow->bo = src_priv->gpu_bo;
 		cow->refcnt = 1;
 
+		DBG(("%s: attaching source cow to pixmap=%ld\n",
+		     __FUNCTION__, src_priv->pixmap->drawable.serialNumber));
+
 		src_priv->cow = MAKE_COW_OWNER(cow);
 		list_init(&src_priv->cow_list);
 
@@ -1691,8 +1700,10 @@ sna_pixmap_make_cow(struct sna *sna,
 	}
 	assert(!src_priv->mapped);
 
-	if (cow == COW(dst_priv->cow))
+	if (cow == COW(dst_priv->cow)) {
+		assert(dst_priv->gpu_bo == cow->bo);
 		return true;
+	}
 
 	if (dst_priv->cow)
 		sna_pixmap_undo_cow(sna, dst_priv, 0);
@@ -1704,6 +1715,9 @@ sna_pixmap_make_cow(struct sna *sna,
 	list_add(&dst_priv->cow_list, &cow->list);
 	cow->refcnt++;
 
+	DBG(("%s: attaching clone to pixmap=%ld\n",
+	     __FUNCTION__, dst_priv->pixmap->drawable.serialNumber));
+
 	if (dst_priv->mapped) {
 		dst_priv->pixmap->devPrivate.ptr = NULL;
 		dst_priv->mapped = false;
commit 21f17455650d52848467290f609c678e85b8ceab
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 17 11:46:16 2013 +0100

    sna: Add the missing ref(bo) when undoing the source clone
    
    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 7e3c0bb..a50f4d4 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1599,7 +1599,7 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 			list_del(&clone->cow_list);
 
 			kgem_bo_destroy(&sna->kgem, clone->gpu_bo);
-			clone->gpu_bo = bo;
+			clone->gpu_bo = kgem_bo_reference(bo);
 		}
 		kgem_bo_destroy(&sna->kgem, bo);
 	} else {
commit ee166ca856ac02ca8900b9ff44ed3899add2c72a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 17 11:30:03 2013 +0100

    sna: Undo the clone when replacing the DRI pixmap
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index c8a954d..aed3e08 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -451,6 +451,9 @@ PixmapPtr sna_pixmap_create_unattached(ScreenPtr screen,
 				       int width, int height, int depth);
 void sna_pixmap_destroy(PixmapPtr pixmap);
 
+bool
+sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags);
+
 #define MOVE_WRITE 0x1
 #define MOVE_READ 0x2
 #define MOVE_INPLACE_HINT 0x4
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index b3dca97..7e3c0bb 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1538,7 +1538,7 @@ static inline bool use_cpu_bo_for_upload(struct sna *sna,
 	return kgem_bo_is_busy(priv->gpu_bo) || kgem_bo_is_busy(priv->cpu_bo);
 }
 
-static bool
+bool
 sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags)
 {
 	struct sna_cow *cow = COW(priv->cow);
diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index 99f9d12..06d1f21 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -505,11 +505,13 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo)
 	assert(pixmap->drawable.height * bo->pitch <= kgem_bo_size(bo));
 	assert(bo->proxy == NULL);
 	assert(bo->flush);
-	assert(priv->cow == NULL);
 	assert(priv->pinned & PIN_DRI);
 	assert((priv->pinned & PIN_PRIME) == 0);
 	assert(priv->flush);
 
+	if (priv->cow)
+		sna_pixmap_undo_cow(sna, priv, 0);
+
 	/* Post damage on the new front buffer so that listeners, such
 	 * as DisplayLink know take a copy and shove it over the USB,
 	 * also for software cursors and the like.
@@ -529,7 +531,8 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo)
 
 	assert(bo->refcnt);
 	if (priv->gpu_bo != bo) {
-		kgem_bo_destroy(&sna->kgem, priv->gpu_bo);
+		if (priv->gpu_bo)
+			kgem_bo_destroy(&sna->kgem, priv->gpu_bo);
 		priv->gpu_bo = ref(bo);
 		if (priv->mapped) {
 			assert(!priv->shm && priv->stride);


More information about the xorg-commit mailing list