xf86-video-intel: 5 commits - src/i830_accel.c src/i830_batchbuffer.c src/i830_dri.c src/i830_memory.c src/i830_uxa.c src/i965_hwmc.c uxa/uxa-accel.c uxa/uxa-unaccel.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Dec 2 06:30:54 PST 2009


 src/i830_accel.c       |    2 --
 src/i830_batchbuffer.c |    7 ++++---
 src/i830_dri.c         |    1 -
 src/i830_memory.c      |    3 +--
 src/i830_uxa.c         |   35 ++++++++++++++++++-----------------
 src/i965_hwmc.c        |    1 -
 uxa/uxa-accel.c        |   18 ++++++++----------
 uxa/uxa-unaccel.c      |   22 +++++++++-------------
 8 files changed, 40 insertions(+), 49 deletions(-)

New commits:
commit ad68881b670aabf8dbfd3b954e8796f91260579d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 2 14:14:39 2009 +0000

    uxa_check_composite: Minor whitespace.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/uxa/uxa-unaccel.c b/uxa/uxa-unaccel.c
index 90d4950..15be821 100644
--- a/uxa/uxa-unaccel.c
+++ b/uxa/uxa-unaccel.c
@@ -353,11 +353,10 @@ uxa_check_composite(CARD8 op,
 		    PicturePtr pSrc,
 		    PicturePtr pMask,
 		    PicturePtr pDst,
-		    INT16 xSrc,
-		    INT16 ySrc,
-		    INT16 xMask,
-		    INT16 yMask,
-		    INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+		    INT16 xSrc, INT16 ySrc,
+		    INT16 xMask, INT16 yMask,
+		    INT16 xDst, INT16 yDst,
+		    CARD16 width, CARD16 height)
 {
 	ScreenPtr screen = pDst->pDrawable->pScreen;
 
@@ -369,14 +368,11 @@ uxa_check_composite(CARD8 op,
 			if (!pMask || pMask->pDrawable == NULL ||
 			    uxa_prepare_access(pMask->pDrawable, UXA_ACCESS_RO))
 			{
-				fbComposite(op,
-					    pSrc,
-					    pMask,
-					    pDst,
-					    xSrc,
-					    ySrc,
-					    xMask,
-					    yMask, xDst, yDst, width, height);
+				fbComposite(op, pSrc, pMask, pDst,
+					    xSrc, ySrc,
+					    xMask, yMask,
+					    xDst, yDst,
+					    width, height);
 				if (pMask && pMask->pDrawable != NULL)
 					uxa_finish_access(pMask->pDrawable);
 			}
commit 49d2ccab2a82083110fe796636f3f91ba8c31237
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 2 14:13:43 2009 +0000

    uxa_prepare_access() don't force a flush.
    
    Only the kernel knows whether the mapping requires a flush, so do not
    preempt it.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index 2227c58..6d056c8 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -573,7 +573,7 @@ static Bool i830_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 
 	if (!list_is_empty(&priv->batch) &&
 	    (access == UXA_ACCESS_RW || priv->batch_write_domain))
-		intel_batch_flush(scrn, TRUE);
+		intel_batch_flush(scrn, FALSE);
 
 	/* No VT sema or GEM?  No GTT mapping. */
 	if (!scrn->vtSema || bo->size > intel->max_gtt_map_size) {
commit b68d3646f1fdfe012c16741958c7a62136a9b5aa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 2 14:12:19 2009 +0000

    Review use of errno after libdrm call
    
    Since drm may not actually set the appropriate errno after a failure, we
    must use the return code instead when determining the cause of failure.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/i830_accel.c b/src/i830_accel.c
index 2622837..4302eca 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -40,8 +40,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "config.h"
 #endif
 
-#include <errno.h>
-
 #include "xf86.h"
 #include "i830.h"
 #include "i810_reg.h"
diff --git a/src/i830_batchbuffer.c b/src/i830_batchbuffer.c
index 0c755d6..e1537ae 100644
--- a/src/i830_batchbuffer.c
+++ b/src/i830_batchbuffer.c
@@ -32,7 +32,6 @@
 
 #include <assert.h>
 #include <stdlib.h>
-#include <errno.h>
 
 #include "xf86.h"
 #include "i830.h"
@@ -44,6 +43,7 @@
 static void intel_next_batch(ScrnInfoPtr scrn)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
+	int ret;
 
 	/* The 865 has issues with larger-than-page-sized batch buffers. */
 	if (IS_I865G(intel))
@@ -53,8 +53,9 @@ static void intel_next_batch(ScrnInfoPtr scrn)
 		intel->batch_bo =
 		    dri_bo_alloc(intel->bufmgr, "batch", 4096 * 4, 4096);
 
-	if (dri_bo_map(intel->batch_bo, 1) != 0)
-		FatalError("Failed to map batchbuffer: %s\n", strerror(errno));
+	ret = dri_bo_map(intel->batch_bo, 1);
+	if (ret != 0)
+		FatalError("Failed to map batchbuffer: %s\n", strerror(-ret));
 
 	intel->batch_used = 0;
 	intel->batch_ptr = intel->batch_bo->virtual;
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 440748b..a9eed5b 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -42,7 +42,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
 
diff --git a/src/i830_memory.c b/src/i830_memory.c
index ea4922a..7abea72 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -77,7 +77,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <assert.h>
 #include <inttypes.h>
 #include <string.h>
-#include <errno.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
@@ -366,7 +365,7 @@ i830_memory *i830_allocate_memory(ScrnInfoPtr scrn, const char *name,
 	if (ret != 0 || tiling_mode != requested_tiling_mode) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			   "Failed to set tiling on %s: %s\n", mem->name,
-			   ret == 0 ? "rejected by kernel" : strerror(errno));
+			   ret == 0 ? "rejected by kernel" : strerror(-ret));
 	}
 	mem->tiling_mode = tiling_mode;
 
diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index 875833b..2227c58 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -569,6 +569,7 @@ static Bool i830_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	struct intel_pixmap *priv = i830_get_pixmap_intel(pixmap);
 	dri_bo *bo = priv->bo;
+	int ret;
 
 	if (!list_is_empty(&priv->batch) &&
 	    (access == UXA_ACCESS_RW || priv->batch_write_domain))
@@ -576,19 +577,21 @@ static Bool i830_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 
 	/* No VT sema or GEM?  No GTT mapping. */
 	if (!scrn->vtSema || bo->size > intel->max_gtt_map_size) {
-		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0) {
+		ret = dri_bo_map(bo, access == UXA_ACCESS_RW);
+		if (ret != 0) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "%s: bo map failed: %d [%s]\n",
+				   "%s: bo map failed: %s\n",
 				   __FUNCTION__,
-				   errno, strerror(errno));
+				   strerror(-ret));
 			return FALSE;
 		}
 	} else {
-		if (drm_intel_gem_bo_map_gtt(bo)) {
+		ret = drm_intel_gem_bo_map_gtt(bo);
+		if (ret != 0) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "%s: gtt bo map failed: %d [%s]\n",
+				   "%s: gtt bo map failed: %s\n",
 				   __FUNCTION__,
-				   errno, strerror(errno));
+				   strerror(-ret));
 			return FALSE;
 		}
 	}
diff --git a/src/i965_hwmc.c b/src/i965_hwmc.c
index 3fe4f41..5b24f3b 100644
--- a/src/i965_hwmc.c
+++ b/src/i965_hwmc.c
@@ -31,7 +31,6 @@
 #include <X11/extensions/Xv.h>
 #include <X11/extensions/XvMC.h>
 #include <fourcc.h>
-#include <errno.h>
 
 #include "i830.h"
 #include "i830_dri.h"
commit 0ff4d42a42b9e537b083343ee7dcc41cb41ae7cf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 2 12:12:07 2009 +0000

    uxa: Review uxa_prepare_access() to remove potential nesting
    
    Around a call to uxa_put_image() it is possible to mix both accelerated
    and fallback paths, with the fallback code making the presumed
    optimisation of only trying to call uxa_prepare_access() once. This
    fails if the accelerated path also uses prepare/finish access on the
    same drawable and then later fallback to the fallback path. This can
    happen currently if an error is reported whilst attempting to accelerate
    PutImage.
    
      #0  memcpy () at ../sysdeps/x86_64/memcpy.S:162
      #1  0x00007ffff43ce4bd in fbBlt (srcLine=<value optimized out>, srcStride=40, srcX=<value optimized out>, dstLine=0xffffffffffffffff, dstStride=64, dstX=0, width=<value optimized out>, height=8, alu=3, pm=4294967295, bpp=8, reverse=0, upsidedown=0) at fbblt.c:93
      #2  0x00007ffff43ce740 in fbBltStip (src=0xffffffffffffffff, srcStride=156555204, srcX=34, dst=0xfffffffc, dstStride=64, dstX=40, width=304, height=8, alu=3, pm=4294967295, bpp=8) at fbblt.c:944
      #3  0x00007ffff4c32c53 in uxa_do_put_image (pDrawable=0x246aa410, pGC=0x2c0a4f0, depth=8, x=0, y=0, w=38, h=8, leftPad=0, format=2, bits=0x954d7c4 "") at uxa-accel.c:196 #4  uxa_do_shm_put_image (pDrawable=0x246aa410, pGC=0x2c0a4f0, depth=8, x=0, y=0, w=38, h=8, leftPad=0, format=2, bits=0x954d7c4 "") at uxa-accel.c:223
      #5  uxa_put_image (pDrawable=0x246aa410, pGC=0x2c0a4f0, depth=8, x=0, y=0, w=38, h=8, leftPad=0, format=2, bits=0x954d7c4 "") at uxa-accel.c:289
      #6  0x00000000004d574f in damagePutImage (pDrawable=0x246aa410, pGC=0x2c0a4f0, depth=8, x=0, y=0, w=38, h=8, leftPad=0, format=2, pImage=0x954d7c4 "") at damage.c:905
      #7  0x00000000004287db in ProcPutImage (client=0x47ca72d0) at dispatch.c:2073
      #8  0x000000000042bd94 in Dispatch () at dispatch.c:445
      #9  0x000000000042513a in main (argc=4, argv=0x7fffffffe2a8, envp=<value optimized out>) at main.c:285
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c
index f0bf92f..80be91f 100644
--- a/uxa/uxa-accel.c
+++ b/uxa/uxa-accel.c
@@ -128,7 +128,6 @@ uxa_do_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 	int nbox;
 	int xoff, yoff;
 	int bpp = pDrawable->bitsPerPixel;
-	Bool access_prepared = FALSE;
 
 	/* Don't bother with under 8bpp, XYPixmaps. */
 	if (format != ZPixmap || bpp < 8)
@@ -183,12 +182,8 @@ uxa_do_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 			int dstBpp;
 			int dstXoff, dstYoff;
 
-			if (!access_prepared) {
-				if (!uxa_prepare_access
-				    (pDrawable, UXA_ACCESS_RW))
-					return FALSE;
-				access_prepared = TRUE;
-			}
+			if (!uxa_prepare_access(pDrawable, UXA_ACCESS_RW))
+				return FALSE;
 
 			fbGetStipDrawable(pDrawable, dst, dst_stride, dstBpp,
 					  dstXoff, dstYoff);
@@ -200,11 +195,11 @@ uxa_do_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 				  dst + (y1 + dstYoff) * dst_stride, dst_stride,
 				  (x1 + dstXoff) * dstBpp, (x2 - x1) * dstBpp,
 				  y2 - y1, GXcopy, FB_ALLONES, dstBpp);
+
+			uxa_finish_access(pDrawable);
 		}
 	}
 
-	if (access_prepared)
-		uxa_finish_access(pDrawable);
 
 	return TRUE;
 }
@@ -236,8 +231,11 @@ uxa_do_shm_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth,
 		if (!pPixmap)
 			return FALSE;
 
-		if (!uxa_prepare_access(pDrawable, UXA_ACCESS_RW))
+		if (!uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
+			FreeScratchPixmapHeader(pPixmap);
 			return FALSE;
+		}
+
 		fbCopyArea((DrawablePtr) pPixmap, pDrawable, pGC, sx, sy, sw,
 			   sh, dx, dy);
 		uxa_finish_access(pDrawable);
commit 6be26cae8379f973d9ca27e0d5371d16618e4f7b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 1 16:13:25 2009 +0000

    i830: Simplify prepare_access / finish_access
    
    Reduce the 3 conditions into the 2 distinct cases. This has the
    secondary benefit of also distinguishing between the reported errors.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index 4d7ecb7..875833b 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -38,6 +38,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "i915_drm.h"
 #include <string.h>
 #include <sys/mman.h>
+#include <errno.h>
 
 const int I830CopyROP[16] = {
 	ROP_0,			/* GXclear */
@@ -574,22 +575,24 @@ static Bool i830_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 		intel_batch_flush(scrn, TRUE);
 
 	/* No VT sema or GEM?  No GTT mapping. */
-	if (!scrn->vtSema) {
-		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0)
-			return FALSE;
-	} else if (bo->size < intel->max_gtt_map_size) {
-		if (drm_intel_gem_bo_map_gtt(bo)) {
+	if (!scrn->vtSema || bo->size > intel->max_gtt_map_size) {
+		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "%s: bo map failed\n", __FUNCTION__);
+				   "%s: bo map failed: %d [%s]\n",
+				   __FUNCTION__,
+				   errno, strerror(errno));
 			return FALSE;
 		}
 	} else {
-		if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0) {
+		if (drm_intel_gem_bo_map_gtt(bo)) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "%s: bo map failed\n", __FUNCTION__);
+				   "%s: gtt bo map failed: %d [%s]\n",
+				   __FUNCTION__,
+				   errno, strerror(errno));
 			return FALSE;
 		}
 	}
+
 	pixmap->devPrivate.ptr = bo->virtual;
 
 	return TRUE;
@@ -607,16 +610,11 @@ static void i830_uxa_finish_access(PixmapPtr pixmap)
 		if (bo == intel->front_buffer->bo)
 			intel->need_flush = TRUE;
 
-		if (!scrn->vtSema) {
+		if (!scrn->vtSema || bo->size > intel->max_gtt_map_size)
 			dri_bo_unmap(bo);
-			pixmap->devPrivate.ptr = NULL;
-			return;
-		}
-
-		if (bo->size < intel->max_gtt_map_size)
-			drm_intel_gem_bo_unmap_gtt(bo);
 		else
-			dri_bo_unmap(bo);
+			drm_intel_gem_bo_unmap_gtt(bo);
+
 		pixmap->devPrivate.ptr = NULL;
 	}
 }


More information about the xorg-commit mailing list