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

Bug#602207: backported upstream fix



Although this is far too late for the squeeze release, I assume that
fixing this bug in a later point release might be of interest.  The
upstream fix does not apply cleanly to 2.13.0 so I have backported it.
Backport patch is attached.

The second patch is a straight cherry-pick of 537fa55e.  This is
necessary to avoid introducing a regression.  I've not combined the
patches to keep as much as possible of upstream history.

I have succcessfully tested and verified this fix on top of the Debian
package version 2:2.13.0-5.  Please consider it for squeeze.1


Bjørn

>From e40735144642766f25b0f916ff3532bfe0b79617 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
Date: Sat, 15 Jan 2011 14:01:19 +0100
Subject: [PATCH 1/3] Don't replace the scanout bo through PutImage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As the bo may be pinned for either use by the scanout or through sharing
with another application, under those circumstances we cannot replace
the bo itself but must force the blit for PutImage.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31367
Reported-and-tested-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
[backport of commit 53fbc9f1]
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 src/intel.h     |    1 +
 src/intel_dri.c |   26 +++++++++++++++++++-------
 src/intel_uxa.c |    5 +++--
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/intel.h b/src/intel.h
index b816aeb..93a3524 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -169,6 +169,7 @@ struct intel_pixmap {
 	uint8_t tiling;
 	int8_t busy :2;
 	int8_t batch_write :1;
+	int8_t pinned :1;
 };
 
 #if HAS_DEVPRIVATEKEYREC
diff --git a/src/intel_dri.c b/src/intel_dri.c
index 9804272..49d83da 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -71,6 +71,22 @@ typedef struct {
 	unsigned int attachment;
 } I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr;
 
+static uint32_t pixmap_flink(PixmapPtr pixmap)
+{
+	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	uint32_t name;
+	dri_bo *bo;
+
+	if (priv == NULL || priv->bo == NULL)
+		return 0;
+
+	if (dri_bo_flink(bo, &name) != 0)
+		return 0;
+
+	priv->pinned = 1;
+	return name;
+}
+
 #if DRI2INFOREC_VERSION < 2
 
 static DRI2BufferPtr
@@ -81,10 +97,9 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	DRI2BufferPtr buffers;
-	dri_bo *bo;
-	int i;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap, pDepthPixmap;
+	int i;
 
 	buffers = calloc(count, sizeof *buffers);
 	if (buffers == NULL)
@@ -144,8 +159,7 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 		privates[i].pixmap = pixmap;
 		privates[i].attachment = attachments[i];
 
-		bo = intel_get_pixmap_bo(pixmap);
-		if (bo == NULL || dri_bo_flink(bo, &buffers[i].name) != 0) {
+		if ((buffers[i].name = pixmap_flink(pixmap)) == 0) {
 			/* failed to name buffer */
 			screen->DestroyPixmap(pixmap);
 			goto unwind;
@@ -190,7 +204,6 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	DRI2Buffer2Ptr buffer;
-	dri_bo *bo;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap;
 
@@ -252,8 +265,7 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	privates->pixmap = pixmap;
 	privates->attachment = attachment;
 
-	bo = intel_get_pixmap_bo(pixmap);
-	if (bo == NULL || dri_bo_flink(bo, &buffer->name) != 0) {
+	if ((buffer->name = pixmap_flink(pixmap)) == 0) {
 		/* failed to name buffer */
 		screen->DestroyPixmap(pixmap);
 		free(privates);
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index ef4c553..b3d8d31 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -767,7 +767,8 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
 	} else {
 		ScreenPtr screen = pixmap->drawable.pScreen;
 
-		if (x == 0 && y == 0 &&
+		if (!priv->pinned &&
+		    x == 0 && y == 0 &&
 		    w == pixmap->drawable.width &&
 		    h == pixmap->drawable.height)
 		{
@@ -1263,7 +1264,7 @@ void intel_uxa_create_screen_resources(ScreenPtr screen)
 		if (bo != NULL) {
 			PixmapPtr pixmap = screen->GetScreenPixmap(screen);
 			intel_set_pixmap_bo(pixmap, bo);
-			intel_get_pixmap_private(pixmap)->busy = 1;
+			intel_get_pixmap_private(pixmap)->pinned = 1;
 			screen->ModifyPixmapHeader(pixmap,
 						   scrn->virtualX,
 						   scrn->virtualY,
-- 
1.7.2.3

>From 20f80989044dee581e97ae33ffd3d3789e8dfeff Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris@chris-wilson.co.uk>
Date: Sun, 2 Jan 2011 09:06:28 +0000
Subject: [PATCH 2/3] dri: Fix the use of the uninitialised bo for flink
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reported-by: Jeff Chua <jeff.chua.linux@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
(cherry picked from commit 537fa55ed2449e91f3dd1e04abc720c6818d7227)

Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 src/intel_dri.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/intel_dri.c b/src/intel_dri.c
index 49d83da..1c151bf 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -75,12 +75,11 @@ static uint32_t pixmap_flink(PixmapPtr pixmap)
 {
 	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
 	uint32_t name;
-	dri_bo *bo;
 
 	if (priv == NULL || priv->bo == NULL)
 		return 0;
 
-	if (dri_bo_flink(bo, &name) != 0)
+	if (dri_bo_flink(priv->bo, &name) != 0)
 		return 0;
 
 	priv->pinned = 1;
-- 
1.7.2.3


Reply to: