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

Chris Wilson ickle at kemper.freedesktop.org
Mon Jun 10 14:57:50 PDT 2013


 src/sna/kgem.c      |   29 ++++++++++++++++-------------
 src/sna/kgem.h      |   15 +++++++++------
 src/sna/sna.h       |    1 -
 src/sna/sna_accel.c |   16 ++--------------
 src/sna/sna_blt.c   |   12 ------------
 5 files changed, 27 insertions(+), 46 deletions(-)

New commits:
commit b9439a56170c4732b340137d306933a742ee6ae9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 10 22:56:20 2013 +0100

    sna: Move the GTT dirty tracking from the pixmap to the bo
    
    This allows us to more accurately track when the GTT is dirty. However,
    the only danger is that we may prematurely flush the scanout and clear
    the dirty bit and not preserve the flush timer.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index b444179..9b783a9 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -445,6 +445,7 @@ bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
 		kgem_bo_retire(kgem, bo);
 		bo->domain = DOMAIN_NONE;
 	}
+	bo->gtt_dirty = true;
 	return true;
 }
 
@@ -4621,6 +4622,7 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 		if (drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain) == 0) {
 			kgem_bo_retire(kgem, bo);
 			bo->domain = DOMAIN_GTT;
+			bo->gtt_dirty = true;
 		}
 	}
 
@@ -4943,6 +4945,7 @@ void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo)
 		if (drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain) == 0) {
 			kgem_bo_retire(kgem, bo);
 			bo->domain = DOMAIN_GTT;
+			bo->gtt_dirty = true;
 		}
 	}
 }
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 7f6052c..b7355d4 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -85,6 +85,7 @@ struct kgem_bo {
 	uint32_t tiling : 2;
 	uint32_t reusable : 1;
 	uint32_t gpu_dirty : 1;
+	uint32_t gtt_dirty : 1;
 	uint32_t domain : 2;
 	uint32_t needs_flush : 1;
 	uint32_t snoop : 1;
@@ -584,10 +585,12 @@ static inline void kgem_bo_mark_busy(struct kgem_bo *bo, int ring)
 
 inline static void __kgem_bo_clear_busy(struct kgem_bo *bo)
 {
-	bo->needs_flush = false;
-	list_del(&bo->request);
 	bo->rq = NULL;
+	list_del(&bo->request);
+
 	bo->domain = DOMAIN_NONE;
+	bo->needs_flush = false;
+	bo->gtt_dirty = false;
 }
 
 static inline bool kgem_bo_is_busy(struct kgem_bo *bo)
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 18573a9..da5d8af 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -140,7 +140,6 @@ struct sna_pixmap {
 	uint8_t clear :1;
 	uint8_t header :1;
 	uint8_t cpu :1;
-	uint8_t gtt_dirty :1;
 };
 
 struct sna_glyph {
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 850463b..69a151c 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1828,7 +1828,6 @@ _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
 			sna_damage_destroy(&priv->cpu_damage);
 			priv->clear = false;
 			priv->cpu = false;
-			priv->gtt_dirty = true;
 			list_del(&priv->flush_list);
 
 			assert(!priv->shm);
@@ -1890,7 +1889,6 @@ skip_inplace_map:
 				sna_pixmap_free_cpu(sna, priv);
 				list_del(&priv->flush_list);
 				priv->clear = false;
-				priv->gtt_dirty = true;
 			}
 			priv->cpu = false;
 
@@ -2281,7 +2279,6 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 								    region);
 				}
 				priv->clear = false;
-				priv->gtt_dirty = true;
 			}
 			assert_pixmap_damage(pixmap);
 			priv->cpu = false;
@@ -2860,8 +2857,6 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 				}
 				if (!ok)
 					return false;
-
-				priv->gtt_dirty = true;
 			}
 		}
 
@@ -2889,7 +2884,6 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 					     pixmap->devKind,
 					     0, 0,
 					     box, 1);
-			priv->gtt_dirty = true;
 		}
 		if (!ok)
 			return false;
@@ -2921,7 +2915,6 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 					     pixmap->devKind,
 					     0, 0,
 					     box, n);
-			priv->gtt_dirty = true;
 		}
 		if (!ok)
 			return false;
@@ -3591,8 +3584,6 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 			}
 			if (!ok)
 				return NULL;
-
-			priv->gtt_dirty = true;
 		}
 	}
 
@@ -4978,8 +4969,6 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 						     src_dx, src_dy,
 						     box, n))
 					goto fallback;
-
-				dst_priv->gtt_dirty = true;
 			}
 
 			assert(dst_priv->clear == false);
@@ -14203,7 +14192,7 @@ static bool start_flush(struct sna *sna, struct sna_pixmap *scanout)
 	if (!scanout)
 		return false;
 
-	if (sna->flags & SNA_FLUSH_GTT && scanout->gtt_dirty) {
+	if (sna->flags & SNA_FLUSH_GTT && scanout->gpu_bo->gtt_dirty) {
 		scanout->gpu_bo->needs_flush = true;
 		return true;
 	}
@@ -14229,7 +14218,7 @@ static bool stop_flush(struct sna *sna, struct sna_pixmap *scanout)
 	if (!scanout)
 		return false;
 
-	if (sna->flags & SNA_FLUSH_GTT && scanout->gtt_dirty) {
+	if (sna->flags & SNA_FLUSH_GTT && scanout->gpu_bo->gtt_dirty) {
 		scanout->gpu_bo->needs_flush = true;
 		return true;
 	}
@@ -14249,7 +14238,6 @@ static void timer_enable(struct sna *sna, int whom, int interval)
 static void sna_pixmap_flush(struct sna *sna, struct sna_pixmap *priv)
 {
 	kgem_bo_flush(&sna->kgem, priv->gpu_bo);
-	priv->gtt_dirty = false;
 }
 
 static bool sna_accel_do_flush(struct sna *sna)
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 2520af4..7002638 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -1719,8 +1719,6 @@ blt_put_composite(struct sna *sna,
 				     &box, 1);
 		assert(ok);
 	}
-
-	dst_priv->gtt_dirty = true;
 }
 
 fastcall static void blt_put_composite_box(struct sna *sna,
@@ -1757,8 +1755,6 @@ fastcall static void blt_put_composite_box(struct sna *sna,
 				     box, 1);
 		assert(ok);
 	}
-
-	dst_priv->gtt_dirty = true;
 }
 
 static void blt_put_composite_boxes(struct sna *sna,
@@ -1796,8 +1792,6 @@ static void blt_put_composite_boxes(struct sna *sna,
 				     box, n);
 		assert(ok);
 	}
-
-	dst_priv->gtt_dirty = true;
 }
 
 fastcall static void
@@ -1843,8 +1837,6 @@ blt_put_composite_with_alpha(struct sna *sna,
 				     &box, 1,
 				     0xffffffff, op->u.blt.pixel);
 	}
-
-	dst_priv->gtt_dirty = true;
 }
 
 fastcall static void
@@ -1882,8 +1874,6 @@ blt_put_composite_box_with_alpha(struct sna *sna,
 				     box, 1,
 				     0xffffffff, op->u.blt.pixel);
 	}
-
-	dst_priv->gtt_dirty = true;
 }
 
 static void
@@ -1922,8 +1912,6 @@ blt_put_composite_boxes_with_alpha(struct sna *sna,
 				     box, n,
 				     0xffffffff, op->u.blt.pixel);
 	}
-
-	dst_priv->gtt_dirty = true;
 }
 
 static bool
commit 5f0c5a49538d9995926b8dbda85c8e6d99496f17
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 10 22:48:03 2013 +0100

    sna: s/bo->dirty/bo->gpu_dirty/ to avoid later confusion
    
    The next step is to introduce bo->gtt_dirty.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 4c5686f..b444179 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -2139,7 +2139,7 @@ static void kgem_commit(struct kgem *kgem)
 
 		DBG(("%s: release handle=%d (proxy? %d), dirty? %d flush? %d, snoop? %d -> offset=%x\n",
 		     __FUNCTION__, bo->handle, bo->proxy != NULL,
-		     bo->dirty, bo->needs_flush, bo->snoop,
+		     bo->gpu_dirty, bo->needs_flush, bo->snoop,
 		     (unsigned)bo->exec->offset));
 
 		assert(!bo->purged);
@@ -2159,7 +2159,7 @@ static void kgem_commit(struct kgem *kgem)
 
 		bo->binding.offset = 0;
 		bo->domain = DOMAIN_GPU;
-		bo->dirty = false;
+		bo->gpu_dirty = false;
 
 		if (bo->proxy) {
 			/* proxies are not used for domain tracking */
@@ -2311,11 +2311,11 @@ static void kgem_finish_buffers(struct kgem *kgem)
 					list_replace(&bo->base.request,
 						     &shrink->request);
 					list_init(&bo->base.request);
-					shrink->needs_flush = bo->base.dirty;
+					shrink->needs_flush = bo->base.gpu_dirty;
 
 					bo->base.exec = NULL;
 					bo->base.rq = NULL;
-					bo->base.dirty = false;
+					bo->base.gpu_dirty = false;
 					bo->base.needs_flush = false;
 					bo->used = 0;
 
@@ -2356,11 +2356,11 @@ static void kgem_finish_buffers(struct kgem *kgem)
 					list_replace(&bo->base.request,
 						     &shrink->request);
 					list_init(&bo->base.request);
-					shrink->needs_flush = bo->base.dirty;
+					shrink->needs_flush = bo->base.gpu_dirty;
 
 					bo->base.exec = NULL;
 					bo->base.rq = NULL;
-					bo->base.dirty = false;
+					bo->base.gpu_dirty = false;
 					bo->base.needs_flush = false;
 					bo->used = 0;
 
@@ -2406,7 +2406,7 @@ static void kgem_cleanup(struct kgem *kgem)
 						      request);
 
 				bo->exec = NULL;
-				bo->dirty = false;
+				bo->gpu_dirty = false;
 				__kgem_bo_clear_busy(bo);
 				if (bo->refcnt == 0)
 					kgem_bo_free(kgem, bo);
@@ -2471,7 +2471,7 @@ void kgem_reset(struct kgem *kgem)
 			bo->binding.offset = 0;
 			bo->exec = NULL;
 			bo->target_handle = -1;
-			bo->dirty = false;
+			bo->gpu_dirty = false;
 
 			if (bo->needs_flush && __kgem_busy(kgem, bo->handle)) {
 				list_add(&bo->request, &kgem->flushing);
@@ -4417,7 +4417,7 @@ uint32_t kgem_add_reloc(struct kgem *kgem,
 				bo->exec = &_kgem_dummy_exec;
 			}
 
-			if (read_write_domain & 0x7fff && !bo->dirty)
+			if (read_write_domain & 0x7fff && !bo->gpu_dirty)
 				__kgem_bo_mark_dirty(bo);
 
 			bo = bo->proxy;
@@ -4445,7 +4445,7 @@ uint32_t kgem_add_reloc(struct kgem *kgem,
 		kgem->reloc[index].target_handle = bo->target_handle;
 		kgem->reloc[index].presumed_offset = bo->presumed_offset;
 
-		if (read_write_domain & 0x7fff && !bo->dirty) {
+		if (read_write_domain & 0x7fff && !bo->gpu_dirty) {
 			assert(!bo->snoop || kgem->can_blt_cpu);
 			__kgem_bo_mark_dirty(bo);
 		}
@@ -4953,10 +4953,10 @@ void kgem_clear_dirty(struct kgem *kgem)
 	struct kgem_bo *bo;
 
 	list_for_each_entry(bo, buffers, request) {
-		if (!bo->dirty)
+		if (!bo->gpu_dirty)
 			break;
 
-		bo->dirty = false;
+		bo->gpu_dirty = false;
 	}
 }
 
@@ -4979,7 +4979,7 @@ struct kgem_bo *kgem_create_proxy(struct kgem *kgem,
 	bo->size.bytes = length;
 
 	bo->io = target->io && target->proxy == NULL;
-	bo->dirty = target->dirty;
+	bo->gpu_dirty = target->gpu_dirty;
 	bo->tiling = target->tiling;
 	bo->pitch = target->pitch;
 	bo->flush = target->flush;
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 3086f17..7f6052c 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -84,7 +84,7 @@ struct kgem_bo {
 	uint32_t pitch : 18; /* max 128k */
 	uint32_t tiling : 2;
 	uint32_t reusable : 1;
-	uint32_t dirty : 1;
+	uint32_t gpu_dirty : 1;
 	uint32_t domain : 2;
 	uint32_t needs_flush : 1;
 	uint32_t snoop : 1;
@@ -622,7 +622,7 @@ static inline bool kgem_bo_is_dirty(struct kgem_bo *bo)
 		return false;
 
 	assert(bo->refcnt);
-	return bo->dirty;
+	return bo->gpu_dirty;
 }
 
 static inline void kgem_bo_unclean(struct kgem *kgem, struct kgem_bo *bo)
@@ -642,7 +642,7 @@ static inline void __kgem_bo_mark_dirty(struct kgem_bo *bo)
 	     bo->handle, bo->proxy != NULL));
 
 	bo->exec->flags |= LOCAL_EXEC_OBJECT_WRITE;
-	bo->needs_flush = bo->dirty = true;
+	bo->needs_flush = bo->gpu_dirty = true;
 	list_move(&bo->request, &RQ(bo->rq)->buffers);
 }
 
@@ -653,7 +653,7 @@ static inline void kgem_bo_mark_dirty(struct kgem_bo *bo)
 		assert(bo->exec);
 		assert(bo->rq);
 
-		if (bo->dirty)
+		if (bo->gpu_dirty)
 			return;
 
 		__kgem_bo_mark_dirty(bo);


More information about the xorg-commit mailing list