From 0ff4d42a42b9e537b083343ee7dcc41cb41ae7cf Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 2 Dec 2009 12:12:07 +0000 Subject: [PATCH] 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=, srcStride=40, srcX=, dstLine=0xffffffffffffffff, dstStride=64, dstX=0, width=, 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=) at main.c:285 Signed-off-by: Chris Wilson --- uxa/uxa-accel.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c index f0bf92f1..80be91f6 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);