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

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



 README                     |    6 +-
 man/intel.man              |    6 +-
 src/backlight.c            |   28 ++++++++++---
 src/i915_pciids.h          |    4 +
 src/intel_module.c         |   39 ++++++++++++++++--
 src/sna/brw/brw_eu_emit.c  |    2 
 src/sna/gen9_render.c      |   28 +++++++++++++
 src/sna/sna.h              |    3 +
 src/sna/sna_accel.c        |   32 +++++++--------
 src/sna/sna_display.c      |   96 +++++++++++++++++++++++++++++----------------
 src/sna/sna_display_fake.c |   10 ----
 src/sna/sna_driver.c       |    6 +-
 src/sna/sna_present.c      |    4 -
 src/sna/sna_render.h       |    1 
 src/sna/sna_video_sprite.c |   28 ++++++++-----
 tools/virtual.c            |   24 ++++++++---
 16 files changed, 227 insertions(+), 90 deletions(-)

New commits:
commit 169c74fa6c2cd9c28dd7bfacd9639cd245b8c8a8
Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
Date:   Thu Nov 17 14:46:31 2016 -0800

    intel: Adding Marketing names for Skylake, Kabylake and Apollolake/Broxton.
    
    This commit adding all known marketing names for latest gen9 platforms.
    
    v2: On top of simplified generic string names.
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

diff --git a/src/intel_module.c b/src/intel_module.c
index f9b5d99..6b04857 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -276,6 +276,33 @@ static const SymTabRec intel_chipsets[] = {
 	{0x22b2, "HD Graphics"},
 	{0x22b3, "HD Graphics"},
 
+	/* Skylake */
+	{0x1902, "HD Graphics 510"},
+	{0x1906, "HD Graphics 510"},
+	{0x190B, "HD Graphics 510"},
+	{0x1912, "HD Graphics 530"},
+	{0x1916, "HD Graphics 520"},
+	{0x191B, "HD Graphics 530"},
+	{0x191D, "HD Graphics P530"},
+	{0x191E, "HD Graphics 515"},
+	{0x1921, "HD Graphics 520"},
+	{0x1926, "Iris Graphics 540"},
+	{0x1927, "Iris Graphics 550"},
+	{0x192B, "Iris Graphics 555"},
+	{0x192D, "Iris Graphics P555"},
+	{0x1932, "Iris Pro Graphics 580"},
+	{0x193A, "Iris Pro Graphics P580"},
+	{0x193B, "Iris Pro Graphics 580"},
+	{0x193D, "Iris Pro Graphics P580"},
+
+	/* Broxton (Apollolake) */
+	{0x5A84, "HD Graphics 505"},
+	{0x5A85, "HD Graphics 500"},
+
+	/* Kabylake */
+	{0x5916, "HD Graphics 620"},
+	{0x591E, "HD Graphics 615"},
+
 	/* When adding new identifiers, also update:
 	 * 1. intel_identify()
 	 * 2. man/intel.man

commit 2948cf0531a5165787dc763028ae4c4ac1eed063
Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
Date:   Thu Nov 17 14:46:30 2016 -0800

    intel: Simplify new platform names.
    
    Modern Intel (R) platforms with integrated graphics comes with common
    names varying the range numbers. So instead of listing all supported
    platforms let's start using the generic marketing strings without
    the numbers.
    
    And for the specific board we list it's actual marketing name if
    available on detection.
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

diff --git a/README b/README
index cf4d88d..348983b 100644
--- a/README
+++ b/README
@@ -15,9 +15,9 @@ Intel graphics chipsets including:
 	G/Q33,G/Q35,G41,G/Q43,G/GM/Q45
 	PineView-M (Atom N400 series)
 	PineView-D (Atom D400/D500 series)
-	Intel(R) HD Graphics: 2000-6000,
-	Intel(R) Iris(TM) Graphics: 5100/6100, and
-	Intel(R) Iris(TM) Pro Graphics: 5200/6200/P6300.
+	Intel(R) HD Graphics,
+	Intel(R) Iris(TM) Graphics,
+	Intel(R) Iris(TM) Pro Graphics.
 
 Where to get more information about the driver
 ----------------------------------------------
diff --git a/man/intel.man b/man/intel.man
index 8da496e..be398fb 100644
--- a/man/intel.man
+++ b/man/intel.man
@@ -27,9 +27,9 @@ supports the i810, i810-DC100, i810e, i815, i830M, 845G, 852GM, 855GM,
 865G, 915G, 915GM, 945G, 945GM, 965G, 965Q, 946GZ, 965GM, 945GME,
 G33, Q33, Q35, G35, GM45, G45, Q45, G43, G41 chipsets, Pineview-M in
 Atom N400 series, Pineview-D in Atom D400/D500 series,
-Intel(R) HD Graphics: 2000-6000,
-Intel(R) Iris(TM) Graphics: 5100/6100, and
-Intel(R) Iris(TM) Pro Graphics: 5200/6200/P6300.
+Intel(R) HD Graphics,
+Intel(R) Iris(TM) Graphics,
+Intel(R) Iris(TM) Pro Graphics.
 
 .SH CONFIGURATION DETAILS
 Please refer to __xconfigfile__(__filemansuffix__) for general configuration
diff --git a/src/intel_module.c b/src/intel_module.c
index 68ec9fe..f9b5d99 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -471,9 +471,9 @@ static void intel_identify(int flags)
 	if (unique != stack)
 		free(unique);
 
-	xf86Msg(X_INFO, INTEL_NAME ": Driver for Intel(R) HD Graphics: 2000-6000\n");
-	xf86Msg(X_INFO, INTEL_NAME ": Driver for Intel(R) Iris(TM) Graphics: 5100, 6100\n");
-	xf86Msg(X_INFO, INTEL_NAME ": Driver for Intel(R) Iris(TM) Pro Graphics: 5200, 6200, P6300\n");
+	xf86Msg(X_INFO, INTEL_NAME ": Driver for Intel(R) HD Graphics\n");
+	xf86Msg(X_INFO, INTEL_NAME ": Driver for Intel(R) Iris(TM) Graphics\n");
+	xf86Msg(X_INFO, INTEL_NAME ": Driver for Intel(R) Iris(TM) Pro Graphics\n");
 }
 
 static Bool intel_driver_func(ScrnInfoPtr pScrn,

commit ff25ad3402be3bc20f7b6e680e49ad03d7c6e2af
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Dec 5 21:28:35 2016 +0000

    sna: Reorder frontbuffer resize vs flip event queue draining
    
    If we are not careful, we may process an unflip in the middle of
    resizing the frontbuffer - when the ScreenPixmap state is ill-defined.
    First flush all the pending flip events, cancel any residual unflips,
    then update the screen pixmap. This should be enough to close the race.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=98855#c11
    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 f6b6e5b..1b271ab 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -5679,6 +5679,14 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
 	assert(sna->mode.shadow_damage == NULL);
 	assert(sna->mode.shadow == NULL);
 
+	/* Flush pending shadow updates */
+	if (sna->mode.flip_active) {
+		DBG(("%s: waiting for %d outstanding TearFree flips\n",
+		     __FUNCTION__, sna->mode.flip_active));
+		while (sna->mode.flip_active && sna_mode_wait_for_event(sna))
+			sna_mode_wakeup(sna);
+	}
+
 	/* Cancel a pending [un]flip (as the pixmaps no longer match) */
 	sna_present_cancel_flip(sna);
 	copy_front(sna, sna->front, new_front);
@@ -5692,14 +5700,6 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
 	scrn->virtualY = height;
 	scrn->displayWidth = width;
 
-	/* Flush pending shadow updates */
-	if (sna->mode.flip_active) {
-		DBG(("%s: waiting for %d outstanding TearFree flips\n",
-		     __FUNCTION__, sna->mode.flip_active));
-		while (sna->mode.flip_active && sna_mode_wait_for_event(sna))
-			sna_mode_wakeup(sna);
-	}
-
 	/* Only update the CRTCs if we are in control */
 	if (!scrn->vtSema)
 		return TRUE;
diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index cfff0f1..7c536ab 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -926,12 +926,12 @@ reset_mode:
 		goto notify;
 	}
 
-	assert(sna_pixmap(screen->GetScreenPixmap(screen))->pinned & PIN_SCANOUT);
-
 	/* Are we unflipping after a failure that left our ScreenP in place? */
 	if (!sna_needs_page_flip(sna, bo))
 		goto notify;
 
+	assert(sna_pixmap(screen->GetScreenPixmap(screen))->pinned & PIN_SCANOUT);
+
 	if (sna->flags & SNA_HAS_ASYNC_FLIP) {
 		DBG(("%s: trying async flip restore\n", __FUNCTION__));
 		if (flip__async(sna, NULL, event_id, 0, bo))

commit fcf943f45b674b080dbd07b65f6bfbc89c427c21
Author: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Date:   Mon Dec 5 12:27:14 2016 +0200

    Add Geminialke PCI IDs
    
    Same ids from kernel's
    
    commit 8363e3c3947d0e22955f94a6a87e4f17ce5087b4
    Author: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
    Date:   Thu Nov 10 17:23:08 2016 +0200
    
        drm/i915/glk: Add Geminilake PCI IDs
    
    Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>

diff --git a/src/i915_pciids.h b/src/i915_pciids.h
index 33466bf..e1f46bb 100644
--- a/src/i915_pciids.h
+++ b/src/i915_pciids.h
@@ -336,4 +336,8 @@
 	INTEL_KBL_GT3_IDS(info), \
 	INTEL_KBL_GT4_IDS(info)
 
+#define INTEL_GLK_IDS(info) \
+	INTEL_VGA_DEVICE(0x3184, info), \
+	INTEL_VGA_DEVICE(0x3185, info)
+
 #endif /* _I915_PCIIDS_H */
diff --git a/src/intel_module.c b/src/intel_module.c
index e443c9e..68ec9fe 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -134,6 +134,10 @@ static const struct intel_device_info intel_kabylake_info = {
 	.gen = 0112,
 };
 
+static const struct intel_device_info intel_geminilake_info = {
+	.gen = 0113,
+};
+
 static const SymTabRec intel_chipsets[] = {
 	{PCI_CHIP_I810,				"i810"},
 	{PCI_CHIP_I810_DC100,			"i810-dc100"},
@@ -335,6 +339,8 @@ static const struct pci_id_match intel_device_match[] = {
 
 	INTEL_KBL_IDS(&intel_kabylake_info),
 
+	INTEL_GLK_IDS(&intel_geminilake_info),
+
 	INTEL_VGA_DEVICE(PCI_MATCH_ANY, &intel_generic_info),
 #endif
 
diff --git a/src/sna/gen9_render.c b/src/sna/gen9_render.c
index 5f6b542..e5f12c7 100644
--- a/src/sna/gen9_render.c
+++ b/src/sna/gen9_render.c
@@ -240,6 +240,11 @@ static const struct gt_info kbl_gt_info = {
 	.urb = { .max_vs_entries = 960 },
 };
 
+static const struct gt_info glk_gt_info = {
+	.name = "Geminilake (gen9)",
+	.urb = { .max_vs_entries = 320 },
+};
+
 static bool is_skl(struct sna *sna)
 {
 	return sna->kgem.gen == 0110;
@@ -255,6 +260,11 @@ static bool is_kbl(struct sna *sna)
 	return sna->kgem.gen == 0112;
 }
 
+static bool is_glk(struct sna *sna)
+{
+	return sna->kgem.gen == 0113;
+}
+
 
 static inline bool too_large(int width, int height)
 {
@@ -4028,6 +4038,8 @@ static bool gen9_render_setup(struct sna *sna)
 		state->info = &bxt_gt_info;
 	if (is_kbl(sna))
 		state->info = &kbl_gt_info;
+	if (is_glk(sna))
+		state->info = &glk_gt_info;
 
 	sna_static_stream_init(&general);
 

commit a1b39eb6dd1717501a0546275d07df8321fe4905
Author: James Clarke <jrtc27@jrtc27.com>
Date:   Mon Dec 5 11:30:27 2016 +0000

    sna: Add missing NULL check for readdir result in has_connector_backlight
    
    Signed-off-by: James Clarke <jrtc27@jrtc27.com>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 1d31d00..f6b6e5b 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1033,6 +1033,9 @@ static char *has_connector_backlight(xf86OutputPtr output)
 	DBG(("%s: lookup %s\n", __FUNCTION__, path));
 
 	dir = opendir(path);
+	if (dir == NULL)
+		return NULL;
+
 	while ((de = readdir(dir))) {
 		struct stat st;
 

commit 4acd4a7d3d2f41227022fa7581cfb85a0b124eae
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Dec 5 15:13:24 2016 +0000

    sna/gen9: Emit a dummy primitive between VertexElements
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=98999
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/gen9_render.c b/src/sna/gen9_render.c
index 56c1b8d..5f6b542 100644
--- a/src/sna/gen9_render.c
+++ b/src/sna/gen9_render.c
@@ -1101,6 +1101,17 @@ gen9_emit_vertex_elements(struct sna *sna,
 		return;
 	render->ve_id = id;
 
+	if (render->ve_dirty) {
+		/* dummy primitive to flush vertex before change? */
+		OUT_BATCH(GEN9_3DPRIMITIVE | (7 - 2));
+		OUT_BATCH(0); /* ignored, see VF_TOPOLOGY */
+		OUT_BATCH(0);
+		OUT_BATCH(0);
+		OUT_BATCH(1);	/* single instance */
+		OUT_BATCH(0);	/* start instance location */
+		OUT_BATCH(0);	/* index buffer offset, ignored */
+	}
+
 	/* The VUE layout
 	 *    dword 0-3: pad (0.0, 0.0, 0.0. 0.0)
 	 *    dword 4-7: position (x, y, 1.0, 1.0),
@@ -1198,6 +1209,8 @@ gen9_emit_vertex_elements(struct sna *sna,
 			  offset << VE_OFFSET_SHIFT);
 		OUT_BATCH(dw);
 	}
+
+	render->ve_dirty = true;
 }
 
 inline static void
@@ -1322,6 +1335,7 @@ static bool gen9_magic_ca_pass(struct sna *sna,
 	OUT_BATCH(0);	/* index buffer offset, ignored */
 
 	state->last_primitive = sna->kgem.nbatch;
+	state->ve_dirty = false;
 	return true;
 }
 
@@ -1508,6 +1522,7 @@ static void gen9_emit_primitive(struct sna *sna)
 	sna->render.vertex_start = sna->render.vertex_index;
 
 	sna->render_state.gen9.last_primitive = sna->kgem.nbatch;
+	sna->render_state.gen9.ve_dirty = false;
 }
 
 static bool gen9_rectangle_begin(struct sna *sna,
@@ -3967,6 +3982,7 @@ static void gen9_render_reset(struct sna *sna)
 	sna->render_state.gen9.emit_flush = false;
 	sna->render_state.gen9.needs_invariant = true;
 	sna->render_state.gen9.ve_id = 3 << 2;
+	sna->render_state.gen9.ve_dirty = false;
 	sna->render_state.gen9.last_primitive = -1;
 
 	sna->render_state.gen9.num_sf_outputs = 0;
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index aa2e676..4ba345a 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -623,6 +623,7 @@ struct gen9_render_state {
 
 	bool needs_invariant;
 	bool emit_flush;
+	bool ve_dirty;
 };
 
 struct sna_static_stream {

commit 9ac7a3370ab265d4cbdbbf3dc588af88c37048e1
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Nov 29 22:01:21 2016 +0000

    sna: Handle xf86Randr12 gamma changes in xorg-xserver-1.19
    
    commit 17213b74fd7fc4c4e2fe7a3781e7422dd482a0ab
    Author: Michel Dänzer <michel.daenzer@amd.com>
    Date:   Tue Jun 21 16:44:20 2016 +0900
    
        xfree86/modes: Remove xf86RandR12CrtcGetGamma
    
    removed the randr_crtc->palettes allocation and initialisation causing a
    later dereference of the gamma table to crash. Looks like that was just
    ABI misuse.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=98855
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_display_fake.c b/src/sna/sna_display_fake.c
index f0bdea6..fa26bda 100644
--- a/src/sna/sna_display_fake.c
+++ b/src/sna/sna_display_fake.c
@@ -96,12 +96,6 @@ sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 }
 
 static void
-sna_crtc_gamma_set(xf86CrtcPtr crtc,
-		       CARD16 *red, CARD16 *green, CARD16 *blue, int size)
-{
-}
-
-static void
 sna_crtc_destroy(xf86CrtcPtr crtc)
 {
 }
@@ -109,7 +103,6 @@ sna_crtc_destroy(xf86CrtcPtr crtc)
 static const xf86CrtcFuncsRec sna_crtc_funcs = {
 	.dpms = sna_crtc_dpms,
 	.set_mode_major = sna_crtc_set_mode_major,
-	.gamma_set = sna_crtc_gamma_set,
 	.destroy = sna_crtc_destroy,
 };
 
@@ -298,7 +291,8 @@ static bool add_fake_output(struct sna *sna, bool late)
 
 		RRCrtcSetRotations(crtc->randr_crtc,
 				   RR_Rotate_All | RR_Reflect_All);
-		RRCrtcGammaGet(crtc->randr_crtc);
+		if (!RRCrtcGammaSetSize(crtc->randr_crtc, 256))
+			goto err;
 	}
 
 	sna->mode.num_fake++;

commit f2901dd34d371113cb9ebe70ef91f700f45f7729
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Nov 30 18:53:22 2016 +0000

    sna: Always ask the client to reprobe after userspace
    
    This doesn't guarrantee that the client does, but the kernel insists.
    
    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 1b89cfd..1d31d00 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -5369,6 +5369,7 @@ void sna_mode_discover(struct sna *sna, bool tell)
 {
 	ScreenPtr screen = xf86ScrnToScreen(sna->scrn);
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn);
+	bool force = sna->flags & SNA_REPROBE;
 	struct drm_mode_card_res res;
 	uint32_t connectors[32], now;
 	unsigned changed = 0;
@@ -5402,7 +5403,11 @@ void sna_mode_discover(struct sna *sna, bool tell)
 	if (serial == 0)
 		serial = ++sna->mode.serial;
 
-	now = GetTimeInMillis();
+	if (force) {
+		changed = 4;
+		now = 0;
+	} else
+		now = GetTimeInMillis();
 	for (i = 0; i < res.count_connectors; i++) {
 		DBG(("%s: connector[%d] = %d\n", __FUNCTION__, i, connectors[i]));
 		for (j = 0; j < sna->mode.num_real_output; j++) {
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 5170439..1b4015d 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -806,10 +806,12 @@ sna_handle_uevents(int fd, void *closure)
 			str = udev_device_get_property_value(dev, "HOTPLUG");
 			if (str && atoi(str) == 1) {
 				str = udev_device_get_property_value(dev, "CONNECTOR");
-				if (str)
+				if (str) {
 					hotplug |= sna_mode_find_hotplug_connector(sna, atoi(str));
-				else
+				} else {
+					sna->flags |= SNA_REPROBE;
 					hotplug = true;
+				}
 			}
 		}
 

commit 35473dd9c9455238721a090021b4665fd9259c0c
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Nov 30 23:39:05 2016 +0000

    sna: Prevent switching to GPU rendering when given a SHM pixmap
    
    If we have a SHM pixmap, we only track rendering via the CPU bo for
    synchronisation with the client.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 072c34f..7861110 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -1367,6 +1367,9 @@ static inline void add_shm_flush(struct sna *sna, struct sna_pixmap *priv)
 	if (!priv->shm)
 		return;
 
+	DBG(("%s: marking handle=%d for SHM flush\n",
+	     __FUNCTION__, priv->cpu_bo->handle));
+
 	assert(!priv->flush);
 	sna_add_flush_pixmap(sna, priv, priv->cpu_bo);
 	sna->needs_shm_flush = true;
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 9fe09ff..5d72c0e 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -4044,26 +4044,28 @@ prefer_gpu_bo:
 			goto move_to_gpu;
 		}
 
-		if ((priv->cpu_damage == NULL || flags & IGNORE_DAMAGE)) {
-			if (priv->gpu_bo && priv->gpu_bo->tiling) {
-				DBG(("%s: prefer to use GPU bo for rendering large pixmaps\n", __FUNCTION__));
-				goto prefer_gpu_bo;
+		if (!priv->shm) {
+			if ((priv->cpu_damage == NULL || flags & IGNORE_DAMAGE)) {
+				if (priv->gpu_bo && priv->gpu_bo->tiling) {
+					DBG(("%s: prefer to use GPU bo for rendering large pixmaps\n", __FUNCTION__));
+					goto prefer_gpu_bo;
+				}
+
+				if (priv->cpu_bo->pitch >= 4096) {
+					DBG(("%s: prefer to use GPU bo for rendering wide pixmaps\n", __FUNCTION__));
+					goto prefer_gpu_bo;
+				}
 			}
 
-			if (priv->cpu_bo->pitch >= 4096) {
-				DBG(("%s: prefer to use GPU bo for rendering wide pixmaps\n", __FUNCTION__));
+			if ((flags & IGNORE_DAMAGE) == 0 && priv->cpu_bo->snoop) {
+				DBG(("%s: prefer to use GPU bo for reading from snooped target bo\n", __FUNCTION__));
 				goto prefer_gpu_bo;
 			}
-		}
-
-		if ((flags & IGNORE_DAMAGE) == 0 && priv->cpu_bo->snoop) {
-			DBG(("%s: prefer to use GPU bo for reading from snooped target bo\n", __FUNCTION__));
-			goto prefer_gpu_bo;
-		}
 
-		if (!sna->kgem.can_blt_cpu) {
-			DBG(("%s: can't render to CPU bo, try to use GPU bo\n", __FUNCTION__));
-			goto prefer_gpu_bo;
+			if (!sna->kgem.can_blt_cpu) {
+				DBG(("%s: can't render to CPU bo, try to use GPU bo\n", __FUNCTION__));
+				goto prefer_gpu_bo;
+			}
 		}
 	}
 

commit cdd06717643f4d110a0d9c2b72851f9cb2c64b81
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Nov 30 23:40:14 2016 +0000

    tools/intel-virtual-output: Check for pending events before blocking
    
    If the xlib/xcb library has pulled events from the fd, then a poll on
    that fd will block until new events arrive. If none do, we fail to
    process the currently waiting events in a timely fashion.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/tools/virtual.c b/tools/virtual.c
index 77e6a58..fc8db2b 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -3392,6 +3392,7 @@ int main(int argc, char **argv)
 	uint64_t count;
 	int daemonize = 1, bumblebee = 0, siblings = 0, singleton = 1;
 	int i, ret, open, fail;
+	int idle;
 
 	signal(SIGPIPE, SIG_IGN);
 
@@ -3572,21 +3573,30 @@ int main(int argc, char **argv)
 
 	ctx.command_continuation = 0;
 	update_cursor_image(&ctx);
+
+	idle = 0;
 	while (!done) {
 		XEvent e;
 		int reconfigure = 0;
 		int rr_update = 0;
 
-		DBG(POLL, ("polling - enable timer? %d, nfd=%d, ndisplay=%d\n", ctx.timer_active, ctx.nfd, ctx.ndisplay));
-		ret = poll(ctx.pfd + !ctx.timer_active, ctx.nfd - !ctx.timer_active, -1);
-		if (ret <= 0)
-			break;
+		if (idle) {
+			DBG(POLL, ("polling - enable timer? %d, nfd=%d, ndisplay=%d\n", ctx.timer_active, ctx.nfd, ctx.ndisplay));
+			ret = poll(ctx.pfd + !ctx.timer_active, ctx.nfd - !ctx.timer_active, -1);
+			if (ret <= 0)
+				break;
+
+			DBG(POLL, ("poll reports %d fd awake\n", ret));
+		}
+		idle = 1;
 
 		/* pfd[0] is the timer, pfd[1] is the local display, pfd[2] is the mouse, pfd[3+] are the remotes */
 
-		DBG(POLL, ("poll reports %d fd awake\n", ret));
 		if (ctx.pfd[1].revents || XPending(ctx.display[0].dpy)) {
 			DBG(POLL,("%s woken up\n", DisplayString(ctx.display[0].dpy)));
+			ctx.pfd[1].revents = 0;
+			idle = 0;
+
 			do {
 				XNextEvent(ctx.display->dpy, &e);
 
@@ -3663,6 +3673,9 @@ int main(int argc, char **argv)
 			if (ctx.pfd[i+2].revents == 0 && !XPending(ctx.display[i].dpy))
 				continue;
 
+			ctx.pfd[i+2].revents = 0;
+			idle = 0;
+
 			DBG(POLL, ("%s woken up\n", DisplayString(ctx.display[i].dpy)));
 			do {
 				XNextEvent(ctx.display[i].dpy, &e);
@@ -3742,6 +3755,7 @@ int main(int argc, char **argv)
 
 			DBG(TIMER, ("%s timer still active? %d\n", DisplayString(ctx.display->dpy), ret != 0));
 			ctx.timer_active = ret != 0;
+			idle = 0;
 		}
 	}
 

commit bde946054efbc1c7ae1483b84c3b4fa3c2c7e2ec
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Nov 17 19:22:02 2016 +0000

    backlight: Protect iface writes against signal interruptions
    
    Handle EINTR (and EAGAIN) by repeating until the write is complete.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=98759
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/backlight.c b/src/backlight.c
index d020a7c..3cba577 100644
--- a/src/backlight.c
+++ b/src/backlight.c
@@ -48,6 +48,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <dirent.h>
+#include <errno.h>
 
 #include <xorg-server.h>
 #include <xf86.h>
@@ -216,6 +217,24 @@ __backlight_read(const char *iface, const char *file)
 }
 
 static int
+writen(int fd, const char *value, int len)
+{
+	int ret;
+
+	do {
+		ret = write(fd, value, len);
+		if (ret < 0) {
+			if (errno == EAGAIN || errno == EINTR)
+				continue;
+
+			return ret;
+		}
+	} while (value += ret, len -= ret);
+
+	return 0;
+}
+
+static int
 __backlight_write(const char *iface, const char *file, const char *value)
 {
 	int fd, ret;
@@ -224,7 +243,7 @@ __backlight_write(const char *iface, const char *file, const char *value)
 	if (fd < 0)
 		return -1;
 
-	ret = write(fd, value, strlen(value)+1);
+	ret = writen(fd, value, strlen(value)+1);
 	close(fd);
 
 	return ret;
@@ -458,7 +477,7 @@ err:
 int backlight_set(struct backlight *b, int level)
 {
 	char val[BACKLIGHT_VALUE_LEN];
-	int len, ret = 0;
+	int len;
 
 	if (b->iface == NULL)
 		return 0;
@@ -467,10 +486,7 @@ int backlight_set(struct backlight *b, int level)
 		level = b->max;
 
 	len = snprintf(val, BACKLIGHT_VALUE_LEN, "%d\n", level);
-	if (write(b->fd, val, len) != len)
-		ret = -1;
-
-	return ret;
+	return writen(b->fd, val, len);
 }
 
 int backlight_get(struct backlight *b)

commit 04491bbdaa461aff1a6734a4c2cda093a8ce3482
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Nov 18 16:31:44 2016 +0000

    sna: Set reprobe flag on attached connectors after setcrtc failure
    
    The most common cause of SETCRTC failure is if the connectors disappear.
    Force the reprobe on these after a failure.
    
    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 9f8f862..1b89cfd 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3011,6 +3011,21 @@ static const char *reflection_to_str(Rotation rotation)
 	}
 }
 
+static void reprobe_connectors(xf86CrtcPtr crtc)
+{
+	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+	struct sna *sna = to_sna(crtc->scrn);
+	int i;
+
+	for (i = 0; i < sna->mode.num_real_output; i++) {
+		xf86OutputPtr output = config->output[i];
+		if (output->crtc == crtc)
+			to_sna_output(output)->reprobe = true;
+	}
+
+	sna_mode_discover(sna, true);
+}
+
 static Bool
 __sna_crtc_set_mode(xf86CrtcPtr crtc)
 {
@@ -3105,7 +3120,8 @@ error:
 	sna_crtc->cursor_transform = saved_cursor_transform;
 	sna_crtc->hwcursor = saved_hwcursor;
 	sna_crtc->bo = saved_bo;
-	sna_mode_discover(sna, true);
+
+	reprobe_connectors(crtc);
 	return FALSE;
 }
 

commit a1a0f76e55d8dfbbf27a288b71b4bd3edbfbe836
Author: Matt Roper <matthew.d.roper@intel.com>
Date:   Tue Nov 15 14:36:19 2016 -0800

    sna: Ensure we re-calculate fb_to_cursor transform if sharing cursor
    
    If we find that we're sharing the cursor, we wind up bailing out of
    __sna_get_cursor() before the fb_to_cursor transform is computed.  For
    rotated displays, this can prevent the hotspot transformation from
    happening properly, so the cursor's visible position won't match the
    software's idea of where it is.
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index ebfeb6a..9f8f862 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -5839,20 +5839,6 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 	transformed = to_sna_crtc(crtc)->cursor_transform;
 	rotation = (!transformed && crtc->transform_in_use) ? crtc->rotation : RR_Rotate_0;
 
-	/* Don't allow phys cursor sharing */
-	if (sna->cursor.use_gtt && !transformed) {
-		for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
-			if (cursor->serial == sna->cursor.serial &&
-			    cursor->rotation == rotation &&
-			    !cursor->transformed) {
-				__DBG(("%s: reusing handle=%d, serial=%d, rotation=%d, size=%d\n",
-				       __FUNCTION__, cursor->handle, cursor->serial, cursor->rotation, cursor->size));
-				assert(cursor->size == sna->cursor.size);
-				return cursor;
-			}
-		}
-	}
-
 	if (transformed) {
 		struct pixman_box16 box;
 
@@ -5910,6 +5896,20 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 		       to_sna_crtc(crtc)->cursor_to_fb.m[2][2]));
 	}
 
+	/* Don't allow phys cursor sharing */
+	if (sna->cursor.use_gtt && !transformed) {
+		for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
+			if (cursor->serial == sna->cursor.serial &&
+			    cursor->rotation == rotation &&
+			    !cursor->transformed) {
+				__DBG(("%s: reusing handle=%d, serial=%d, rotation=%d, size=%d\n",
+				       __FUNCTION__, cursor->handle, cursor->serial, cursor->rotation, cursor->size));
+				assert(cursor->size == sna->cursor.size);
+				return cursor;
+			}
+		}
+	}
+
 	cursor = to_sna_crtc(crtc)->cursor;
 	if (cursor && cursor->alloc < 4*size*size)
 		cursor = NULL;

commit 0472b1f0fe1510c9709279d30ae033d766f44118
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Nov 15 22:01:10 2016 +0000

    sna: Acquire cursor before use in sna_cursor_set_position()
    
    sna_cursor_set_position() requires an already computed cursor
    transformation matrix in order to determine whether the cursor is
    visible. This is computed in __sna_get_cursor() which is currently only
    called for visible cursors - i.e. we were using uninitialised state.
    
    Reported-by: Matt Roper <matthew.d.roper@intel.com>
    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 24e3603..ebfeb6a 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -6296,6 +6296,14 @@ sna_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
 		if (sna_crtc->bo == NULL)
 			goto disable;
 
+		cursor = __sna_get_cursor(sna, crtc);
+		if (cursor == NULL)
+			cursor = sna_crtc->cursor;
+		if (cursor == NULL) {
+			__DBG(("%s: failed to grab cursor, disabling\n", __FUNCTION__));
+			goto disable;
+		}
+
 		if (crtc->transform_in_use) {
 			int xhot = sna->cursor.ref->bits->xhot;
 			int yhot = sna->cursor.ref->bits->yhot;
@@ -6320,15 +6328,6 @@ sna_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
 
 		if (arg.x < crtc->mode.HDisplay && arg.x > -sna->cursor.size &&
 		    arg.y < crtc->mode.VDisplay && arg.y > -sna->cursor.size) {
-			cursor = __sna_get_cursor(sna, crtc);
-			if (cursor == NULL)
-				cursor = sna_crtc->cursor;
-			if (cursor == NULL) {
-				__DBG(("%s: failed to grab cursor, disabling\n",
-				       __FUNCTION__));
-				goto disable;
-			}
-
 			if (sna_crtc->cursor != cursor || sna_crtc->last_cursor_size != cursor->size) {
 				arg.flags |= DRM_MODE_CURSOR_BO;
 				arg.handle = cursor->handle;

commit 01114334dd893863ad4bbe72fc94a278aa36bfa5
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Nov 15 21:58:26 2016 +0000

    sna: Recompute the cursor after a modeset
    
    As a modeset may adjust the rotation or the transform of the cursor, we
    may need to recompute the cursor image afterwards.
    
    Reported-by: Matt Roper <matthew.d.roper@intel.com>
    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 59ecfd3..24e3603 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -2878,6 +2878,13 @@ static void sna_crtc_randr(xf86CrtcPtr crtc)
 	} else
 		crtc->transform_in_use = sna_crtc->rotation != RR_Rotate_0;
 
+	/* Recompute the cursor after a potential change in transform */
+	if (sna_crtc->cursor) {
+		assert(sna_crtc->cursor->ref > 0);
+		sna_crtc->cursor->ref--;
+		sna_crtc->cursor = NULL;
+	}
+
 	if (needs_transform) {
 		sna_crtc->hwcursor = is_affine(&f_fb_to_crtc);
 		sna_crtc->cursor_transform =

commit d1d14f20cfd6412adbd6f937f54c814c2a332e6f
Author: Sergei Trofimovich <siarheit@google.com>
Date:   Fri Nov 11 09:00:15 2016 +0000

    brw_eu_emit.c: fix wrong test on a register type
    
    Caught by gcc-6 as:
        brw_eu_emit.c:180:49: warning: logical 'and' of equal expressions [-Wlogical-op]
    
        if (reg.file == BRW_ARCHITECTURE_REGISTER_FILE &&
            reg.file == BRW_ARF_NULL)
            return;
    
    Change uses 'reg.nr' test for 'BRW_ARF_NULL'.
    
    Signed-off-by: Sergei Trofimovich <siarheit@google.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/brw/brw_eu_emit.c b/src/sna/brw/brw_eu_emit.c
index 2f33022..154f939 100644
--- a/src/sna/brw/brw_eu_emit.c
+++ b/src/sna/brw/brw_eu_emit.c
@@ -178,7 +178,7 @@ validate_reg(struct brw_instruction *insn, struct brw_reg reg)
 	}
 
 	if (reg.file == BRW_ARCHITECTURE_REGISTER_FILE &&
-	    reg.file == BRW_ARF_NULL)
+	    reg.nr == BRW_ARF_NULL)
 		return;
 
 	assert(reg.hstride >= 0 && reg.hstride < ARRAY_SIZE(hstride_for_reg));

commit dad64e9f76c718033402be7bfd2129866d492304
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Nov 10 15:38:18 2016 +0000

    sna/video: Mark the bo as clean after a setplane
    
    The kernel will flush it, so we can treat it as clean after a successful
    setplane.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
index adb7ba2..bef1a44 100644
--- a/src/sna/sna_video_sprite.c
+++ b/src/sna/sna_video_sprite.c
@@ -370,7 +370,7 @@ sna_video_sprite_show(struct sna *sna,
 		return false;
 	}
 
-	frame->bo->domain = DOMAIN_NONE;
+	__kgem_bo_clear_dirty(frame->bo);
 
 	if (video->bo[pipe])
 		kgem_bo_destroy(&sna->kgem, video->bo[pipe]);
@@ -580,7 +580,6 @@ off:
 			ret = BadAlloc;
 		}
 
-		frame.bo->domain = DOMAIN_NONE;
 		if (cache_bo)
 			sna_video_buffer_fini(video);
 		else

commit 65b680e6cf6b710e6feb23d707f728e89bee4a22
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Nov 10 15:36:23 2016 +0000


Reply to: