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

xserver-xorg-video-nouveau: Changes to 'debian-experimental'



 ChangeLog                             |  147 ++++++++++++++++++++++++++++++++++
 configure.ac                          |    2 
 debian/changelog                      |    5 -
 debian/patches/02-clamp-to-edge.patch |   65 ---------------
 debian/patches/series                 |    1 
 src/nouveau_dri2.c                    |   57 +++++++++----
 src/nouveau_exa.c                     |   15 ++-
 src/nv40_exa.c                        |    6 -
 src/nv50_exa.c                        |    6 -
 src/nv_driver.c                       |    1 
 src/nv_include.h                      |    3 
 src/nv_shadow.c                       |    7 -
 src/nv_type.h                         |    2 
 src/nvc0_exa.c                        |   40 +++++----
 14 files changed, 232 insertions(+), 125 deletions(-)

New commits:
commit 919949abbe048323d0951e752bba9937d7f7aac2
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Thu Oct 25 11:09:23 2012 +0200

    new upstream release

diff --git a/ChangeLog b/ChangeLog
index be9cb72..0b254e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,150 @@
+commit 8c3e1623b0be15f8cc590d893bfd19be87bd079a
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Wed Oct 24 11:19:04 2012 +0200
+
+    bump version to 1.0.3
+
+commit 6644a3a724a11150eba0c0082c8d4fe167b1755e
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Tue Oct 23 20:17:29 2012 +0200
+
+    exa: remove exaMarkSync from download/upload screen
+    
+    They're noops on nouveau since sync markers are unused and
+    download/upload are always synchronous anyway from exa's POV.
+    
+    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+
+commit 2a757b7dffa85c30879653a1e52e33b8f4fa8806
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Tue Oct 23 17:04:37 2012 +0200
+
+    exa: fix comparison in download_from_screen
+    
+    Presumably a copy/paste error from upload_to_screen.
+    
+    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+
+commit 72230cd5a7846f7a26f929262a745dc0bdc34a3d
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Tue Oct 23 10:37:27 2012 +0200
+
+    exa: fix up download_from/upload_to screen
+    
+    Add a missing return TRUE to download_from_screen.
+    Add a missing exaMarkSync to memcpy in upload_to_screen.
+    Add a really loud warning to both if memcpy to/from tiled is done.
+    
+    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+
+commit 1d7890ecb8b3188177ab85608ea232812672d923
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Tue Oct 23 09:53:39 2012 +0200
+
+    remove unused members from nv_type.h
+
+commit 0b2a548316b0ce88ba19d5e05fdca205fc139962
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Mon Oct 22 13:12:06 2012 +0200
+
+    nvc0/exa: make solid fill actually work
+    
+    Some investigation showed that the code for accelerating solid fill
+    didn't actually work because NVC0EXACheckTexture would fail.
+    
+    Making the check the same as in NV50EXACheckTexture fixes this, and
+    seems to get acceleration for solid fills working right.
+    
+    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+
+commit b4231dd715a8a7f86b04519b5f4e8a8d93c2f561
+Author: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
+Date:   Tue Oct 9 09:06:59 2012 +0200
+
+    dri2: Fix potential race and crash for swap at next vblank.
+    
+    This fixes a potential race + crash that wasn't properly
+    handled by commit 248de8cdbd6d0bc062633b49896fa4791148cd3b
+    and happened at least on one users machine.
+    
+    That commit wrongly assumed no special action would be needed
+    for swaps at next vblank while triple-buffering is enabled on
+    XOrg server 1.12 or later.
+    
+    Closer inspection of the x-server main dispatch loop shows
+    it is possible that the client manages to get the server
+    to dispatch a new DRI2GetBuffersWithFormat() call before
+    the server calls the vblank event handler and executes
+    the nouveau_dri2_finish_swap() routine. Such a race would
+    cause a crash, as described in above commit.
+    
+    This commit handles the "swap at next vblank" case by
+    calling nouveau_dri2_finish_swap() immediately without
+    the roundtrip (queue vblank_event -> kernel -> deliver event
+    -> x-server processes event -> nouveau vblank event handler),
+    before control gets returned to the client.
+    
+    This avoids the race while retaining triple-buffering. As
+    a bonus, time-critical swaps at next vblank get processed
+    without roundtrip delay, increasing the chance of not
+    skipping a frame due to vblank miss while sync to vblank is
+    on.
+    
+    Thanks to Anssi for reporting this problem on the nouveau
+    mailing list at 12th July 2012 and for testing this patch.
+    
+    Reported-by: Anssi Hannula <anssi.hannula@iki.fi>
+    Tested-by: Anssi Hannula <anssi.hannula@iki.fi>
+    Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
+
+commit 01c9a9cff7d6232ca6eafa59dd60833a0d9cdc5b
+Author: Ben Skeggs <bskeggs@redhat.com>
+Date:   Thu Oct 18 18:38:21 2012 +1000
+
+    shadowfb: fix segfault due to reading outside of shadow buffer
+    
+    Probably caused by the new libdrm port, the new libdrm sets the bo
+    size field to the *allocated* size and not the *requested* size,
+    making the max_height calculation here invalid.
+    
+    Switched to using virtualX/virtualY as the bounds, which should
+    hopefully do the right thing..
+    
+    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+
+commit 297fd0d0755bda698be1d0b30cc60a41d7673c0b
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Tue Oct 16 16:15:16 2012 +1000
+
+    nouveau/dri2: fix pixmap/window offset calcs.
+    
+    This should fix prime rendering under kwin, and not break it under the
+    others.
+    
+    Signed-off-by: Dave Airlie <airlied@redhat.com>
+
+commit 5c9379b14cdabc81fd5d4c916dcd93dc77c4f683
+Author: Sebastian Keller <sebastian-keller@gmx.de>
+Date:   Tue Sep 25 11:35:35 2012 +0200
+
+    exa: use CLAMP_TO_EDGE for RepeatPad
+    
+    This fixes border rendering in some gtk3 themes.
+    https://bugs.freedesktop.org/show_bug.cgi?id=55310
+    
+    v2 (Ben Skeggs): implement same fix for fermi/kepler too
+    
+    Signed-off-by: Sebastian Keller <sebastian-keller@gmx.de>
+    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+
+commit 302b5da84b4890c067f5f7e8b0f4e689909bbb51
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Sep 25 10:44:32 2012 -0400
+
+    Remove mibstore.h
+    
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
 commit 20f3830ddf868c0d1a46c18fa381585c076bfb8d
 Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
 Date:   Wed Sep 12 13:42:43 2012 +0200
diff --git a/debian/changelog b/debian/changelog
index b1de9c4..049ee5b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-xserver-xorg-video-nouveau (1:1.0.2-1) UNRELEASED; urgency=low
+xserver-xorg-video-nouveau (1:1.0.3-1) UNRELEASED; urgency=low
 
   [ Maarten Lankhorst ]
   * New upstream release.
@@ -7,9 +7,6 @@ xserver-xorg-video-nouveau (1:1.0.2-1) UNRELEASED; urgency=low
   [ Timo Aaltonen ]
   * watch: Use the .gz tarball, and update the url.
 
-  [ Maarten Lankhorst ]
-  * add upstream 02-clamp-to-edge.patch to fix a exa rendering error
-
  -- Maarten Lankhorst <maarten.lankhorst@canonical.com>  Mon, 16 Jul 2012 15:22:19 +0200
 
 xserver-xorg-video-nouveau (1:1.0.1-3) unstable; urgency=low
diff --git a/debian/patches/02-clamp-to-edge.patch b/debian/patches/02-clamp-to-edge.patch
deleted file mode 100644
index cdcf5d5..0000000
--- a/debian/patches/02-clamp-to-edge.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-commit 5c9379b14cdabc81fd5d4c916dcd93dc77c4f683
-Author: Sebastian Keller <sebastian-keller@gmx.de>
-Date:   Tue Sep 25 11:35:35 2012 +0200
-
-    exa: use CLAMP_TO_EDGE for RepeatPad
-    
-    This fixes border rendering in some gtk3 themes.
-    https://bugs.freedesktop.org/show_bug.cgi?id=55310
-    
-    v2 (Ben Skeggs): implement same fix for fermi/kepler too
-    
-    Signed-off-by: Sebastian Keller <sebastian-keller@gmx.de>
-    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-
-diff --git a/src/nv40_exa.c b/src/nv40_exa.c
-index 87ed5b2..c9e99e0 100644
---- a/src/nv40_exa.c
-+++ b/src/nv40_exa.c
-@@ -260,9 +260,9 @@ NV40EXAPictTexture(NVPtr pNv, PixmapPtr pPix, PicturePtr pPict, int unit)
- 	if (pPict->repeat) {
- 		switch(pPict->repeatType) {
- 		case RepeatPad:
--			PUSH_DATA (push, NV30_3D_TEX_WRAP_S_CLAMP | 
--					 NV30_3D_TEX_WRAP_T_CLAMP |
--					 NV30_3D_TEX_WRAP_R_CLAMP);
-+			PUSH_DATA (push, NV30_3D_TEX_WRAP_S_CLAMP_TO_EDGE |
-+					 NV30_3D_TEX_WRAP_T_CLAMP_TO_EDGE |
-+					 NV30_3D_TEX_WRAP_R_CLAMP_TO_EDGE);
- 			break;
- 		case RepeatReflect:
- 			PUSH_DATA (push, NV30_3D_TEX_WRAP_S_MIRRORED_REPEAT |
-diff --git a/src/nv50_exa.c b/src/nv50_exa.c
-index d6f38eb..e70d92d 100644
---- a/src/nv50_exa.c
-+++ b/src/nv50_exa.c
-@@ -665,9 +665,9 @@ NV50EXAPictTexture(NVPtr pNv, PixmapPtr ppix, PicturePtr ppict, unsigned unit)
- 	if (ppict->repeat) {
- 		switch (ppict->repeatType) {
- 		case RepeatPad:
--			PUSH_DATA (push, NV50TSC_1_0_WRAPS_CLAMP |
--				 NV50TSC_1_0_WRAPT_CLAMP |
--				 NV50TSC_1_0_WRAPR_CLAMP | 0x00024000);
-+			PUSH_DATA (push, NV50TSC_1_0_WRAPS_CLAMP_TO_EDGE |
-+				 NV50TSC_1_0_WRAPT_CLAMP_TO_EDGE |
-+				 NV50TSC_1_0_WRAPR_CLAMP_TO_EDGE | 0x00024000);
- 			break;
- 		case RepeatReflect:
- 			PUSH_DATA (push, NV50TSC_1_0_WRAPS_MIRROR_REPEAT |
-diff --git a/src/nvc0_exa.c b/src/nvc0_exa.c
-index dc8ba0b..7bd7294 100644
---- a/src/nvc0_exa.c
-+++ b/src/nvc0_exa.c
-@@ -659,9 +659,9 @@ NVC0EXAPictTexture(NVPtr pNv, PixmapPtr ppix, PicturePtr ppict, unsigned unit)
- 		switch (ppict->repeatType) {
- 		case RepeatPad:
- 			PUSH_DATA (push, 0x00024000 |
--					 NV50TSC_1_0_WRAPS_CLAMP |
--					 NV50TSC_1_0_WRAPT_CLAMP |
--					 NV50TSC_1_0_WRAPR_CLAMP);
-+					 NV50TSC_1_0_WRAPS_CLAMP_TO_EDGE |
-+					 NV50TSC_1_0_WRAPT_CLAMP_TO_EDGE |
-+					 NV50TSC_1_0_WRAPR_CLAMP_TO_EDGE);
- 			break;
- 		case RepeatReflect:
- 			PUSH_DATA (push, 0x00024000 |
diff --git a/debian/patches/series b/debian/patches/series
index feaa065..d6892cf 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1 @@
 01-set-NV_DRIVER_DATE-from-ChangeLog.diff
-02-clamp-to-edge.patch

commit 8c3e1623b0be15f8cc590d893bfd19be87bd079a
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Wed Oct 24 11:19:04 2012 +0200

    bump version to 1.0.3

diff --git a/configure.ac b/configure.ac
index 4861608..e2fdb20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-nouveau],
-        [1.0.2],
+        [1.0.3],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-nouveau])
 

commit 6644a3a724a11150eba0c0082c8d4fe167b1755e
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Tue Oct 23 20:17:29 2012 +0200

    exa: remove exaMarkSync from download/upload screen
    
    They're noops on nouveau since sync markers are unused and
    download/upload are always synchronous anyway from exa's POV.
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

diff --git a/src/nouveau_exa.c b/src/nouveau_exa.c
index b0d63a1..8191aeb 100644
--- a/src/nouveau_exa.c
+++ b/src/nouveau_exa.c
@@ -321,20 +321,17 @@ nouveau_exa_upload_to_screen(PixmapPtr pdpix, int x, int y, int w, int h,
 		if (pNv->Architecture < NV_ARCH_50) {
 			if (NV04EXAUploadIFC(pScrn, src, src_pitch, pdpix,
 					     x, y, w, h, cpp)) {
-				exaMarkSync(pdpix->drawable.pScreen);
 				return TRUE;
 			}
 		} else
 		if (pNv->Architecture < NV_ARCH_C0) {
 			if (NV50EXAUploadSIFC(src, src_pitch, pdpix,
 					      x, y, w, h, cpp)) {
-				exaMarkSync(pdpix->drawable.pScreen);
 				return TRUE;
 			}
 		} else {
 			if (NVC0EXAUploadSIFC(src, src_pitch, pdpix,
 					      x, y, w, h, cpp)) {
-				exaMarkSync(pdpix->drawable.pScreen);
 				return TRUE;
 			}
 		}
@@ -372,7 +369,6 @@ nouveau_exa_upload_to_screen(PixmapPtr pdpix, int x, int y, int w, int h,
 		y += lines;
 	}
 
-	exaMarkSync(pdpix->drawable.pScreen);
 	return TRUE;
 
 	/* fallback to memcpy-based transfer */
@@ -386,8 +382,6 @@ memcpy:
 		return FALSE;
 	dst = (char *)bo->map + (y * dst_pitch) + (x * cpp);
 	ret = NVAccelMemcpyRect(dst, src, h, dst_pitch, src_pitch, w*cpp);
-	if (ret)
-		exaMarkSync(pdpix->drawable.pScreen);
 	return ret;
 }
 

commit 2a757b7dffa85c30879653a1e52e33b8f4fa8806
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Tue Oct 23 17:04:37 2012 +0200

    exa: fix comparison in download_from_screen
    
    Presumably a copy/paste error from upload_to_screen.
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

diff --git a/src/nouveau_exa.c b/src/nouveau_exa.c
index 136b68f..b0d63a1 100644
--- a/src/nouveau_exa.c
+++ b/src/nouveau_exa.c
@@ -269,7 +269,7 @@ nouveau_exa_download_from_screen(PixmapPtr pspix, int x, int y, int w, int h,
 			goto memcpy;
 
 		nouveau_bo_wait(tmp, NOUVEAU_BO_RD, pNv->client);
-		if (src_pitch == tmp_pitch) {
+		if (dst_pitch == tmp_pitch) {
 			memcpy(dst, tmp->map + tmp_offset, dst_pitch * lines);
 			dst += dst_pitch * lines;
 		} else {

commit 72230cd5a7846f7a26f929262a745dc0bdc34a3d
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Tue Oct 23 10:37:27 2012 +0200

    exa: fix up download_from/upload_to screen
    
    Add a missing return TRUE to download_from_screen.
    Add a missing exaMarkSync to memcpy in upload_to_screen.
    Add a really loud warning to both if memcpy to/from tiled is done.
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

diff --git a/src/nouveau_exa.c b/src/nouveau_exa.c
index 13d7e1f..136b68f 100644
--- a/src/nouveau_exa.c
+++ b/src/nouveau_exa.c
@@ -285,9 +285,14 @@ nouveau_exa_download_from_screen(PixmapPtr pspix, int x, int y, int w, int h,
 		h -= lines;
 		y += lines;
 	}
+	return TRUE;
 
 memcpy:
 	bo = nouveau_pixmap_bo(pspix);
+	if (nv50_style_tiled_pixmap(pspix))
+		ErrorF("%s:%d - falling back to memcpy ignores tiling\n",
+		       __func__, __LINE__);
+
 	if (nouveau_bo_map(bo, NOUVEAU_BO_RD, pNv->client))
 		return FALSE;
 	src = (char *)bo->map + (y * src_pitch) + (x * cpp);
@@ -373,10 +378,16 @@ nouveau_exa_upload_to_screen(PixmapPtr pdpix, int x, int y, int w, int h,
 	/* fallback to memcpy-based transfer */
 memcpy:
 	bo = nouveau_pixmap_bo(pdpix);
+	if (nv50_style_tiled_pixmap(pdpix))
+		ErrorF("%s:%d - falling back to memcpy ignores tiling\n",
+		       __func__, __LINE__);
+
 	if (nouveau_bo_map(bo, NOUVEAU_BO_WR, pNv->client))
 		return FALSE;
 	dst = (char *)bo->map + (y * dst_pitch) + (x * cpp);
 	ret = NVAccelMemcpyRect(dst, src, h, dst_pitch, src_pitch, w*cpp);
+	if (ret)
+		exaMarkSync(pdpix->drawable.pScreen);
 	return ret;
 }
 

commit 1d7890ecb8b3188177ab85608ea232812672d923
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Tue Oct 23 09:53:39 2012 +0200

    remove unused members from nv_type.h

diff --git a/src/nv_type.h b/src/nv_type.h
index 5a99dbd..d882e7c 100644
--- a/src/nv_type.h
+++ b/src/nv_type.h
@@ -167,8 +167,6 @@ typedef struct _NVPortPrivRec {
 
 struct nouveau_pixmap {
 	struct nouveau_bo *bo;
-	void *linear;
-	unsigned size;
 	Bool shared;
 };
 

commit 0b2a548316b0ce88ba19d5e05fdca205fc139962
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Mon Oct 22 13:12:06 2012 +0200

    nvc0/exa: make solid fill actually work
    
    Some investigation showed that the code for accelerating solid fill
    didn't actually work because NVC0EXACheckTexture would fail.
    
    Making the check the same as in NV50EXACheckTexture fixes this, and
    seems to get acceleration for solid fills working right.
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

diff --git a/src/nvc0_exa.c b/src/nvc0_exa.c
index 7bd7294..8717eb9 100644
--- a/src/nvc0_exa.c
+++ b/src/nvc0_exa.c
@@ -459,14 +459,19 @@ NVC0EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)
 static Bool
 NVC0EXACheckTexture(PicturePtr ppict, PicturePtr pdpict, int op)
 {
-	if (!ppict->pDrawable)
-		NOUVEAU_FALLBACK("Solid and gradient pictures unsupported.\n");
-
-	if (ppict->pDrawable->width > 8192 ||
-	    ppict->pDrawable->height > 8192)
-		NOUVEAU_FALLBACK("texture dimensions exceeded %dx%d\n",
-				 ppict->pDrawable->width,
-				 ppict->pDrawable->height);
+	if (ppict->pDrawable) {
+		if (ppict->pDrawable->width > 8192 ||
+		    ppict->pDrawable->height > 8192)
+			NOUVEAU_FALLBACK("texture too large\n");
+	} else {
+		switch (ppict->pSourcePict->type) {
+		case SourcePictTypeSolidFill:
+			break;
+		default:
+			NOUVEAU_FALLBACK("pict %d\n", ppict->pSourcePict->type);
+			break;
+		}
+	}
 
 	switch (ppict->format) {
 	case PICT_a8r8g8b8:
@@ -826,10 +831,8 @@ NVC0EXAPrepareComposite(int op,
 			PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict,
 			PixmapPtr pspix, PixmapPtr pmpix, PixmapPtr pdpix)
 {
-	struct nouveau_bo *src = nouveau_pixmap_bo(pspix);
 	struct nouveau_bo *dst = nouveau_pixmap_bo(pdpix);
-	struct nouveau_bo *mask = pmpix ? nouveau_pixmap_bo(pmpix) : NULL;
-	NVC0EXA_LOCALS(pspix);
+	NVC0EXA_LOCALS(pdpix);
 
 	if (!PUSH_SPACE(push, 256))
 		NOUVEAU_FALLBACK("space\n");
@@ -881,10 +884,13 @@ NVC0EXAPrepareComposite(int op,
 
 	PUSH_RESET(push);
 	PUSH_REFN (push, pNv->scratch, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
-	PUSH_REFN (push, src, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+	if (pspict->pDrawable)
+		PUSH_REFN (push, nouveau_pixmap_bo(pspix),
+			   NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
 	PUSH_REFN (push, dst, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
-	if (pmpict)
-		PUSH_REFN (push, mask, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+	if (pmpict && pmpict->pDrawable)
+		PUSH_REFN (push, nouveau_pixmap_bo(pmpix),
+			   NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
 
 	nouveau_pushbuf_bufctx(push, pNv->bufctx);
 	if (nouveau_pushbuf_validate(push)) {

commit b4231dd715a8a7f86b04519b5f4e8a8d93c2f561
Author: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Date:   Tue Oct 9 09:06:59 2012 +0200

    dri2: Fix potential race and crash for swap at next vblank.
    
    This fixes a potential race + crash that wasn't properly
    handled by commit 248de8cdbd6d0bc062633b49896fa4791148cd3b
    and happened at least on one users machine.
    
    That commit wrongly assumed no special action would be needed
    for swaps at next vblank while triple-buffering is enabled on
    XOrg server 1.12 or later.
    
    Closer inspection of the x-server main dispatch loop shows
    it is possible that the client manages to get the server
    to dispatch a new DRI2GetBuffersWithFormat() call before
    the server calls the vblank event handler and executes
    the nouveau_dri2_finish_swap() routine. Such a race would
    cause a crash, as described in above commit.
    
    This commit handles the "swap at next vblank" case by
    calling nouveau_dri2_finish_swap() immediately without
    the roundtrip (queue vblank_event -> kernel -> deliver event
    -> x-server processes event -> nouveau vblank event handler),
    before control gets returned to the client.
    
    This avoids the race while retaining triple-buffering. As
    a bonus, time-critical swaps at next vblank get processed
    without roundtrip delay, increasing the chance of not
    skipping a frame due to vblank miss while sync to vblank is
    on.
    
    Thanks to Anssi for reporting this problem on the nouveau
    mailing list at 12th July 2012 and for testing this patch.
    
    Reported-by: Anssi Hannula <anssi.hannula@iki.fi>
    Tested-by: Anssi Hannula <anssi.hannula@iki.fi>
    Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>

diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index 7bd0b3a..8d21dca 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -479,6 +479,7 @@ nouveau_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
 {
 	struct nouveau_dri2_vblank_state *s;
 	CARD64 current_msc, expect_msc;
+	CARD64 current_ust;
 	int ret;
 
 	/* Initialize a swap structure */
@@ -490,9 +491,9 @@ nouveau_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
 		{ SWAP, client, draw->id, dst, src, func, data, 0 };
 
 	if (can_sync_to_vblank(draw)) {
-		/* Get current sequence */
+		/* Get current sequence and vblank time*/
 		ret = nouveau_wait_vblank(draw, DRM_VBLANK_RELATIVE, 0,
-					  &current_msc, NULL, NULL);
+					  &current_msc, &current_ust, NULL);
 		if (ret)
 			goto fail;
 
@@ -512,24 +513,48 @@ nouveau_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
 		if (*target_msc == 0)
 			*target_msc = 1;
 
+		/* Swap at next possible vblank requested? */
+		if (current_msc >= *target_msc - 1) {
+			/* Special case: Need to swap at next vblank.
+			 * Schedule swap immediately, bypassing the kernel
+			 * vblank event mechanism to avoid a dangerous race
+			 * between the client and the x-server vblank event
+			 * dispatch in the main x-server dispatch loop when
+			 * the swap_limit is set to 2 for triple-buffering.
+			 *
+			 * This also optimizes for the common case of swap
+			 * at next vblank, avoiding vblank dispatch delay.
+			 */
+			s->frame = 1 + ((unsigned int) current_msc & 0xffffffff);
+			*target_msc = 1 + current_msc;
+			nouveau_dri2_finish_swap(draw, current_msc,
+						 (unsigned int) (current_ust / 1000000),
+						 (unsigned int) (current_ust % 1000000),
+						 s);
+			return TRUE;
+		}
+
+		/* This is a swap in the future, ie. the vblank event will
+		 * only get dispatched at least 2 vblanks into the future.
+		 */
+
 #if DRI2INFOREC_VERSION >= 6
-		/* Is this a swap in the future, ie. the vblank event will
-		 * not be immediately dispatched, but only at a future vblank?
-		 * If so, we need to temporarily lower the swaplimit to 1, so
-		 * that DRI2GetBuffersWithFormat() requests from the client get
+		/* On XOrg 1.12+ we need to temporarily lower the swaplimit to 1,
+		 * so that DRI2GetBuffersWithFormat() requests from the client get
 		 * deferred in the x-server until the vblank event has been
 		 * dispatched to us and nouveau_dri2_finish_swap() is done. If
 		 * we wouldn't do this, DRI2GetBuffersWithFormat() would operate
 		 * on wrong (pre-swap) buffers, and cause a segfault later on in
-		 * nouveau_dri2_finish_swap(). Our vblank event handler restores
+		 * nouveau_dri2_finish_swap(). Our vblank event handler will restore
 		 * the old swaplimit immediately after nouveau_dri2_finish_swap()
-		 * is done, so we still get 1 video refresh cycle worth of
-		 * triple-buffering. For a swap at next vblank, dispatch of the
-		 * vblank event happens immediately, so there isn't any need
-		 * for this lowered swaplimit.
+		 * is done, so we still get 1 video refresh cycle worth of triple-
+		 * buffering, because the client can start rendering again 1 cycle
+		 * before the pending swap is completed.
+		 *
+		 * The same race would happen for the "swap at next vblank" case,
+		 * but the special case "swap immediately" code above prevents this.
 		 */
-		if (current_msc < *target_msc - 1)
-			DRI2SwapLimit(draw, 1);
+		DRI2SwapLimit(draw, 1);
 #endif
 
 		/* Request a vblank event one frame before the target */

commit 01c9a9cff7d6232ca6eafa59dd60833a0d9cdc5b
Author: Ben Skeggs <bskeggs@redhat.com>
Date:   Thu Oct 18 18:38:21 2012 +1000

    shadowfb: fix segfault due to reading outside of shadow buffer
    
    Probably caused by the new libdrm port, the new libdrm sets the bo
    size field to the *allocated* size and not the *requested* size,
    making the max_height calculation here invalid.
    
    Switched to using virtualX/virtualY as the bounds, which should
    hopefully do the right thing..
    
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

diff --git a/src/nv_shadow.c b/src/nv_shadow.c
index 67d9ea5..4ad2357 100644
--- a/src/nv_shadow.c
+++ b/src/nv_shadow.c
@@ -32,19 +32,18 @@ void
 NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
 {
 	NVPtr pNv = NVPTR(pScrn);
-	int x1, y1, x2, y2, width, height, cpp, FBPitch, max_height;
+	int x1, y1, x2, y2, width, height, cpp, FBPitch;
 	unsigned char *src, *dst;
    
 	cpp = pScrn->bitsPerPixel >> 3;
 	FBPitch = pScrn->displayWidth * cpp;
-	max_height = pNv->scanout->size/FBPitch;
 
 	nouveau_bo_map(pNv->scanout, NOUVEAU_BO_WR, pNv->client);
 	while(num--) {
 		x1 = MAX(pbox->x1, 0);
 		y1 = MAX(pbox->y1, 0);
-		x2 = MIN(pbox->x2, pScrn->displayWidth);
-		y2 = MIN(pbox->y2, max_height);
+		x2 = MIN(pbox->x2, pScrn->virtualX);
+		y2 = MIN(pbox->y2, pScrn->virtualY);
 		width = (x2 - x1) * cpp;
 		height = y2 - y1;
 

commit 297fd0d0755bda698be1d0b30cc60a41d7673c0b
Author: Dave Airlie <airlied@redhat.com>
Date:   Tue Oct 16 16:15:16 2012 +1000

    nouveau/dri2: fix pixmap/window offset calcs.
    
    This should fix prime rendering under kwin, and not break it under the
    others.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index 71cff26..7bd0b3a 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -165,9 +165,9 @@ nouveau_dri2_copy_region2(ScreenPtr pScreen, DrawablePtr pDraw, RegionPtr pRegio
 		translate = TRUE;
 
 	if (translate && pDraw->type == DRAWABLE_WINDOW) {
-		WindowPtr pWin = (WindowPtr)pDraw;
-		off_x = pWin->origin.x;
-		off_y = pWin->origin.y;
+		PixmapPtr pPix = get_drawable_pixmap(pDraw);
+		off_x = pDraw->x - pPix->screen_x;
+		off_y = pDraw->y - pPix->screen_y;
 	}
 
 	pGC = GetScratchGC(pDraw->depth, pScreen);

commit 5c9379b14cdabc81fd5d4c916dcd93dc77c4f683
Author: Sebastian Keller <sebastian-keller@gmx.de>
Date:   Tue Sep 25 11:35:35 2012 +0200

    exa: use CLAMP_TO_EDGE for RepeatPad
    
    This fixes border rendering in some gtk3 themes.
    https://bugs.freedesktop.org/show_bug.cgi?id=55310
    
    v2 (Ben Skeggs): implement same fix for fermi/kepler too
    
    Signed-off-by: Sebastian Keller <sebastian-keller@gmx.de>
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

diff --git a/src/nv40_exa.c b/src/nv40_exa.c
index 87ed5b2..c9e99e0 100644
--- a/src/nv40_exa.c
+++ b/src/nv40_exa.c
@@ -260,9 +260,9 @@ NV40EXAPictTexture(NVPtr pNv, PixmapPtr pPix, PicturePtr pPict, int unit)
 	if (pPict->repeat) {
 		switch(pPict->repeatType) {
 		case RepeatPad:
-			PUSH_DATA (push, NV30_3D_TEX_WRAP_S_CLAMP | 
-					 NV30_3D_TEX_WRAP_T_CLAMP |
-					 NV30_3D_TEX_WRAP_R_CLAMP);
+			PUSH_DATA (push, NV30_3D_TEX_WRAP_S_CLAMP_TO_EDGE |
+					 NV30_3D_TEX_WRAP_T_CLAMP_TO_EDGE |
+					 NV30_3D_TEX_WRAP_R_CLAMP_TO_EDGE);
 			break;
 		case RepeatReflect:
 			PUSH_DATA (push, NV30_3D_TEX_WRAP_S_MIRRORED_REPEAT |
diff --git a/src/nv50_exa.c b/src/nv50_exa.c
index d6f38eb..e70d92d 100644
--- a/src/nv50_exa.c
+++ b/src/nv50_exa.c
@@ -665,9 +665,9 @@ NV50EXAPictTexture(NVPtr pNv, PixmapPtr ppix, PicturePtr ppict, unsigned unit)
 	if (ppict->repeat) {
 		switch (ppict->repeatType) {
 		case RepeatPad:
-			PUSH_DATA (push, NV50TSC_1_0_WRAPS_CLAMP |
-				 NV50TSC_1_0_WRAPT_CLAMP |
-				 NV50TSC_1_0_WRAPR_CLAMP | 0x00024000);
+			PUSH_DATA (push, NV50TSC_1_0_WRAPS_CLAMP_TO_EDGE |
+				 NV50TSC_1_0_WRAPT_CLAMP_TO_EDGE |
+				 NV50TSC_1_0_WRAPR_CLAMP_TO_EDGE | 0x00024000);
 			break;
 		case RepeatReflect:
 			PUSH_DATA (push, NV50TSC_1_0_WRAPS_MIRROR_REPEAT |
diff --git a/src/nvc0_exa.c b/src/nvc0_exa.c
index dc8ba0b..7bd7294 100644
--- a/src/nvc0_exa.c
+++ b/src/nvc0_exa.c
@@ -659,9 +659,9 @@ NVC0EXAPictTexture(NVPtr pNv, PixmapPtr ppix, PicturePtr ppict, unsigned unit)
 		switch (ppict->repeatType) {
 		case RepeatPad:
 			PUSH_DATA (push, 0x00024000 |
-					 NV50TSC_1_0_WRAPS_CLAMP |
-					 NV50TSC_1_0_WRAPT_CLAMP |
-					 NV50TSC_1_0_WRAPR_CLAMP);
+					 NV50TSC_1_0_WRAPS_CLAMP_TO_EDGE |
+					 NV50TSC_1_0_WRAPT_CLAMP_TO_EDGE |
+					 NV50TSC_1_0_WRAPR_CLAMP_TO_EDGE);
 			break;
 		case RepeatReflect:
 			PUSH_DATA (push, 0x00024000 |

commit 302b5da84b4890c067f5f7e8b0f4e689909bbb51
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Sep 25 10:44:32 2012 -0400

    Remove mibstore.h
    
    Signed-off-by: Adam Jackson <ajax@redhat.com>

diff --git a/src/nv_driver.c b/src/nv_driver.c
index 271f641..9b5b9d6 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1283,7 +1283,6 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
 	if (!pNv->NoAccel && !nouveau_exa_init(pScreen))
 		return FALSE;
 
-	miInitializeBackingStore(pScreen);
 	xf86SetBackingStore(pScreen);
 	xf86SetSilkenMouse(pScreen);
 
diff --git a/src/nv_include.h b/src/nv_include.h
index 3984227..de55570 100644
--- a/src/nv_include.h
+++ b/src/nv_include.h
@@ -27,9 +27,6 @@
 /* All drivers initialising the SW cursor need this */
 #include "mipointer.h"
 
-/* All drivers implementing backing store need this */
-#include "mibstore.h"
-
 #include "micmap.h"
 
 #include "xf86DDC.h"


Reply to: