xf86-video-intel: 7 commits - src/intel_driver.c src/intel_video.c src/legacy/i810 src/sna/kgem.c src/sna/kgem_debug_gen3.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_composite.c src/sna/sna_driver.c src/sna/sna_render.c src/sna/sna_video.c src/sna/sna_video_overlay.c uxa/uxa-glyphs.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Jun 19 13:04:38 PDT 2012


 src/intel_driver.c           |    5 ++++-
 src/intel_video.c            |    6 ++----
 src/legacy/i810/i810_video.c |    6 ++----
 src/sna/kgem.c               |    7 +++++--
 src/sna/kgem.h               |    7 +++++--
 src/sna/kgem_debug_gen3.c    |   16 ++--------------
 src/sna/sna_accel.c          |   35 ++++++++++++++++++++++++-----------
 src/sna/sna_blt.c            |   40 ++++++++++++++++++++++++----------------
 src/sna/sna_composite.c      |   20 +++++++++++---------
 src/sna/sna_driver.c         |   14 +++++++++++---
 src/sna/sna_render.c         |   13 ++++++++-----
 src/sna/sna_video.c          |    1 +
 src/sna/sna_video_overlay.c  |    5 ++++-
 uxa/uxa-glyphs.c             |   11 +++++++----
 14 files changed, 110 insertions(+), 76 deletions(-)

New commits:
commit fda9faee755cb35906ca1179a568332ef2de35a5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 21:01:47 2012 +0100

    uxa: Use the original src for fallback glyph compositing
    
    In 64a4bcb8cefff, I introduced a WHITE source for the purposes of
    accumulating the glyph mask correctly. Unfortunately I neglected to
    restore the original source picture for compositing the glyph mask on
    the destination, resulting in a use-after-free and then corruption.
    
    Reported-by: Maarten Lankhorst <maarten.lankhorst at canonical.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/uxa/uxa-glyphs.c b/uxa/uxa-glyphs.c
index e83464e..0ae0568 100644
--- a/uxa/uxa-glyphs.c
+++ b/uxa/uxa-glyphs.c
@@ -451,12 +451,12 @@ uxa_check_glyphs(CARD8 op,
 {
 	pixman_image_t *image;
 	PixmapPtr scratch;
-	PicturePtr mask, white = NULL;
+	PicturePtr mask, mask_src = NULL, white = NULL;
 	int width = 0, height = 0;
 	int x, y, n;
 	int xDst = list->xOff, yDst = list->yOff;
 	BoxRec extents = { 0, 0, 0, 0 };
-	CARD8 mask_op;
+	CARD8 mask_op = 0;
 
 	if (maskFormat) {
 		pixman_format_code_t format;
@@ -504,10 +504,13 @@ uxa_check_glyphs(CARD8 op,
 		y = -extents.y1;
 
 		color.red = color.green = color.blue = color.alpha = 0xffff;
-		src = white = CreateSolidPicture(0, &color, &error);
+		white = CreateSolidPicture(0, &color, &error);
 
 		mask_op = op;
 		op = PictOpAdd;
+
+		mask_src = src;
+		src = white;
 	} else {
 		mask = dst;
 		x = 0;
@@ -544,7 +547,7 @@ uxa_check_glyphs(CARD8 op,
 	if (maskFormat) {
 		x = extents.x1;
 		y = extents.y1;
-		CompositePicture(mask_op, src, mask, dst,
+		CompositePicture(mask_op, mask_src, mask, dst,
 				 xSrc + x - xDst,
 				 ySrc + y - yDst,
 				 0, 0,
commit 8141e290b1ac7c4d1524bb389a84a8f375df4634
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 20:24:33 2012 +0100

    sna: Explain why we ignore the busy status result during kgem_bo_flush()
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 40730c7..0ab8033 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -275,8 +275,11 @@ static inline void kgem_bo_flush(struct kgem *kgem, struct kgem_bo *bo)
 	if (!bo->needs_flush)
 		return;
 
-	__kgem_flush(kgem, bo);
-
+	/* If the kernel fails to emit the flush, then it will be forced when
+	 * we assume direct access. And as the useual failure is EIO, we do
+	 * not actualy care.
+	 */
+	(void)__kgem_flush(kgem, bo);
 	bo->needs_flush = false;
 }
 
commit eb1d07624e5aeb7b5db7ceb46975091e92185d63
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 16:00:13 2012 +0100

    sna: Ensure extents is initialised if short-circuit use-cpu-bo
    
    As we may attempt to end up using the GPU bo is the CPU bo is busy, we
    need to make sure we have initialised the damage extents first.
    
    Reported-by: Zdenek Kabelac <zkabelac at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 60e1a80..5b0b33d 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2288,6 +2288,7 @@ move_to_gpu:
 	if (!sna_pixmap_move_area_to_gpu(pixmap, &extents,
 					 MOVE_READ | MOVE_WRITE)) {
 		DBG(("%s: failed to move-to-gpu, fallback\n", __FUNCTION__));
+		assert(priv->gpu_bo == NULL);
 		goto use_cpu_bo;
 	}
 
@@ -2330,8 +2331,16 @@ use_cpu_bo:
 			return NULL;
 
 		/* Both CPU and GPU are busy, prefer to use the GPU */
-		if (priv->gpu_bo && kgem_bo_is_busy(priv->gpu_bo))
+		if (priv->gpu_bo && kgem_bo_is_busy(priv->gpu_bo)) {
+			get_drawable_deltas(drawable, pixmap, &dx, &dy);
+
+			extents = *box;
+			extents.x1 += dx;
+			extents.x2 += dx;
+			extents.y1 += dy;
+			extents.y2 += dy;
 			goto move_to_gpu;
+		}
 
 		priv->mapped = false;
 		pixmap->devPrivate.ptr = NULL;
commit 9f216e159bd05ddd269eb8ddf3ca7a407c2901e2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 15:57:31 2012 +0100

    sna: Assert expected return values
    
    Keep the semantic analyser happy by consuming the expected return value
    with an assert.
    
    Reported-by: Zdenek Kabelac <zkabelac at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 13f91c2..60e1a80 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -5200,15 +5200,15 @@ sna_fill_spans__gpu(DrawablePtr drawable, GCPtr gc, int n,
 		}
 
 		if (gc->fillStyle == FillTiled) {
-			sna_poly_fill_rect_tiled_blt(drawable,
-						     data->bo, NULL,
-						     gc, n, rect,
-						     &data->region.extents, 2);
+			(void)sna_poly_fill_rect_tiled_blt(drawable,
+							   data->bo, NULL,
+							   gc, n, rect,
+							   &data->region.extents, 2);
 		} else {
-			sna_poly_fill_rect_stippled_blt(drawable,
-							data->bo, NULL,
-							gc, n, rect,
-							&data->region.extents, 2);
+			(void)sna_poly_fill_rect_stippled_blt(drawable,
+							      data->bo, NULL,
+							      gc, n, rect,
+							      &data->region.extents, 2);
 		}
 		free (rect);
 	}
@@ -6212,8 +6212,12 @@ sna_poly_zero_line_blt(DrawablePtr drawable,
 				}
 				b->x2++;
 				b->y2++;
-				if (oc1 | oc2)
-					box_intersect(b, extents);
+				if (oc1 | oc2) {
+					bool intersects;
+
+					intersects = box_intersect(b, extents);
+					assert(intersects);
+				}
 				if (++b == last_box) {
 					ret = &&rectangle_continue;
 					goto *jump;
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 4a9dbff..7690afe 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -1205,16 +1205,18 @@ blt_put_composite(struct sna *sna,
 			    data, pitch);
 	} else {
 		BoxRec box;
+		bool ok;
 
 		box.x1 = dst_x;
 		box.y1 = dst_y;
 		box.x2 = dst_x + r->width;
 		box.y2 = dst_y + r->height;
 
-		sna_write_boxes(sna, dst,
-				dst_priv->gpu_bo, 0, 0,
-				data, pitch, src_x, src_y,
-				&box, 1);
+		ok = sna_write_boxes(sna, dst,
+				     dst_priv->gpu_bo, 0, 0,
+				     data, pitch, src_x, src_y,
+				     &box, 1);
+		assert(ok);
 	}
 }
 
@@ -1242,12 +1244,15 @@ fastcall static void blt_put_composite_box(struct sna *sna,
 		sna_replace(sna, op->dst.pixmap, &dst_priv->gpu_bo,
 			    data, pitch);
 	} else {
-		sna_write_boxes(sna, op->dst.pixmap,
-				op->dst.bo, op->dst.x, op->dst.y,
-				src->devPrivate.ptr,
-				src->devKind,
-				op->u.blt.sx, op->u.blt.sy,
-				box, 1);
+		bool ok;
+
+		ok = sna_write_boxes(sna, op->dst.pixmap,
+				     op->dst.bo, op->dst.x, op->dst.y,
+				     src->devPrivate.ptr,
+				     src->devKind,
+				     op->u.blt.sx, op->u.blt.sy,
+				     box, 1);
+		assert(ok);
 	}
 }
 
@@ -1276,12 +1281,15 @@ static void blt_put_composite_boxes(struct sna *sna,
 		sna_replace(sna, op->dst.pixmap, &dst_priv->gpu_bo,
 			    data, pitch);
 	} else {
-		sna_write_boxes(sna, op->dst.pixmap,
-				op->dst.bo, op->dst.x, op->dst.y,
-				src->devPrivate.ptr,
-				src->devKind,
-				op->u.blt.sx, op->u.blt.sy,
-				box, n);
+		bool ok;
+
+		ok = sna_write_boxes(sna, op->dst.pixmap,
+				     op->dst.bo, op->dst.x, op->dst.y,
+				     src->devPrivate.ptr,
+				     src->devKind,
+				     op->u.blt.sx, op->u.blt.sy,
+				     box, n);
+		assert(ok);
 	}
 }
 
diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c
index 85453d3..c14af3c 100644
--- a/src/sna/sna_composite.c
+++ b/src/sna/sna_composite.c
@@ -845,17 +845,19 @@ sna_composite_rectangles(CARD8		 op,
 			       pixmap->drawable.width, pixmap->drawable.height);
 		priv->undamaged = false;
 		if (op <= PictOpSrc) {
-			priv->clear = true;
+			bool ok = true;
+
 			priv->clear_color = 0;
 			if (op == PictOpSrc)
-				sna_get_pixel_from_rgba(&priv->clear_color,
-							color->red,
-							color->green,
-							color->blue,
-							color->alpha,
-							dst->format);
-			DBG(("%s: marking clear [%08x]\n",
-			     __FUNCTION__, priv->clear_color));
+				ok = sna_get_pixel_from_rgba(&priv->clear_color,
+							     color->red,
+							     color->green,
+							     color->blue,
+							     color->alpha,
+							     dst->format);
+			priv->clear = ok;
+			DBG(("%s: marking clear [%08x]? %d\n",
+			     __FUNCTION__, priv->clear_color, ok));
 		}
 	}
 	if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index 199fdd5..49f7c5e 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -1886,12 +1886,15 @@ sna_render_composite_redirect_done(struct sna *sna,
 		assert(op->dst.bo != t->real_bo);
 
 		if (t->box.x2 > t->box.x1) {
+			bool ok;
+
 			DBG(("%s: copying temporary to dst\n", __FUNCTION__));
-			sna_blt_copy_boxes(sna, GXcopy,
-					   op->dst.bo, -t->box.x1, -t->box.y1,
-					   t->real_bo, 0, 0,
-					   op->dst.pixmap->drawable.bitsPerPixel,
-					   &t->box, 1);
+			ok = sna_blt_copy_boxes(sna, GXcopy,
+						op->dst.bo, -t->box.x1, -t->box.y1,
+						t->real_bo, 0, 0,
+						op->dst.pixmap->drawable.bitsPerPixel,
+						&t->box, 1);
+			assert(ok);
 		}
 		if (t->damage) {
 			DBG(("%s: combining damage, offset=(%d, %d)\n",
commit 2dc93b2a6c832ce8b972de90d09080e860dcd40f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 15:34:09 2012 +0100

    sna: Check results from syscalls
    
    Reported-by: Zdenek Kabelac <zkabelac at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_driver.c b/src/intel_driver.c
index 3a9fe6f..f1bb10d 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -753,7 +753,10 @@ I830HandleUEvents(int fd, void *closure)
 		return;
 
 	udev_devnum = udev_device_get_devnum(dev);
-	fstat(intel->drmSubFD, &s);
+	if (fstat(intel->drmSubFD, &s)) {
+		udev_device_unref(dev);
+		return;
+	}
 	/*
 	 * Check to make sure this event is directed at our
 	 * device (by comparing dev_t values), then make
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 016ff48..bb1b77d 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -567,7 +567,8 @@ static int gem_param(struct kgem *kgem, int name)
 	VG_CLEAR(gp);
 	gp.param = name;
 	gp.value = &v;
-	drmIoctl(kgem->fd, DRM_IOCTL_I915_GETPARAM, &gp);
+	if (drmIoctl(kgem->fd, DRM_IOCTL_I915_GETPARAM, &gp))
+		return -1;
 
 	VG(VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v)));
 	return v;
@@ -2129,7 +2130,9 @@ void kgem_cleanup_cache(struct kgem *kgem)
 		set_domain.handle = rq->bo->handle;
 		set_domain.read_domains = I915_GEM_DOMAIN_GTT;
 		set_domain.write_domain = I915_GEM_DOMAIN_GTT;
-		drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
+		(void)drmIoctl(kgem->fd,
+			       DRM_IOCTL_I915_GEM_SET_DOMAIN,
+			       &set_domain);
 	}
 
 	kgem_retire(kgem);
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 76ae24e..a02ff76 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -353,7 +353,7 @@ static int sna_open_drm_master(ScrnInfoPtr scrn)
 		/* make the fd nonblocking to handle event loops */
 		flags = fcntl(fd, F_GETFL, 0);
 		if (flags != -1)
-			fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+			(void)fcntl(fd, F_SETFL, flags | O_NONBLOCK);
 
 		dev->fd = fd;
 		dev->open_count = 1;
@@ -392,10 +392,14 @@ static bool has_pageflipping(struct sna *sna)
 	if (sna->flags & SNA_NO_WAIT)
 		return false;
 
+	v = 0;
+
 	VG_CLEAR(gp);
 	gp.param = I915_PARAM_HAS_PAGEFLIPPING;
 	gp.value = &v;
-	drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	if (drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GETPARAM, &gp))
+		return false;
 
 	VG(VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v)));
 	return v > 0;
@@ -625,7 +629,11 @@ sna_handle_uevents(int fd, void *closure)
 		return;
 
 	udev_devnum = udev_device_get_devnum(dev);
-	fstat(sna->kgem.fd, &s);
+	if (fstat(sna->kgem.fd, &s)) {
+		udev_device_unref(dev);
+		return;
+	}
+
 	/*
 	 * Check to make sure this event is directed at our
 	 * device (by comparing dev_t values), then make
diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c
index 612711f..d47f745 100644
--- a/src/sna/sna_video_overlay.c
+++ b/src/sna/sna_video_overlay.c
@@ -148,7 +148,10 @@ static void sna_video_overlay_off(struct sna *sna)
 
 	request.flags = 0;
 
-	drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_OVERLAY_PUT_IMAGE, &request);
+	/* Not much we can do if the hardware dies before we turn it off! */
+	(void)drmIoctl(sna->kgem.fd,
+		       DRM_IOCTL_I915_OVERLAY_PUT_IMAGE,
+		       &request);
 }
 
 static void sna_video_overlay_stop(ScrnInfoPtr scrn,
commit 06634604abf15fdd27dd007fcf81595da994146b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 15:28:43 2012 +0100

    Initialise adaptors to 0 in case xf86XVListGenericAdaptors does not
    
    Reported-by: Zdenek Kabelac <zkabelac at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_video.c b/src/intel_video.c
index 235845f..0e9845d 100644
--- a/src/intel_video.c
+++ b/src/intel_video.c
@@ -329,11 +329,9 @@ void I830InitVideo(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+	XF86VideoAdaptorPtr *adaptors = NULL, *newAdaptors = NULL;
 	XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL;
-	int num_adaptors;
-
-	num_adaptors = xf86XVListGenericAdaptors(scrn, &adaptors);
+	int num_adaptors = xf86XVListGenericAdaptors(scrn, &adaptors);
 	/* Give our adaptor list enough space for the overlay and/or texture video
 	 * adaptors.
 	 */
diff --git a/src/legacy/i810/i810_video.c b/src/legacy/i810/i810_video.c
index 440f9f7..56d04a4 100644
--- a/src/legacy/i810/i810_video.c
+++ b/src/legacy/i810/i810_video.c
@@ -155,10 +155,8 @@ static Atom xvBrightness, xvContrast, xvColorKey;
 void I810InitVideo(ScreenPtr screen)
 {
     ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
-    XF86VideoAdaptorPtr *adaptors;
-    int num_adaptors;
-
-    num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
+    XF86VideoAdaptorPtr *adaptors = NULL;
+    int num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
 
     if (pScrn->bitsPerPixel != 8) {
 	XF86VideoAdaptorPtr newAdaptor;
diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c
index 6999548..08b848b 100644
--- a/src/sna/sna_video.c
+++ b/src/sna/sna_video.c
@@ -538,6 +538,7 @@ void sna_video_init(struct sna *sna, ScreenPtr screen)
 	if (!xf86LoaderCheckSymbol("xf86XVListGenericAdaptors"))
 		return;
 
+	adaptors = NULL;
 	num_adaptors = xf86XVListGenericAdaptors(sna->scrn, &adaptors);
 	newAdaptors = realloc(adaptors,
 			      (num_adaptors + 2) * sizeof(XF86VideoAdaptorPtr));
commit 8bfea58dbc634cadc399d3132030c591e086880c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 19 15:26:18 2012 +0100

    sna: Minor cleanups from sematic analyser in DBG
    
    Reported-by: Zdenek Kabelac <zkabelac at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem_debug_gen3.c b/src/sna/kgem_debug_gen3.c
index 5d6d175..1634225 100644
--- a/src/sna/kgem_debug_gen3.c
+++ b/src/sna/kgem_debug_gen3.c
@@ -205,22 +205,11 @@ static void gen3_update_vertex_elements_offsets(struct kgem *kgem)
 	int i, offset;
 
 	for (i = offset = 0; i < ARRAY_SIZE(state.ve); i++) {
-		int size;
-
 		if (!state.ve[i].valid)
 			continue;
 
-		size = 0;
-		switch (state.ve[i].type) {
-		case T_FLOAT16:
-			size = 4;
-			break;
-		case T_FLOAT32:
-			size = 4;
-			break;
-		}
 		state.ve[i].offset = offset;
-		offset += size * state.ve[i].size;
+		offset += 4 * state.ve[i].size;
 		state.num_ve = i;
 	}
 }
@@ -969,7 +958,7 @@ gen3_decode_load_state_immediate_1(struct kgem *kgem, uint32_t offset)
 					}
 					kgem_debug_print(data, offset, i, "S4: point_width=%i, line_width=%.1f,"
 						  "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s%s%s "
-						  "%s%s\n",
+						  "%s%s%s\n",
 						  (data[i]>>23)&0x1ff,
 						  ((data[i]>>19)&0xf) / 2.0,
 						  data[i]&(0xf<<15)?" flatshade=":"",
@@ -1342,7 +1331,6 @@ gen3_decode_3d_1d(struct kgem *kgem, uint32_t offset)
 					  dword&(1<<5)?" normalized coords,":"",
 					  (dword>>1)&0xf,
 					  dword&(1<<0)?" deinterlacer,":"");
-				dword = data[i];
 				kgem_debug_print(data, offset, i++, "sampler %d SS4: border color\n",
 					  sampler);
 			}


More information about the xorg-commit mailing list