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

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



 src/compat-api.h           |    4 
 src/i915_pciids.h          |   10 -
 src/sna/gen2_render.c      |    4 
 src/sna/gen3_render.c      |    4 
 src/sna/gen4_render.c      |    4 
 src/sna/gen5_render.c      |    4 
 src/sna/gen6_render.c      |    4 
 src/sna/gen7_render.c      |    4 
 src/sna/gen8_render.c      |    4 
 src/sna/gen9_render.c      |    4 
 src/sna/sna.h              |   10 -
 src/sna/sna_display.c      |  313 ++++++++++++++++++++++-----------------------
 src/sna/sna_dri2.c         |   15 +-
 src/sna/sna_driver.c       |    4 
 src/sna/sna_video.h        |    2 
 src/sna/sna_video_sprite.c |  100 ++++++++------
 src/uxa/intel_driver.c     |    2 
 17 files changed, 263 insertions(+), 229 deletions(-)

New commits:
commit 26f8ab5429a554801641415f0ab3b2d68cea1d00
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Jul 4 10:11:50 2016 +0100

    sna: Restore local damage processing for TearFree/DRI2/swcursor early
    
    We currently hack TearFree/DRI2/swcursor to avoid recursion from inside
    the SwapBuffers to handle the swcursor. This has the issue of a trailing
    cursor on the boundary of the DRI2 drawable, but prevents the explosion
    from swapping TearFree buffers from within the TearFree handler (i.e.
    recursion). This only has to apply to the damage processing before the
    swap.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index 3838468..4ec0cca 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -1037,8 +1037,8 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo)
 	assert(bo->flush);
 
 	if (APPLY_DAMAGE) {
-		DamageRegionProcessPending(&pixmap->drawable);
 		sna->ignore_copy_area = false;
+		DamageRegionProcessPending(&pixmap->drawable);
 	}
 }
 
@@ -1394,8 +1394,8 @@ __sna_dri2_copy_region(struct sna *sna, DrawablePtr draw, RegionPtr region,
 	}
 
 	if (APPLY_DAMAGE || flags & DRI2_DAMAGE) {
-		DamageRegionProcessPending(&pixmap->drawable);
 		sna->ignore_copy_area = false;
+		DamageRegionProcessPending(&pixmap->drawable);
 	}
 
 	if (clip.data)
