[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-intel: Changes to 'debian-unstable'



 Makefile.am                |    4 
 debian/changelog           |    6 +
 src/i915_pciids.h          |    6 -
 src/sna/kgem.c             |   20 +++
 src/sna/kgem.h             |    1 
 src/sna/sna.h              |    2 
 src/sna/sna_accel.c        |    1 
 src/sna/sna_display.c      |   10 +
 src/sna/sna_display_fake.c |    4 
 src/sna/sna_dri2.c         |  121 +++++++++++---------
 src/sna/sna_present.c      |  110 +++++++++++++-----
 src/sna/xassert.h          |   21 ++-
 src/uxa/intel_uxa.c        |    6 -
 test/dri2-race.c           |  264 ++++++++++++++++++++++++++++++++++++++++-----
 test/present-speed.c       |   54 +++++++++
 test/present-test.c        |  255 +++++++++++++++++++++++++++++++++++++++++--
 tools/cursor.c             |   16 ++
 17 files changed, 759 insertions(+), 142 deletions(-)

New commits:
commit 8dee4e4b8ad76371fd754bd24a9d3467d8d8f326
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Tue Mar 29 10:54:53 2016 +0300

    release to unstable

diff --git a/debian/changelog b/debian/changelog
index f620743..ddbc0e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+xserver-xorg-video-intel (2:2.99.917+git20160325-1) unstable; urgency=medium
+
+  * New upstream snapshot.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Tue, 29 Mar 2016 10:29:35 +0300
+
 xserver-xorg-video-intel (2:2.99.917+git20160307-2) unstable; urgency=medium
 
   * Disable the patch to use modesetting on skylake for now, since it reveals

commit 094924f7f882da1f32395d4c982db6ad8e0f609f
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Mar 25 20:59:48 2016 +0000

    tools/cursor: Print an ASCII representation as well
    
    Show the ASCII outline of the cursor as well as the image stored in the
    PNG.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/tools/cursor.c b/tools/cursor.c
index 6f4e3f8..6a2438a 100644
--- a/tools/cursor.c
+++ b/tools/cursor.c
@@ -61,6 +61,22 @@ int main(int argc, char **argv)
 	       cur->width, cur->height,
 	       cur->xhot, cur->yhot);
 
+	if (1) {
+		int x, y;
+
+		src = cur->pixels;
+		for (y = 0; y < cur->height; y++) {
+			for (x = 0; x < cur->width; x++) {
+				if (x == cur->xhot && y == cur->yhot)
+					printf("+");
+				else
+					printf("%c", *src ? *src >> 24 >= 127 ? 'x' : '.' : ' ');
+				src++;
+			}
+			printf("\n");
+		}
+	}
+
 	file = fopen("cursor.png", "wb");
 	if (file == NULL)
 		return 2;

commit 39fbae3c61cc2d78ac5e7c5c471d161fafd53400
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 22:09:48 2016 +0000

    Update i915_pciids.h
    
    Sync with kernel commit 7157bb27e79875db5603aa1e30f56e873a8300f9
    Author: Michał Winiarski <michal.winiarski@intel.com>
    Date:   Fri Feb 5 13:21:42 2016 +0100
    
        drm/i915/skl: Add missing SKL ids
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/i915_pciids.h b/src/i915_pciids.h
index f970209..9094599 100644
--- a/src/i915_pciids.h
+++ b/src/i915_pciids.h
@@ -277,7 +277,9 @@
 	INTEL_VGA_DEVICE(0x191D, info)  /* WKS GT2 */
 
 #define INTEL_SKL_GT3_IDS(info) \
+	INTEL_VGA_DEVICE(0x1923, info), /* ULT GT3 */ \
 	INTEL_VGA_DEVICE(0x1926, info), /* ULT GT3 */ \
+	INTEL_VGA_DEVICE(0x1927, info), /* ULT GT3 */ \
 	INTEL_VGA_DEVICE(0x192B, info), /* Halo GT3 */ \
 	INTEL_VGA_DEVICE(0x192A, info)  /* SRV GT3 */
 
@@ -296,7 +298,9 @@
 #define INTEL_BXT_IDS(info) \
 	INTEL_VGA_DEVICE(0x0A84, info), \
 	INTEL_VGA_DEVICE(0x1A84, info), \
-	INTEL_VGA_DEVICE(0x5A84, info)
+	INTEL_VGA_DEVICE(0x1A85, info), \
+	INTEL_VGA_DEVICE(0x5A84, info), /* APL HD Graphics 505 */ \
+	INTEL_VGA_DEVICE(0x5A85, info)  /* APL HD Graphics 500 */
 
 #define INTEL_KBL_GT1_IDS(info)	\
 	INTEL_VGA_DEVICE(0x5913, info), /* ULT GT1.5 */ \

commit 03bed1c7ba838af9aa6ab722aeaa070aa4cc70e3
Author: Lyude <cpaul@redhat.com>
Date:   Wed Mar 23 15:44:37 2016 -0400

    uxa: Restore old bo on failure
    
    When we fail to do a modeset, we need to make sure that we restore the
    previous bo in the event that it's changed. Otherwise we'll crash the X
    server the next time we do a pageflip.
    
    This fixes an issue with panning crashing the X server if a user tries
    to set a large panning resolution such as 5200x3200, and the GPU doesn't
    have enough memory to handle the bo due to being in UXA mode.
    
    Signed-off-by: Lyude <cpaul@redhat.com>
    Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 590ff5d..830f094 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -1068,7 +1068,7 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	PixmapPtr pixmap;
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	dri_bo *bo = intel->front_buffer;
+	dri_bo *bo = intel->front_buffer, *old_bo;
 	int old_width, old_height, old_pitch;
 
 	if (!uxa_resources_init(screen))
@@ -1081,6 +1081,7 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 	old_width = pixmap->drawable.width;
 	old_height = pixmap->drawable.height;
 	old_pitch = pixmap->devKind;
+	old_bo = intel_uxa_get_pixmap_bo(pixmap);
 
 	if (!screen->ModifyPixmapHeader(pixmap,
 					scrn->virtualX,
@@ -1102,6 +1103,9 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 err:
 	screen->ModifyPixmapHeader(pixmap,
 				   old_width, old_height, -1, -1, old_pitch, NULL);
+	if (old_bo)
+		intel_uxa_set_pixmap_bo(pixmap, old_bo);
+
 	return FALSE;
 }
 

commit c186d4dda3b62b73af3caf2883a9cedfd97e3b45
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 18:22:20 2016 +0000

    sna/present: Restrict vblank.sequence range to 31bits
    
    The kernel checks for past vblanks using an int32_t comparison, so we
    can only program up to 31bits into the future (and similarly programing
    a timer that large would also overflow).
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=94685
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index 93c7f06..e08afe5 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -114,8 +114,10 @@ static void vblank_complete(struct sna_present_event *info,
 	int n;
 
 	if (msc < info->target_msc) {
-		DBG(("%s: %d too early, now %lld, expected %lld\n",
-		     __FUNCTION__, (long long)msc, (long long)info->target_msc));
+		DBG(("%s: event=%d too early, now %lld, expected %lld\n",
+		     __FUNCTION__,
+		     info->event_id[0],
+		     (long long)msc, (long long)info->target_msc));
 		if (sna_present_queue(info, msc))
 			return;
 	}
@@ -247,7 +249,7 @@ static bool sna_present_queue(struct sna_present_event *info,
 	     (long long)info->target_msc,
 	     (unsigned)info->target_msc,
 	     (long long)last_msc));
-	assert(info->target_msc - last_msc < 1ull<<32);
+	assert(info->target_msc - last_msc < 1ull<<31);
 
 	VG_CLEAR(vbl);
 	vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
@@ -360,7 +362,7 @@ sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 		present_event_notify(event_id, swap_ust(swap), swap->msc);
 		return Success;
 	}
-	if (warn_unless(msc - swap->msc < 1ull<<32))
+	if (warn_unless(msc - swap->msc < 1ull<<31))
 		return BadValue;
 
 	list_for_each_entry(tmp, &sna->present.vblank_queue, link) {
diff --git a/test/present-test.c b/test/present-test.c
index f578adb..5a12a24 100644
--- a/test/present-test.c
+++ b/test/present-test.c
@@ -1089,6 +1089,86 @@ static int test_future_msc(Display *dpy, void *Q)
 	return ret;
 }
 
+static int test_wrap_msc(Display *dpy)
+{
+	xcb_connection_t *c = XGetXCBConnection(dpy);
+	Window root, win;
+	int x, y;
+	unsigned int width, height;
+	unsigned border, depth;
+	XSetWindowAttributes attr;
+	int ret = 0, n;
+	uint64_t msc, ust;
+	int complete;
+	uint64_t interval;
+	void *Q;
+
+	XGetGeometry(dpy, DefaultRootWindow(dpy),
+		     &root, &x, &y, &width, &height, &border, &depth);
+
+	attr.override_redirect = 1;
+	win = XCreateWindow(dpy, root,
+			    0, 0, width, height, 0, depth,
+			    InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
+			    CWOverrideRedirect, &attr);
+	XMapWindow(dpy, win);
+	XSync(dpy, True);
+	if (_x_error_occurred)
+		return 1;
+
+	printf("Testing wraparound notifies\n");
+	_x_error_occurred = 0;
+
+	Q = setup_msc(dpy, win);
+	interval = msc_interval(dpy, win, Q);
+	if (interval == 0) {
+		printf("Zero delay between frames\n");
+		return 1;
+	}
+	msc = check_msc(dpy, win, Q, 0, &ust);
+	printf("Initial msc=%llx, interval between frames %lldus\n",
+	       (long long)msc, (long long)interval);
+
+	for (n = 1; n <= 10; n++)
+		xcb_present_notify_msc(c, win, n,
+				       msc + ((long long)n<<32) + n,
+				       0, 0);
+	for (n = 1; n <= 10; n++)
+		xcb_present_notify_msc(c, win, -n,
+				       0, (long long)n << 32, 0);
+	xcb_present_notify_msc(c, win, 0xdeadbeef, msc + 60*10, 0, 0);
+	xcb_flush(c);
+
+	complete = 0;
+	do {
+		xcb_present_complete_notify_event_t *ce;
+		xcb_generic_event_t *ev;
+
+		ev = xcb_wait_for_special_event(c, Q);
+		if (ev == NULL)
+			break;
+
+		ce = (xcb_present_complete_notify_event_t *)ev;
+		assert(ce->kind == XCB_PRESENT_COMPLETE_KIND_NOTIFY_MSC);
+
+		if (ce->serial == 0xdeadbeef) {
+			complete = 1;
+		} else {
+			fprintf(stderr,
+				"\tnotify %d recieved at +%llu\n",
+				ce->serial, ce->msc - msc);
+			ret++;
+		}
+		free(ev);
+	} while (!complete);
+
+	teardown_msc(dpy, Q);
+	XDestroyWindow(dpy, win);
+	XSync(dpy, True);
+
+	return ret;
+}
+
 static int test_exhaustion_msc(Display *dpy, void *Q)
 {
 #define N_VBLANKS 256 /* kernel event queue length: 128 vblanks */
@@ -2019,6 +2099,9 @@ int main(void)
 	error += test_future_msc(dpy, queue);
 	last_msc = check_msc(dpy, root, queue, last_msc, NULL);
 
+	error += test_wrap_msc(dpy);
+	last_msc = check_msc(dpy, root, queue, last_msc, NULL);
+
 	error += test_accuracy_msc(dpy, queue);
 	last_msc = check_msc(dpy, root, queue, last_msc, NULL);
 

commit 4e108afe55f6b13aa946d1252ff0b828929245b3
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 12:28:59 2016 +0000

    Revert "configure: Remove test for strlcat"
    
    This reverts commit e4e469a0ede6974e1f916843f9317244516f7674.
    
    It looks like we get to choose between breaking the clang build or the
    gcc build. With gcc, we need to ensure that enter xorg/os.h with the
    right set of HAVE_STRNDUP et al guards, e.g.
    
    In file included from /usr/include/string.h:630:0,
                     from /usr/include/xorg/os.h:53,
                     from /usr/include/xorg/misc.h:116,
                     from fd.c:34:
    /usr/include/xorg/os.h:590:1: error: expected identifier or '(' before '__extension__'
     strndup(const char *str, size_t n);
    
    Reported-by: Arkadiusz Miskiewicz <arekm@maven.pl>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index b121515..c18ad96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,9 @@ AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 AC_SYS_LARGEFILE
 
+# Check for common libc routines redefined by os.h
+AC_CHECK_FUNCS([strlcpy strlcat strndup], [], [])
+
 # Platform specific settings
 case $host_os in
   *linux*)

commit c326ed192bcaeea41bb93b7077ec37a1437a4409
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 11:38:35 2016 +0000

    sna/present: Add missing "static inline" for disabled present stubs
    
    Oops, copy'n'paste broke the non-Present build:
    
    sna_trapezoids_boxes.c:(.text+0x0): multiple definition of
    `sna_present_cancel_flip'
    
    Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 755bd8e..e5ca906 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -605,7 +605,7 @@ static inline bool sna_present_open(struct sna *sna, ScreenPtr pScreen) { return
 static inline void sna_present_update(struct sna *sna) { }
 static inline void sna_present_close(struct sna *sna, ScreenPtr pScreen) { }
 static inline void sna_present_vblank_handler(struct drm_event_vblank *event) { }
-void sna_present_cancel_flip(struct sna *sna) { }
+static inline void sna_present_cancel_flip(struct sna *sna) { }
 #endif
 
 extern bool sna_crtc_set_sprite_rotation(xf86CrtcPtr crtc, uint32_t rotation);

commit f6316fb6f04a61857995aa9fb757249fe3fbaebd
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 11:03:07 2016 +0000

    configure: Remove ACLOCAL_FLAGS passthrough
    
    Still not working right, remove it to keep the standard build working.
    Sorry if you have been relying on ACLOCAL_FLAGS.
    
    Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/Makefile.am b/Makefile.am
index c60e8a7..de5fbe1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,9 @@
 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-ACLOCAL_AMFLAGS = $(ACLOCAL_FLAGS) -I m4
+#Having problems passing through user flags as libtool complains
+#ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
+ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = man libobj xvmc src tools
 

commit e4e469a0ede6974e1f916843f9317244516f7674
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 11:01:52 2016 +0000

    configure: Remove test for strlcat
    
    There's no point in testing for functions we don't use and seem to cause
    problems for Clang.
    
    Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index c18ad96..b121515 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,9 +62,6 @@ AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 AC_SYS_LARGEFILE
 
-# Check for common libc routines redefined by os.h
-AC_CHECK_FUNCS([strlcpy strlcat strndup], [], [])
-
 # Platform specific settings
 case $host_os in
   *linux*)

commit 02f535e8f3659f1147c6f2e698bd5d8730dec19b
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 09:39:06 2016 +0000

    sna/present: Requeue early vblank completions
    
    If the vblank completes too early (e.g. due to a modeset), try
    requeueing it so that it fires at the expected time (and so after the
    modeset).
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index ab07894..93c7f06 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -48,6 +48,8 @@ struct sna_present_event {
 };
 
 static void sna_present_unflip(ScreenPtr screen, uint64_t event_id);
+static bool sna_present_queue(struct sna_present_event *info,
+			      uint64_t last_msc);
 
 static inline struct sna_present_event *
 to_present_event(uintptr_t  data)
@@ -111,6 +113,13 @@ static void vblank_complete(struct sna_present_event *info,
 {
 	int n;
 
+	if (msc < info->target_msc) {
+		DBG(("%s: %d too early, now %lld, expected %lld\n",
+		     __FUNCTION__, (long long)msc, (long long)info->target_msc));
+		if (sna_present_queue(info, msc))
+			return;
+	}
+
 	DBG(("%s: %d events complete\n", __FUNCTION__, info->n_event_id));
 	for (n = 0; n < info->n_event_id; n++) {
 		DBG(("%s: pipe=%d tv=%d.%06d msc=%lld (target=%lld), event=%lld complete%s\n", __FUNCTION__,
@@ -228,6 +237,36 @@ static bool sna_fake_vblank(struct sna_present_event *info)
 	return TimerSet(NULL, 0, delay, sna_fake_vblank_handler, info);
 }
 
+static bool sna_present_queue(struct sna_present_event *info,
+			      uint64_t last_msc)
+{
+	union drm_wait_vblank vbl;
+
+	DBG(("%s: target msc=%llu, seq=%u (last_msc=%llu)\n",
+	     __FUNCTION__,
+	     (long long)info->target_msc,
+	     (unsigned)info->target_msc,
+	     (long long)last_msc));
+	assert(info->target_msc - last_msc < 1ull<<32);
+
+	VG_CLEAR(vbl);
+	vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
+	vbl.request.sequence = info->target_msc;
+	vbl.request.signal = (uintptr_t)MARK_PRESENT(info);
+	if (sna_wait_vblank(info->sna, &vbl, sna_crtc_pipe(info->crtc))) {
+		DBG(("%s: vblank enqueue failed, faking\n", __FUNCTION__));
+		if (!sna_fake_vblank(info))
+			return false;
+	} else {
+		if (info->target_msc - last_msc == 1) {
+			sna_crtc_set_vblank(info->crtc);
+			info->crtc = mark_crtc(info->crtc);
+		}
+	}
+
+	return true;
+}
+
 static RRCrtcPtr
 sna_present_get_crtc(WindowPtr window)
 {
@@ -306,7 +345,6 @@ sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 	struct sna *sna = to_sna_from_screen(crtc->pScreen);
 	struct sna_present_event *info, *tmp;
 	const struct ust_msc *swap;
-	union drm_wait_vblank vbl;
 
 	swap = sna_crtc_last_swap(crtc->devPrivate);
 	DBG(("%s(pipe=%d, event=%lld, msc=%lld, last swap=%lld)\n",
@@ -367,22 +405,10 @@ sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 	info->n_event_id = 1;
 	list_add_tail(&info->link, &tmp->link);
 
-	VG_CLEAR(vbl);
-	vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
-	vbl.request.sequence = msc;
-	vbl.request.signal = (uintptr_t)MARK_PRESENT(info);
-	if (sna_wait_vblank(sna, &vbl, sna_crtc_pipe(info->crtc))) {
-		DBG(("%s: vblank enqueue failed, faking\n", __FUNCTION__));
-		if (!sna_fake_vblank(info)) {
-			list_del(&info->link);
-			free(info);
-			return BadAlloc;
-		}
-	} else {
-		if (msc - swap->msc == 1) {
-			sna_crtc_set_vblank(info->crtc);
-			info->crtc = mark_crtc(info->crtc);
-		}
+	if (!sna_present_queue(info, swap->msc)) {
+		list_del(&info->link);
+		free(info);
+		return BadAlloc;
 	}
 
 	return Success;

commit 1b82b7b48d17b4b3401e9d82b0fe86df06c8d451
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Mar 24 10:31:02 2016 +0000

    sna/present: Cancel pending unflips when resizing the screen
    
    Otherwise we try to flip back before we complete the mode change.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 3c19aa5..755bd8e 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -599,11 +599,13 @@ bool sna_present_open(struct sna *sna, ScreenPtr pScreen);
 void sna_present_update(struct sna *sna);
 void sna_present_close(struct sna *sna, ScreenPtr pScreen);
 void sna_present_vblank_handler(struct drm_event_vblank *event);
+void sna_present_cancel_flip(struct sna *sna);
 #else
 static inline bool sna_present_open(struct sna *sna, ScreenPtr pScreen) { return false; }
 static inline void sna_present_update(struct sna *sna) { }
 static inline void sna_present_close(struct sna *sna, ScreenPtr pScreen) { }
 static inline void sna_present_vblank_handler(struct drm_event_vblank *event) { }
+void sna_present_cancel_flip(struct sna *sna) { }
 #endif
 
 extern bool sna_crtc_set_sprite_rotation(xf86CrtcPtr crtc, uint32_t rotation);
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index ad8690e..6ceb515 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -5346,6 +5346,8 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
 	assert(sna->mode.shadow_damage == NULL);
 	assert(sna->mode.shadow == NULL);
 
+	/* Cancel a pending [un]flip (as the pixmaps no longer match) */
+	sna_present_cancel_flip(sna);
 	copy_front(sna, sna->front, new_front);
 
 	screen->SetScreenPixmap(new_front);
diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index 1624063..ab07894 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -790,6 +790,19 @@ reset_mode:
 		goto reset_mode;
 }
 
+void sna_present_cancel_flip(struct sna *sna)
+{
+	if (sna->present.unflip) {
+		const struct ust_msc *swap;
+
+		swap = sna_crtc_last_swap(sna_primary_crtc(sna));
+		present_event_notify(sna->present.unflip,
+				     swap_ust(swap), swap->msc);
+
+		sna->present.unflip = 0;
+	}
+}
+
 static present_screen_info_rec present_info = {
 	.version = PRESENT_SCREEN_INFO_VERSION,
 

commit f656f6afa288c63968f45d6d32c96a4cf6213117
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Mar 22 22:11:18 2016 +0000

    sna/present: Report BadValue if target_msc exceeds last known msc by 1<<32
    
    As we cannot queue a vblank further than 1<<32 into the future, nor can
    we set a Timer to expire that far into the future, creating such a
    vblank event is futile. Report BadValue and hope for the best.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=94515
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 7d2478c..ad8690e 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -479,14 +479,14 @@ uint64_t sna_crtc_record_swap(xf86CrtcPtr crtc,
 	assert(sna_crtc);
 
 	if (msc64(sna_crtc, seq, &msc)) {
-		DBG(("%s: recording last swap on pipe=%d, frame %d [%08llx], time %d.%06d\n",
+		DBG(("%s: recording last swap on pipe=%d, frame %d [msc=%08lld], time %d.%06d\n",
 		     __FUNCTION__, __sna_crtc_pipe(sna_crtc), seq, (long long)msc,
 		     tv_sec, tv_usec));
 		sna_crtc->swap.tv_sec = tv_sec;
 		sna_crtc->swap.tv_usec = tv_usec;
 		sna_crtc->swap.msc = msc;
 	} else {
-		DBG(("%s: swap event on pipe=%d, frame %d [%08llx], time %d.%06d\n",
+		DBG(("%s: swap event on pipe=%d, frame %d [msc=%08lld], time %d.%06d\n",
 		     __FUNCTION__, __sna_crtc_pipe(sna_crtc), seq, (long long)msc,
 		     tv_sec, tv_usec));
 	}
diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index 7a7650e..1624063 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -279,10 +279,10 @@ last:
 		*msc = swap->msc;
 	}
 
-	DBG(("%s: pipe=%d, tv=%d.%06d msc=%lld\n", __FUNCTION__,
+	DBG(("%s: pipe=%d, tv=%d.%06d seq=%d msc=%lld\n", __FUNCTION__,
 	     sna_crtc_pipe(crtc->devPrivate),
 	     (int)(*ust / 1000000), (int)(*ust % 1000000),
-	     (long long)*msc));
+	     vbl.reply.sequence, (long long)*msc));
 
 	return Success;
 }
@@ -313,8 +313,7 @@ sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 	     __FUNCTION__, sna_crtc_pipe(crtc->devPrivate),
 	     (long long)event_id, (long long)msc, (long long)swap->msc));
 
-	warn_unless((int64_t)(msc - swap->msc) >= 0);
-	if ((int64_t)(msc - swap->msc) <= 0) {
+	if (warn_unless((int64_t)(msc - swap->msc) >= 0)) {
 		DBG(("%s: pipe=%d tv=%d.%06d msc=%lld (target=%lld), event=%lld complete\n", __FUNCTION__,
 		     sna_crtc_pipe(crtc->devPrivate),
 		     swap->tv_sec, swap->tv_usec,
@@ -323,7 +322,8 @@ sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 		present_event_notify(event_id, swap_ust(swap), swap->msc);
 		return Success;
 	}
-	warn_unless(msc < swap->msc + (1ull<<32));
+	if (warn_unless(msc - swap->msc < 1ull<<32))
+		return BadValue;
 
 	list_for_each_entry(tmp, &sna->present.vblank_queue, link) {
 		if (tmp->target_msc == msc &&
@@ -372,7 +372,7 @@ sna_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
 	vbl.request.sequence = msc;
 	vbl.request.signal = (uintptr_t)MARK_PRESENT(info);
 	if (sna_wait_vblank(sna, &vbl, sna_crtc_pipe(info->crtc))) {
-		DBG(("%s: vblank enqueue failed\n", __FUNCTION__));
+		DBG(("%s: vblank enqueue failed, faking\n", __FUNCTION__));
 		if (!sna_fake_vblank(info)) {
 			list_del(&info->link);
 			free(info);
diff --git a/src/sna/xassert.h b/src/sna/xassert.h
index 28796b8..e648e4b 100644
--- a/src/sna/xassert.h
+++ b/src/sna/xassert.h
@@ -44,20 +44,25 @@
 	FatalError("%s:%d assertion '%s' failed\n", __func__, __LINE__, #E); \
 } while (0)
 
-#define warn_unless(E) do if (unlikely(!(E))) { \
-	static int __warn_once__; \
-	if (!__warn_once__) { \
-		xorg_backtrace(); \
-		ErrorF("%s:%d assertion '%s' failed\n", __func__, __LINE__, #E); \
-		__warn_once__ = 1; \
+#define warn_unless(E) \
+({ \
+	bool fail = !(E); \
+	if (unlikely(fail)) { \
+		static int __warn_once__; \
+		if (!__warn_once__) { \
+			xorg_backtrace(); \
+			ErrorF("%s:%d assertion '%s' failed\n", __func__, __LINE__, #E); \
+			__warn_once__ = 1; \
+		} \
 	} \
-} while (0)
+	unlikely(fail); \
+})
 
 #define dbg(EXPR) EXPR
 
 #else
 
-#define warn_unless(E)
+#define warn_unless(E) ({ bool fail = !(E); unlikely(fail); })
 #define dbg(EXPR)
 
 #endif

commit 74cd4d09ae051d3a1f4cb9fe29e656b044f03ece
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Mar 16 17:35:26 2016 +0000

    sna: Ensure the scanout is fully flushed on LeaveVT
    
    Just in case we haven't otherwise flushed and invalidated the scanout
    prior to loosing control of the output.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 71a6207..684d58e 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -18178,6 +18178,7 @@ void sna_accel_watch_flush(struct sna *sna, int enable)
 void sna_accel_leave(struct sna *sna)
 {
 	DBG(("%s\n", __FUNCTION__));
+	sna_scanout_flush(sna);
 
 	/* as root we always have permission to render */
 	if (geteuid() == 0)

commit 68913715a2982572e88f943fd4fbe1b07e2fc720
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Mar 16 13:51:15 2016 +0000

    test: Look at Present scaling with number of cpus
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/test/present-speed.c b/test/present-speed.c
index 4d33904..1e6e48b 100644
--- a/test/present-speed.c
+++ b/test/present-speed.c
@@ -52,6 +52,7 @@
 #include <errno.h>
 #include <setjmp.h>
 #include <signal.h>
+#include <sys/wait.h>
 
 #include "dri3.h"
 
@@ -119,6 +120,9 @@ static int
 _check_error_handler(Display     *display,
 		     XErrorEvent *event)
 {
+	if (_x_error_occurred < 0)
+		return True;
+
 	printf("X11 error from display %s, serial=%ld, error=%d, req=%d.%d\n",
 	       DisplayString(display),
 	       event->serial,
@@ -312,6 +316,7 @@ static void run(Display *dpy, Window win, const char *name, unsigned options)
 	if (_x_error_occurred)
 		abort();
 
+	_x_error_occurred = -1;
 	xcb_present_select_input(c, eid, win, 0);
 	XSync(dpy, True);
 	xcb_unregister_for_special_event(c, Q);
@@ -329,6 +334,51 @@ static void run(Display *dpy, Window win, const char *name, unsigned options)
 	       completed / (elapsed(&start, &end) / 1000000));
 }
 
+static int isqrt(int x)
+{
+	int i;
+
+	for (i = 2; i*i < x; i++)
+		;
+	return i;
+}
+
+static void siblings(int max_width, int max_height, int ncpus, unsigned options)
+{
+	int sq_ncpus = isqrt(ncpus);
+	int width = max_width / sq_ncpus;
+	int height = max_height/ sq_ncpus;
+	int child;
+
+	if (ncpus <= 1)
+		return;
+
+	for (child = 0; child < ncpus; child++) {
+		for (; fork() == 0; exit(0)) {
+			int x = (child % sq_ncpus) * width;
+			int y = (child / sq_ncpus) * height;
+			XSetWindowAttributes attr = { .override_redirect = 1 };
+			Display *dpy = XOpenDisplay(NULL);
+			Window win = XCreateWindow(dpy, DefaultRootWindow(dpy),
+						   x, y, width, height, 0,
+						   DefaultDepth(dpy, DefaultScreen(dpy)),
+						   InputOutput,
+						   DefaultVisual(dpy, DefaultScreen(dpy)),
+						   CWOverrideRedirect, &attr);
+			XMapWindow(dpy, win);
+			run(dpy, win, "sibling", options);
+		}
+	}
+
+	while (child) {
+		int status = -1;
+		pid_t pid = wait(&status);
+		if (pid == -1)
+			continue;
+		child--;
+	}
+}
+
 static int has_present(Display *dpy)
 {
 	xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -551,6 +601,10 @@ static void loop(Display *dpy, XRRScreenResources *res, unsigned options)
 			XDestroyWindow(dpy, win);
 			XSync(dpy, True);
 
+			siblings(mode->width, mode->height,
+				 sysconf(_SC_NPROCESSORS_ONLN),
+				 options);
+
 			XRRSetCrtcConfig(dpy, res, output->crtcs[c], CurrentTime,
 					 0, 0, None, RR_Rotate_0, NULL, 0);
 		}

commit ed83d92b50fcd33a46b20f6a2431206db15d9530
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Mar 16 13:49:24 2016 +0000

    sna/present: Check incoming pitch before flipping
    
    Framebuffers are restricted to pitches with a multiple of 64. Check
    before we flip.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index f95a12c..7a7650e 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -494,6 +494,12 @@ sna_present_check_flip(RRCrtcPtr crtc,
 				return FALSE;
 			}
 		}
+
+		if (flip->gpu_bo->pitch & 63) {
+			DBG(("%s: pined bo, bad pitch=%d\n",
+			     __FUNCTION__, flip->gpu_bo->pitch));
+			return FALSE;
+		}
 	}
 
 	return TRUE;
@@ -663,6 +669,11 @@ get_flip_bo(PixmapPtr pixmap)
 		return NULL;
 	}
 
+	if (priv->gpu_bo->pitch & 63) {
+		DBG(("%s: invalid pitch, no conversion\n", __FUNCTION__));
+		return NULL;
+	}
+
 	return priv->gpu_bo;
 }
 

commit cd864c005568c68610abb85e4a9453377a460aae
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Mar 16 13:14:40 2016 +0000

    tests: Anticipate Present reporting too early
    
    Given Present bugs, any completion event may be sent too early and
    out-of-order. Make sure we drain all outstanding events before
    continuing on to the next test.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/test/present-test.c b/test/present-test.c
index af1882a..f578adb 100644
--- a/test/present-test.c
+++ b/test/present-test.c
@@ -457,7 +457,7 @@ static int test_future(Display *dpy, Window win, const char *phase, void *Q)
 	unsigned border, depth;
 	int x, y, ret = 0, n;
 	uint64_t msc, ust;
-	int complete;
+	int complete, count;
 	int early = 0, late = 0;
 	int earliest = 0, latest = 0;
 	uint64_t interval;
@@ -511,6 +511,7 @@ static int test_future(Display *dpy, Window win, const char *phase, void *Q)
 	xcb_flush(c);
 
 	complete = 0;
+	count = 0;
 	do {
 		xcb_present_complete_notify_event_t *ce;
 		xcb_generic_event_t *ev;
@@ -553,6 +554,7 @@ static int test_future(Display *dpy, Window win, const char *phase, void *Q)
 				late++;
 				ret++;
 			}
+			count++;
 		}
 		free(ev);
 	} while (!complete);
@@ -562,6 +564,24 @@ static int test_future(Display *dpy, Window win, const char *phase, void *Q)
 	if (late)
 		printf("\t%d frames shown too late (worst %d)!\n", late, latest);
 
+	if (count != 10) {
+		fprintf(stderr, "Sentinel frame received too early! %d frames outstanding\n", 10 - count);
+		ret++;
+
+		do {
+			xcb_present_complete_notify_event_t *ce;
+			xcb_generic_event_t *ev;
+
+			ev = xcb_wait_for_special_event(c, Q);
+			if (ev == NULL)
+				break;
+
+			ce = (xcb_present_complete_notify_event_t *)ev;
+			assert(ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP);
+			free(ev);
+		} while (++count != 10);
+	}
+
 	ret += !!_x_error_occurred;
 
 	return ret;
@@ -703,7 +723,7 @@ static int test_accuracy(Display *dpy, Window win, const char *phase, void *Q)
 	uint64_t target;
 	int early = 0, late = 0;
 	int earliest = 0, latest = 0;
-	int complete;
+	int complete, count;
 
 	XGetGeometry(dpy, win,
 		     &root, &x, &y, &width, &height, &border, &depth);
@@ -745,6 +765,7 @@ static int test_accuracy(Display *dpy, Window win, const char *phase, void *Q)
 	xcb_flush(c);
 
 	complete = 0;
+	count = 0;
 	do {
 		xcb_present_complete_notify_event_t *ce;
 		xcb_generic_event_t *ev;
@@ -773,6 +794,7 @@ static int test_accuracy(Display *dpy, Window win, const char *phase, void *Q)
 				late++;
 				ret++;
 			}
+			count++;
 		} else
 			complete = 1;
 		free(ev);
@@ -783,6 +805,23 @@ static int test_accuracy(Display *dpy, Window win, const char *phase, void *Q)
 	if (late)
 		printf("\t%d frames shown too late (worst %d)!\n", late, latest);
 
+	if (count != N_VBLANKS+1) {
+		fprintf(stderr, "Sentinel frame received too early! %d frames outstanding\n", N_VBLANKS+1 - count);


Reply to: