xf86-video-intel: 2 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/gen8_render.c src/sna/gen9_render.c src/sna/sna_display.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Jun 21 20:23:01 UTC 2016


 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_display.c |  149 ++++++++------------------------------------------
 9 files changed, 50 insertions(+), 131 deletions(-)

New commits:
commit c28e62f94f15c9f5c4fb0744588f08ae18e4a9b5
Author: Chris Wilson <chris at 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 at 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 at 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 at freedesktop.org>
    Signed-off-by: Chris Wilson <chris at 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;
 }
 


More information about the xorg-commit mailing list