[Mesa-dev] Another important XA patch

Carl Worth cworth at cworth.org
Thu Jul 3 19:59:33 PDT 2014


Thomas Hellstrom <thellstrom at vmware.com> writes:
> Patch st/xa: Don't close the drm fd on failure v2 causes some conflicts
> when backported to 10.2. Let me know if
> you need help resolving them, or if you want me to push a backported
> version to 10.2.

Thanks for the heads-up, Thomas.

The conflict resolution seemed quite straightforward. Take a look and
let me know if you think I botched anything.

-Carl

From ff02e7995c09278be06c34d596d3d8ca11e26ded Mon Sep 17 00:00:00 2001
From: Thomas Hellstrom <thellstrom at vmware.com>
Date: Thu, 3 Jul 2014 02:07:36 -0700
Subject: [PATCH] st/xa: Don't close the drm fd on failure v2

If XA fails to initialize with pipe_loader enabled, the pipe_loader's
cleanup function will close the drm file descriptor. That's pretty bad
because the file descriptor will probably be the X server driver's only
connection to drm. Temporarily solve this by dup()'ing the file descriptor
before handing it over to the pipe loader.

This fixes freedesktop.org bugzilla bug #80645.

v2: Fix CC addresses.

Cc: "10.2" <mesa-stable at lists.freedesktop.org>
Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob at vmware.com>
(cherry picked from commit 35cf3831d71770211f29da6608313dc1f6213d7b)

Conflicts:
	src/gallium/state_trackers/xa/xa_tracker.c
---
 src/gallium/state_trackers/xa/xa_tracker.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index 9add584..be16964 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -26,6 +26,7 @@
  * Thomas Hellstrom <thellstrom-at-vmware-dot-com>
  */
 
+#include <unistd.h>
 #include "xa_tracker.h"
 #include "xa_priv.h"
 #include "pipe/p_state.h"
@@ -140,11 +141,15 @@ xa_tracker_create(int drm_fd)
     struct xa_tracker *xa = calloc(1, sizeof(struct xa_tracker));
     enum xa_surface_type stype;
     unsigned int num_formats;
+    int loader_fd;
 
     if (!xa)
 	return NULL;
 
-    if (pipe_loader_drm_probe_fd(&xa->dev, drm_fd, false))
+    loader_fd = dup(drm_fd);
+    if (loader_fd == -1)
+        return NULL;
+    if (pipe_loader_drm_probe_fd(&xa->dev, loader_fd, false))
 	xa->screen = pipe_loader_create_screen(xa->dev, PIPE_SEARCH_DIR);
     if (!xa->screen)
 	goto out_no_screen;
-- 
2.0.0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140703/87f699fd/attachment.sig>


More information about the mesa-dev mailing list