@@ -2421,8 +2421,8 @@ static void sna_dri2_xchg_crtc(struct sna *sna, DrawablePtr draw, xf86CrtcPtr cr
 	}
 	sna_shadow_set_crtc(sna, crtc, get_private(back)->bo);
 	if (APPLY_DAMAGE) {
-		DamageRegionProcessPending(&win->drawable);
 		sna->ignore_copy_area = false;
+		DamageRegionProcessPending(&win->drawable);
 	}
 
 	if (priv->front == NULL) {

commit 4556ac396ed46a476cc970946011e377451346ff
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Jul 4 10:07:51 2016 +0100

    sna: Track TearFree shadow as an active scanout
    
    Don't allow DRI2 to hand back the current shadow buffer as a Drawable's
    next back buffer.
    
    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 e9f3707..10d33f2 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1726,11 +1726,13 @@ static bool wait_for_shadow(struct sna *sna,
 	sna_pixmap_unmap(pixmap, priv);
 
 	DBG(("%s: setting front pixmap to handle=%d\n", __FUNCTION__, bo->handle));
+	sna->mode.shadow->active_scanout--;
 	tmp = priv->gpu_bo;
 	priv->gpu_bo = bo;
 	if (bo != sna->mode.shadow)
 		kgem_bo_destroy(&sna->kgem, sna->mode.shadow);
 	sna->mode.shadow = tmp;
+	sna->mode.shadow->active_scanout++;
 
 	sna_dri2_pixmap_update_bo(sna, pixmap, bo);
 
@@ -1852,6 +1854,7 @@ static void sna_mode_disable_shadow(struct sna *sna)
 	sna->mode.shadow_enabled = false;
 
 	if (sna->mode.shadow) {
+		sna->mode.shadow->active_scanout--;
 		kgem_bo_destroy(&sna->kgem, sna->mode.shadow);
 		sna->mode.shadow = NULL;
 	}
@@ -2323,6 +2326,7 @@ static void set_shadow(struct sna *sna, RegionPtr region)
 
 	assert(priv->gpu_bo);
 	assert(sna->mode.shadow);
+	assert(sna->mode.shadow->active_scanout);
 
 	DBG(("%s: waiting for region %dx[(%d, %d), (%d, %d)], front handle=%d, shadow handle=%d\n",
 	     __FUNCTION__,
@@ -2631,6 +2635,7 @@ out_shadow:
 				assert(__sna_pixmap_get_bo(sna->front) == NULL ||
 				       __sna_pixmap_get_bo(sna->front)->pitch == shadow->pitch);
 				sna->mode.shadow = shadow;
+				sna->mode.shadow->active_scanout++;
 			}
 			set_shadow(sna, &region);
 

commit 9154dff9aedad3271f629edb1ccc9c8d273ca7bc
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sat Jul 2 17:25:14 2016 +0100

    DRI3 is not supported by mesa/i915
    
    Since mesa requires __DRI2_FLUSH version 4 for its DRI3 support and
    mesa/i915 only provides version 3, libGL fails to load (not even falling
    back to DRI2). Workaround this by not enabling DRI3.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=96783
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index fce64ba..455113f 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -437,7 +437,7 @@ static void setup_dri(struct sna *sna)
 
 	level = intel_option_cast_to_unsigned(sna->Options, OPTION_DRI, DEFAULT_DRI_LEVEL);
 #if HAVE_DRI3
-	if (level >= 3)
+	if (level >= 3 && sna->kgem.gen >= 040)
 		sna->dri3.available = !!xf86LoadSubModule(sna->scrn, "dri3");
 #endif
 #if HAVE_DRI2
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 8f76b34..73d7f4f 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -244,7 +244,7 @@ static void intel_check_dri_option(ScrnInfoPtr scrn)
 
 	intel->dri2 = intel->dri3 = DRI_NONE;
 	level = intel_option_cast_to_unsigned(intel->Options, OPTION_DRI, DEFAULT_DRI_LEVEL);
-	if (level < 3)
+	if (level < 3 || INTEL_INFO(intel)->gen < 040)
 		intel->dri3 = DRI_DISABLED;
 	if (level < 2)
 		intel->dri2 = DRI_DISABLED;

commit 784dc0228a61661ecb1c3e7b2279bf3811d1309d
Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
Date:   Tue Jun 28 17:02:32 2016 -0700

    pciids: Removing PCI IDs that are no longer listed as Kabylake.
    
    This is unusual. Usually IDs listed on early stages of platform
    definition are kept there as reserved for later use.
    
    However these IDs here are not listed anymore in any of steppings
    and devices IDs tables for Kabylake on configurations overview
    section of BSpec.
    
    So it is better removing them before they become used in any
    other future platform.
    
    It reflects kernel:
    commit a922eb8d4581c883c37ce6e12dca9ff2cb1ea723
    Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Date:   Thu Jun 23 14:50:36 2016 -0700
        drm/i915: Removing PCI IDs that are no longer listed as Kabylake.
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/i915_pciids.h b/src/i915_pciids.h
index 87dde1c..33466bf 100644
--- a/src/i915_pciids.h
+++ b/src/i915_pciids.h
@@ -325,15 +325,10 @@
 #define INTEL_KBL_GT3_IDS(info) \
 	INTEL_VGA_DEVICE(0x5923, info), /* ULT GT3 */ \
 	INTEL_VGA_DEVICE(0x5926, info), /* ULT GT3 */ \
-	INTEL_VGA_DEVICE(0x5927, info), /* ULT GT3 */ \
-	INTEL_VGA_DEVICE(0x592B, info), /* Halo GT3 */ \
-	INTEL_VGA_DEVICE(0x592A, info) /* SRV GT3 */
+	INTEL_VGA_DEVICE(0x5927, info) /* ULT GT3 */
 
 #define INTEL_KBL_GT4_IDS(info) \
-	INTEL_VGA_DEVICE(0x5932, info), /* DT  GT4 */ \
-	INTEL_VGA_DEVICE(0x593B, info), /* Halo GT4 */ \
-	INTEL_VGA_DEVICE(0x593A, info), /* SRV GT4 */ \
-	INTEL_VGA_DEVICE(0x593D, info)  /* WKS GT4 */
+	INTEL_VGA_DEVICE(0x593B, info) /* Halo GT4 */
 
 #define INTEL_KBL_IDS(info) \
 	INTEL_KBL_GT1_IDS(info), \

commit 97be00cb38ac508acc1dbbfda4835d32b0445fa4
Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
Date:   Tue Jun 28 17:02:31 2016 -0700

    pciids: Add more Kabylake PCI IDs.
    
    The spec has been updated adding new PCI IDs.
    
    In parity with kernel:
    commit 33d9391d3020e069dca98fa87a604c037beb2b9e
    Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Date:   Thu Jun 23 14:50:35 2016 -0700
    
        drm/i915: Add more Kabylake PCI IDs.
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/i915_pciids.h b/src/i915_pciids.h
index 9094599..87dde1c 100644
--- a/src/i915_pciids.h
+++ b/src/i915_pciids.h
@@ -309,6 +309,7 @@
 	INTEL_VGA_DEVICE(0x5906, info), /* ULT GT1 */ \
 	INTEL_VGA_DEVICE(0x590E, info), /* ULX GT1 */ \
 	INTEL_VGA_DEVICE(0x5902, info), /* DT  GT1 */ \
+	INTEL_VGA_DEVICE(0x5908, info), /* Halo GT1 */ \
 	INTEL_VGA_DEVICE(0x590B, info), /* Halo GT1 */ \
 	INTEL_VGA_DEVICE(0x590A, info) /* SRV GT1 */
 
@@ -322,7 +323,9 @@
 	INTEL_VGA_DEVICE(0x591D, info) /* WKS GT2 */
 
 #define INTEL_KBL_GT3_IDS(info) \
+	INTEL_VGA_DEVICE(0x5923, info), /* ULT GT3 */ \
 	INTEL_VGA_DEVICE(0x5926, info), /* ULT GT3 */ \
+	INTEL_VGA_DEVICE(0x5927, info), /* ULT GT3 */ \
 	INTEL_VGA_DEVICE(0x592B, info), /* Halo GT3 */ \
 	INTEL_VGA_DEVICE(0x592A, info) /* SRV GT3 */
 

commit bc369bbf4aed9df3c802bf8759bbdcdd1232f893
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Jun 28 12:26:55 2016 +0100

    sna: Avoid recursion by testing shadow.wait
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=96695
    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 2ec9835..e9f3707 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1538,12 +1538,12 @@ static bool wait_for_shadow(struct sna *sna,
 	assert(priv->move_to_gpu_data == sna);
 	assert(sna->mode.shadow != priv->gpu_bo);
 
-	if (flags == 0 || pixmap != sna->front)
+	if (flags == 0 || pixmap != sna->front || !sna->mode.shadow_enabled)
 		goto done;
 
-	if (!sna->mode.shadow_enabled)
-		return ret;
 	assert(sna->mode.shadow_damage);
+	if (sna->mode.shadow_wait)
+		return ret;
 
 	if ((flags & MOVE_WRITE) == 0) {
 		if ((flags & __MOVE_SCANOUT) == 0) {
@@ -1586,7 +1586,6 @@ static bool wait_for_shadow(struct sna *sna,
 
 	assert(sna->mode.shadow_active);
 	sna->mode.shadow_wait = true;
-	sna->mode.shadow_enabled = false;
 
 	flip_active = sna->mode.flip_active;
 	if (flip_active) {
@@ -1638,10 +1637,8 @@ static bool wait_for_shadow(struct sna *sna,
 			bo = sna->mode.shadow;
 		}
 	}
-	assert(!sna->mode.shadow_enabled);
 	assert(sna->mode.shadow_wait);
 	sna->mode.shadow_wait = false;
-	sna->mode.shadow_enabled = true;
 
 	if (bo->refcnt > 1) {
 		bo = kgem_create_2d(&sna->kgem,
diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index dd4598c..3838468 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -2513,7 +2513,7 @@ static void chain_swap(struct sna_dri2_event *chain)
 	switch (chain->type) {
 	case SWAP_COMPLETE:
 		DBG(("%s: emitting chained vsync'ed blit\n", __FUNCTION__));
-		if (chain->sna->mode.shadow && chain->sna->mode.shadow_wait) {
+		if (chain->sna->mode.shadow_wait) {
 			/* recursed from wait_for_shadow(), simply requeue */
 			DBG(("%s -- recursed from wait_for_shadow(), requeuing\n", __FUNCTION__));
 			if (sna_next_vblank(chain))
@@ -2608,7 +2608,7 @@ void sna_dri2_vblank_handler(struct drm_event_vblank *event)
 		/* else fall through to blit */
 	case SWAP:
 		assert(info->signal);
-		if (sna->mode.shadow && sna->mode.shadow_wait) {
+		if (sna->mode.shadow_wait) {
 			/* recursed from wait_for_shadow(), simply requeue */
 			DBG(("%s -- recursed from wait_for_shadow(), requeuing\n", __FUNCTION__));
 		} else if (can_xchg(info->sna, draw, info->front, info->back)) {
@@ -2654,7 +2654,7 @@ void sna_dri2_vblank_handler(struct drm_event_vblank *event)
 			     info->pending.bo->handle, info->pending.name, info->pending.bo->active_scanout,
 			     get_private(info->front)->bo->handle, info->front->name, get_private(info->front)->bo->active_scanout));
 
-			if (sna->mode.shadow && sna->mode.shadow_wait) {
+			if (sna->mode.shadow_wait) {
 				/* recursed from wait_for_shadow(), simply requeue */
 				DBG(("%s -- recursed from wait_for_shadow(), requeuing\n", __FUNCTION__));
 				if (sna_next_vblank(info))

commit cac7c8dc4b154d37ff27430aa7b714ac84f3d092
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sat Jun 25 10:36:38 2016 +0100

    sna: Skip wait_for_shadow() when shadow is temporarily disabled
    
    When recursing, we guard against unwanted waits by temporarily disabling
    the shadow. For the most part, we actually defer the wait to avoid
    recursion, but in a few instances detecting the recursion is hard (e.g.
    finishing a vblank and then performing the FakeFront copy). Here, we
    just ignore shadow (it should only be a read of valid data) and exit to
    avoid the assertion.
    
    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 5785757..2ec9835 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1538,9 +1538,11 @@ static bool wait_for_shadow(struct sna *sna,
 	assert(priv->move_to_gpu_data == sna);
 	assert(sna->mode.shadow != priv->gpu_bo);
 
-	if (flags == 0 || pixmap != sna->front || !sna->mode.shadow_enabled)
+	if (flags == 0 || pixmap != sna->front)
 		goto done;
 
+	if (!sna->mode.shadow_enabled)
+		return ret;
 	assert(sna->mode.shadow_damage);
 
 	if ((flags & MOVE_WRITE) == 0) {

commit e827ef7811da992c6cc7bc9553f0f6f68287ce4b
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sat Jun 25 10:35:59 2016 +0100

    sna: Fixup DBG for sprite rename
    
    A few compiled out DBG escaped the sprite rename.
    
    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 2ef42f1..5785757 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1288,15 +1288,16 @@ bool sna_crtc_set_sprite_rotation(xf86CrtcPtr crtc,
 {
 	struct plane *sprite;
 	assert(to_sna_crtc(crtc));
-	DBG(("%s: CRTC:%d [pipe=%d], sprite=%u set-rotation=%x\n",
-	     __FUNCTION__,
-	     sna_crtc_id(crtc), sna_crtc_pipe(crtc),
-	     to_sna_crtc(crtc)->sprite.id, rotation));
 
 	sprite = lookup_sprite(to_sna_crtc(crtc), idx);
 	if (!sprite)
 		return false;
 
+	DBG(("%s: CRTC:%d [pipe=%d], sprite=%u set-rotation=%x\n",
+	     __FUNCTION__,
+	     sna_crtc_id(crtc), sna_crtc_pipe(crtc),
+	     sprite->id, rotation));
+
 	return rotation_set(to_sna(crtc->scrn), sprite,
 			    rotation_reduce(sprite, rotation));
 }
@@ -3351,10 +3352,9 @@ sna_crtc_add(ScrnInfoPtr scrn, unsigned id)
 	sna_crtc_init__rotation(sna, sna_crtc);
 	sna_crtc_find_planes(sna, sna_crtc);
 
-	DBG(("%s: CRTC:%d [pipe=%d], primary id=%x: supported-rotations=%x, current-rotation=%x, sprite id=%x: supported-rotations=%x, current-rotation=%x\n",
+	DBG(("%s: CRTC:%d [pipe=%d], primary id=%x: supported-rotations=%x, current-rotation=%x\n",
 	     __FUNCTION__, id, get_pipe.pipe,
-	     sna_crtc->primary.id, sna_crtc->primary.rotation.supported, sna_crtc->primary.rotation.current,
-	     sna_crtc->sprite.id, sna_crtc->sprite.rotation.supported, sna_crtc->sprite.rotation.current));
+	     sna_crtc->primary.id, sna_crtc->primary.rotation.supported, sna_crtc->primary.rotation.current));
 
 	list_init(&sna_crtc->shadow_link);
 
@@ -3558,7 +3558,7 @@ static void sna_output_set_parsed_edid(xf86OutputPtr output, xf86MonPtr mon)
 
 	if (output->mm_width != conn_mm_width || output->mm_height != conn_mm_height) {
 		DBG(("%s)%s): kernel and Xorg disagree over physical size: kernel=%dx%dmm, Xorg=%dx%dmm\n",
-		     __FUNCION__, output->name,
+		     __FUNCTION__, output->name,
 		     conn_mm_width, conn_mm_height,
 		     output->mm_width, output->mm_height));
 	}

commit c28e62f94f15c9f5c4fb0744588f08ae18e4a9b5
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Jun 21 21:19:46 2016 +0100

    sna/gen2+: Do not force migration to GPU for very large objects
    
    If the target is larger than the maximum render size, allow us not to
    migrate to the GPU if it is entirely damaged on the CPU.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index 12b741c..37ded24 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -1619,7 +1619,9 @@ gen2_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index eeea91f..4459a56 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -3228,7 +3228,9 @@ gen3_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 552da49..72a98ae 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1647,7 +1647,9 @@ gen4_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index e162f9f..fb3e79b 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1599,7 +1599,9 @@ gen5_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index ee17593..6b69f21 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1908,7 +1908,9 @@ gen6_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index f707d39..aabb869 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2150,7 +2150,9 @@ gen7_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen8_render.c b/src/sna/gen8_render.c
index f979ba8..445983b 100644
--- a/src/sna/gen8_render.c
+++ b/src/sna/gen8_render.c
@@ -1996,7 +1996,9 @@ gen8_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)
diff --git a/src/sna/gen9_render.c b/src/sna/gen9_render.c
index 7b41cdb..801d514 100644
--- a/src/sna/gen9_render.c
+++ b/src/sna/gen9_render.c
@@ -2002,7 +2002,9 @@ gen9_composite_set_target(struct sna *sna,
 	} else
 		sna_render_picture_extents(dst, &box);
 
-	hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+	hint = PREFER_GPU | RENDER_GPU;
+	if (!need_tiling(sna, op->dst.width, op->dst.height))
+		hint |= FORCE_GPU;
 	if (!partial) {
 		hint |= IGNORE_DAMAGE;
 		if (w == op->dst.width && h == op->dst.height)

commit f1c757e4518f6835bbff6c940269a5c6be75f202
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Jun 21 21:17:15 2016 +0100

    sna: Only shutdown unknown secondary planes on CRTC we control
    
    In a ZaphodHead scenario, we do not own all the CRTC and so we should
    not be making changes outside of our zone of control. Also, we only want
    to disable secondary overlay planes and ignore the secondary cursor
    planes which are controlled through the normal modesetting.
    
    As we are now tracking all sprite planes on a CRTC, this leads to much
    simpler code.
    
    Reported-by: Egbert Eich <eich@freedesktop.org>
    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 d790975..2ef42f1 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -7928,143 +7928,46 @@ static bool sna_mode_shutdown_crtc(xf86CrtcPtr crtc)
 	return disabled;
 }
 
-static xf86CrtcPtr
-lookup_crtc_by_id(struct sna *sna, int id)
+static bool
+sna_mode_disable_secondary_planes(struct sna *sna)
 {
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn);
+	bool disabled = false;
 	int c;
 
+	/* Disable all secondary planes on our CRTCs, just in case
+	 * other userspace left garbage in them.
+	 */
 	for (c = 0; c < sna->mode.num_real_crtc; c++) {
 		xf86CrtcPtr crtc = config->crtc[c];
-		if (__sna_crtc_id(to_sna_crtc(crtc)) == id)
-			return crtc;
-	}
-
-	return NULL;
-}
-
-static int plane_type(struct sna *sna, int id)
-{
-	struct local_mode_obj_get_properties arg;
-	uint64_t stack_props[24];
-	uint32_t *props = (uint32_t *)stack_props;
-	uint64_t *values = stack_props + 8;
-	int i, type = -1;
-
-	memset(&arg, 0, sizeof(struct local_mode_obj_get_properties));
-	arg.obj_id = id;
-	arg.obj_type = LOCAL_MODE_OBJECT_PLANE;
-
-	arg.props_ptr = (uintptr_t)props;
-	arg.prop_values_ptr = (uintptr_t)values;
-	arg.count_props = 16;
-
-	if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_OBJ_GETPROPERTIES, &arg))
-		return -1;
-
-	DBG(("%s: object %d (type %x) has %d props\n", __FUNCTION__,
-	     id, LOCAL_MODE_OBJECT_PLANE, arg.count_props));
-
-	if (arg.count_props > 16) {
-		props = malloc(2*sizeof(uint64_t)*arg.count_props);
-		if (props == NULL)
-			return -1;
-
-		values = (uint64_t *)props + arg.count_props;
-
-		arg.props_ptr = (uintptr_t)props;
-		arg.prop_values_ptr = (uintptr_t)values;
-
-		if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_OBJ_GETPROPERTIES, &arg))
-			arg.count_props = 0;
-	}
-	VG(VALGRIND_MAKE_MEM_DEFINED(arg.props_ptr, sizeof(uint32_t)*arg.count_props));
-	VG(VALGRIND_MAKE_MEM_DEFINED(arg.prop_values_ptr, sizeof(uint64_t)*arg.count_props));
-
-	for (i = 0; i < arg.count_props; i++) {
-		struct drm_mode_get_property prop;
-
-		memset(&prop, 0, sizeof(prop));
-		prop.prop_id = props[i];
-		if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) {
-			ERR(("%s: prop[%d].id=%d GETPROPERTY failed with errno=%d\n",
-			     __FUNCTION__, i, props[i], errno));
-			continue;
-		}
-
-		DBG(("%s: prop[%d] .id=%ld, .name=%s, .flags=%x, .value=%ld\n", __FUNCTION__, i,
-		     (long)props[i], prop.name, (unsigned)prop.flags, (long)values[i]));
-
-		if (strcmp(prop.name, "type") == 0) {
-			type = values[i];
-			break;
-		}
-	}
-
-	if (props != (uint32_t *)stack_props)
-		free(props);
-
-	return type;
-}
-
-static bool
-sna_mode_disable_secondary_planes(struct sna *sna)
-{
-	struct local_mode_get_plane_res r;
-	uint32_t stack_planes[64];
-	uint32_t *planes = stack_planes;
-	bool disabled = false;
-	int i;
-
-	VG_CLEAR(r);
-	r.plane_id_ptr = (uintptr_t)planes;
-	r.count_planes = ARRAY_SIZE(stack_planes);
-	if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_GETPLANERESOURCES, &r))
-		return false;
-
-	DBG(("%s: %d planes\n", __FUNCTION__, (int)r.count_planes));
-
-	if (r.count_planes > ARRAY_SIZE(stack_planes)) {
-		planes = malloc(sizeof(uint32_t)*r.count_planes);
-		if (planes == NULL)
-			return false;
-
-		r.plane_id_ptr = (uintptr_t)planes;
-		if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_GETPLANERESOURCES, &r))
-			r.count_planes = 0;
-	}
-
-	VG(VALGRIND_MAKE_MEM_DEFINED(planes, sizeof(uint32_t)*r.count_planes));
-
-	for (i = 0; i < r.count_planes; i++) {
-		struct local_mode_get_plane p;
-		struct local_mode_set_plane s;
+		struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
+		struct plane *plane;
 
-		VG_CLEAR(p);
-		p.plane_id = planes[i];
-		p.count_format_types = 0;
-		if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_GETPLANE, &p))
-			continue;
+		list_for_each_entry(plane, &sna_crtc->sprites, link) {
+			struct local_mode_get_plane p;
+			struct local_mode_set_plane s;
 
-		if (p.fb_id == 0 || p.crtc_id == 0)
-			continue;
+			VG_CLEAR(p);
+			p.plane_id = plane->id;
+			p.count_format_types = 0;
+			if (drmIoctl(sna->kgem.fd,
+				     LOCAL_IOCTL_MODE_GETPLANE,
+				     &p))
+				continue;
 
-		if (plane_type(sna, p.plane_id) == DRM_PLANE_TYPE_PRIMARY)
-			continue;
+			if (p.fb_id == 0 || p.crtc_id == 0)
+				continue;
 
-		memset(&s, 0, sizeof(s));
-		s.plane_id = p.plane_id;
-		s.crtc_id = p.crtc_id;
-		if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s)) {
-			xf86CrtcPtr crtc = lookup_crtc_by_id(sna, p.crtc_id);
-			if (crtc)
+			memset(&s, 0, sizeof(s));
+			s.plane_id = p.plane_id;
+			s.crtc_id = p.crtc_id;
+			if (drmIoctl(sna->kgem.fd,
+				     LOCAL_IOCTL_MODE_SETPLANE,
+				     &s))
 				disabled |= sna_mode_shutdown_crtc(crtc);
 		}
 	}
 
-	if (planes != stack_planes)
-		free(planes);
-
 	return disabled;
 }
 

commit 7b6e219fe461fbbe0bd498f7731781358d11f934
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Jun 20 12:04:02 2016 +0100

    sna: Hide compiler warnings for change in uAPI defines
    
    Just a minor, safe, change in the uAPI defines for DRM_CAP_CURSOR_WIDTH
    causes the compiler to spit out a warning. (The warning was intentional
    to check that when the defines were added to the uAPI they matched. Now
    that they are concrete in the uABI, but the defines are subject to the
    whims of the author.)
    
    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 a22d94e..d790975 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -6296,8 +6296,12 @@ sna_cursor_pre_init(struct sna *sna)
 		return;
 
 #define LOCAL_IOCTL_GET_CAP	DRM_IOWR(0x0c, struct local_get_cap)
-#define DRM_CAP_CURSOR_WIDTH	8
-#define DRM_CAP_CURSOR_HEIGHT	9
+#ifndef DRM_CAP_CURSOR_WIDTH
+#define DRM_CAP_CURSOR_WIDTH	0x8
+#endif
+#ifndef DRM_CAP_CURSOR_HEIGHT
+#define DRM_CAP_CURSOR_HEIGHT	0x9
+#endif
 
 #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
 

commit ebc5e9c3b2241be69bee7b96bd63ef00dacf816c
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Jun 20 11:44:23 2016 +0100

    sna/video: Create one XvAdapter for each sprite plane
    
    The caveat here is that the sprite plane must be available on all CRTCs
    so that the availability of the XvAdapter is not dependent upon output
    configuration or Window placement.
    
    Based on a patch by Michael Hadley <michaelx.hadley@intel.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 033781e..64bf498 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -611,6 +611,7 @@ static inline void sna_present_vblank_handler(struct drm_event_vblank *event) {
 static inline void sna_present_cancel_flip(struct sna *sna) { }
 #endif
 
+extern unsigned sna_crtc_count_sprites(xf86CrtcPtr crtc);
 extern bool sna_crtc_set_sprite_rotation(xf86CrtcPtr crtc, unsigned idx, uint32_t rotation);
 extern uint32_t sna_crtc_to_sprite(xf86CrtcPtr crtc, unsigned idx);
 extern bool sna_crtc_is_transformed(xf86CrtcPtr crtc);
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 2f54ff1..a22d94e 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -445,6 +445,18 @@ static inline uint32_t fb_id(struct kgem_bo *bo)
 	return bo->delta;
 }
 
+unsigned sna_crtc_count_sprites(xf86CrtcPtr crtc)
+{
+	struct plane *sprite;
+	unsigned count;
+
+	count = 0;
+	list_for_each_entry(sprite, &to_sna_crtc(crtc)->sprites, link)
+		count++;
+
+	return count;
+}
+
 static struct plane *lookup_sprite(struct sna_crtc *crtc, unsigned idx)
 {
 	struct plane *sprite;
diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
index a302b5d..1a2b1c8 100644
--- a/src/sna/sna_video_sprite.c
+++ b/src/sna/sna_video_sprite.c
@@ -654,6 +654,7 @@ static int sna_video_sprite_color_key(struct sna *sna)
 static int sna_video_has_sprites(struct sna *sna)
 {
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn);
+	unsigned min;
 	int i;
 
 	DBG(("%s: num_crtc=%d\n", __FUNCTION__, sna->mode.num_real_crtc));
@@ -661,15 +662,17 @@ static int sna_video_has_sprites(struct sna *sna)
 	if (sna->mode.num_real_crtc == 0)
 		return 0;
 
+	min = -1;
 	for (i = 0; i < sna->mode.num_real_crtc; i++) {
-		if (!sna_crtc_to_sprite(config->crtc[i], 0)) {
-			DBG(("%s: no sprite found on pipe %d\n", __FUNCTION__, sna_crtc_pipe(config->crtc[i])));
-			return 0;
-		}
+		unsigned count =  sna_crtc_count_sprites(config->crtc[i]);
+		DBG(("%s: %d sprites found on pipe %d\n", __FUNCTION__,
+		     count, sna_crtc_pipe(config->crtc[i])));
+		if (count < min)
+			min = count;
 	}
 
-	DBG(("%s: yes\n", __FUNCTION__));
-	return 1;
+	DBG(("%s: min=%d\n", __FUNCTION__, min));
+	return min;
 }
 
 void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen)

commit 52c9d7ca2467bc273a8ef3c61c1b690ac56caa74
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Jun 20 11:40:04 2016 +0100

    sna/video: Prepare for multiple sprite ports
    
    Allocate an array of XvAdapters, one for each sprite plane on a CRTC.
    
    Based on a patch by Michael Hadley <michaelx.hadley@intel.com>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h
index b278991..39cb725 100644
--- a/src/sna/sna_video.h
+++ b/src/sna/sna_video.h
@@ -72,6 +72,8 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 struct sna_video {
 	struct sna *sna;
 
+	int idx; /* XXX expose struct plane instead? */
+
 	int brightness;
 	int contrast;
 	int saturation;
diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
index 17b272c..a302b5d 100644
--- a/src/sna/sna_video_sprite.c
+++ b/src/sna/sna_video_sprite.c
@@ -91,7 +91,7 @@ static int sna_video_sprite_stop(ddStopVideo_ARGS)
 			continue;
 
 		memset(&s, 0, sizeof(s));
-		s.plane_id = sna_crtc_to_sprite(crtc, 0);
+		s.plane_id = sna_crtc_to_sprite(crtc, video->idx);
 		if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s))
 			xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR,
 				   "failed to disable plane\n");
