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

Chris Wilson ickle at kemper.freedesktop.org
Sat Dec 16 11:02:52 UTC 2017


 src/sna/kgem.c |   37 ++++++++++++++++---------------------
 src/sna/sna.h  |    8 ++++++--
 2 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit af6d8e9e8f546e5cba60e3a62765c2dbd0328e83
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Dec 16 10:55:54 2017 +0000

    sna: Avoid calling kgem_bo_free() on a still active bo
    
    If we fail to manipulate a bo from the active cache for reuse, then we
    have to be careful not to immediately close it as it is still referenced
    from the current batch.
    
    Reported-by: Adric Blake <promarbler14 at gmail.com>
    References: https://bugs.freedesktop.org/show_bug.cgi?id=103025#c44
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 29e09e33..e58db967 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -4729,10 +4729,8 @@ discard:
 			if (first)
 				continue;
 
-			if (!kgem_set_tiling(kgem, bo, I915_TILING_NONE, 0)) {
-				kgem_bo_free(kgem, bo);
-				break;
-			}
+			if (!kgem_set_tiling(kgem, bo, I915_TILING_NONE, 0))
+				continue;
 		}
 		assert(bo->tiling == I915_TILING_NONE);
 		bo->pitch = 0;
@@ -5466,7 +5464,8 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem,
 
 					if (!kgem_set_tiling(kgem, bo,
 							     tiling, pitch)) {
-						kgem_bo_free(kgem, bo);
+						bo->scanout = false;
+						__kgem_bo_destroy(kgem, bo);
 						break;
 					}
 				}
@@ -5480,7 +5479,8 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem,
 				arg.handle = bo->handle;
 
 				if (do_ioctl(kgem->fd, DRM_IOCTL_MODE_ADDFB, &arg)) {
-					kgem_bo_free(kgem, bo);
+					bo->scanout = false;
+					__kgem_bo_destroy(kgem, bo);
 					break;
 				}
 
@@ -5787,13 +5787,10 @@ search_active:
 					continue;
 
 				if (!kgem_set_tiling(kgem, bo, tiling, pitch)) {
-					if (kgem->gen >= 040 && !exact) {
-						set_gpu_tiling(kgem, bo,
-							       tiling, pitch);
-					} else {
-						kgem_bo_free(kgem, bo);
-						break;
-					}
+					if (exact || kgem->gen < 040)
+						continue;
+
+					set_gpu_tiling(kgem, bo, tiling, pitch);
 				}
 				assert(bo->tiling == tiling);
 				assert(bo->pitch >= pitch);
@@ -5879,12 +5876,12 @@ search_inactive:
 		}
 
 		if (!kgem_set_tiling(kgem, bo, tiling, pitch)) {
-			if (kgem->gen >= 040 && !exact) {
-				set_gpu_tiling(kgem, bo, tiling, pitch);
-			} else {
+			if (exact || kgem->gen < 040) {
 				kgem_bo_free(kgem, bo);
 				break;
 			}
+
+			set_gpu_tiling(kgem, bo, tiling, pitch);
 		}
 
 		if (bo->purged && !kgem_bo_clear_purgeable(kgem, bo)) {
@@ -5945,12 +5942,10 @@ search_inactive:
 			__kgem_bo_clear_busy(bo);
 
 			if (!kgem_set_tiling(kgem, bo, tiling, pitch)) {
-				if (kgem->gen >= 040 && !exact) {
-					set_gpu_tiling(kgem, bo, tiling, pitch);
-				} else {
-					kgem_bo_free(kgem, bo);
+				if (exact || kgem->gen < 040)
 					goto no_retire;
-				}
+
+				set_gpu_tiling(kgem, bo, tiling, pitch);
 			}
 			assert(bo->tiling == tiling);
 			assert(bo->pitch >= pitch);
commit 21008aaa1f9f77ef3509a68dd83c7ad41da4ec81
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Nov 7 20:16:25 2017 +0000

    sna: Assert idempotent conversions between sna <-> ScreenPtr
    
    Check that the struct sna we retrieve from the ScreenPtr points back to
    the screen, and vice versa.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 74eae745..5283ce43 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -495,7 +495,9 @@ extern int sna_page_flip(struct sna *sna,
 pure static inline struct sna *
 to_sna(ScrnInfoPtr scrn)
 {
-	return (struct sna *)(scrn->driverPrivate);
+	struct sna *sna = scrn->driverPrivate;
+	assert(sna->scrn == scrn);
+	return sna;
 }
 
 pure static inline struct sna *
@@ -506,7 +508,9 @@ to_sna_from_screen(ScreenPtr screen)
 
 pure static inline ScreenPtr to_screen_from_sna(struct sna *sna)
 {
-	return xf86ScrnToScreen(sna->scrn);
+	ScreenPtr screen = xf86ScrnToScreen(sna->scrn);
+	assert(sna == to_sna_from_screen(screen));
+	return screen;
 }
 
 pure static inline struct sna *


More information about the xorg-commit mailing list