@@ -224,7 +224,7 @@ sna_video_sprite_show(struct sna *sna,
 	/* XXX handle video spanning multiple CRTC */
 
 	VG_CLEAR(s);
-	s.plane_id = sna_crtc_to_sprite(crtc, 0);
+	s.plane_id = sna_crtc_to_sprite(crtc, video->idx);
 
 #define DRM_I915_SET_SPRITE_COLORKEY 0x2b
 #define LOCAL_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct local_intel_sprite_colorkey)
@@ -422,7 +422,7 @@ off:
 			if (video->bo[pipe]) {
 				struct local_mode_set_plane s;
 				memset(&s, 0, sizeof(s));
-				s.plane_id = sna_crtc_to_sprite(crtc, 0);
+				s.plane_id = sna_crtc_to_sprite(crtc, video->idx);
 				if (drmIoctl(video->sna->kgem.fd, LOCAL_IOCTL_MODE_SETPLANE, &s))
 					xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR,
 						   "failed to disable plane\n");
@@ -461,8 +461,8 @@ off:
 
 		/* if sprite can't handle rotation natively, store it for the copy func */
 		rotation = RR_Rotate_0;
-		if (!sna_crtc_set_sprite_rotation(crtc, 0, crtc->rotation)) {
-			sna_crtc_set_sprite_rotation(crtc, 0, RR_Rotate_0);
+		if (!sna_crtc_set_sprite_rotation(crtc, video->idx, crtc->rotation)) {
+			sna_crtc_set_sprite_rotation(crtc, video->idx, RR_Rotate_0);
 			rotation = crtc->rotation;
 		}
 		sna_video_frame_set_rotation(video, &frame, rotation);
@@ -651,7 +651,7 @@ static int sna_video_sprite_color_key(struct sna *sna)
 	return color_key & ((1 << scrn->depth) - 1);
 }
 
-static bool sna_video_has_sprites(struct sna *sna)
+static int sna_video_has_sprites(struct sna *sna)
 {
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn);
 	int i;
@@ -659,17 +659,17 @@ static bool sna_video_has_sprites(struct sna *sna)
 	DBG(("%s: num_crtc=%d\n", __FUNCTION__, sna->mode.num_real_crtc));
 
 	if (sna->mode.num_real_crtc == 0)
-		return false;
+		return 0;
 
 	for (i = 0; i < sna->mode.num_real_crtc; i++) {
 		if (!sna_crtc_to_sprite(config->crtc[i], 0)) {
 			DBG(("%s: no sprite found on pipe %d\n", __FUNCTION__, sna_crtc_pipe(config->crtc[i])));
-			return false;
+			return 0;
 		}
 	}
 
 	DBG(("%s: yes\n", __FUNCTION__));
-	return true;
+	return 1;
 }
 
 void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen)
@@ -677,16 +677,18 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen)
 	XvAdaptorPtr adaptor;
 	struct sna_video *video;
 	XvPortPtr port;
+	int count, i;
 
-	if (!sna_video_has_sprites(sna))
+	count = sna_video_has_sprites(sna);
+	if (!count)
 		return;
 
 	adaptor = sna_xv_adaptor_alloc(sna);
 	if (!adaptor)
 		return;
 
-	video = calloc(1, sizeof(*video));
-	port = calloc(1, sizeof(*port));
+	video = calloc(count, sizeof(*video));
+	port = calloc(count, sizeof(*port));
 	if (video == NULL || port == NULL) {
 		free(video);
 		free(port);
@@ -731,36 +733,43 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen)
 	adaptor->ddPutImage = sna_video_sprite_put_image;
 	adaptor->ddQueryImageAttributes = sna_video_sprite_query;
 
-	adaptor->nPorts = 1;
+	adaptor->nPorts = count;
 	adaptor->pPorts = port;
 
-	adaptor->base_id = port->id = FakeClientID(0);
-	AddResource(port->id, XvGetRTPort(), port);
-	port->pAdaptor = adaptor;


Reply to: