OSDN Git Service

winsys/radeon: Use dup fd as key in drm-winsys hash table to fix ZaphodHeads.
authorMario Kleiner <mario.kleiner.de@gmail.com>
Sun, 28 Jun 2015 01:02:31 +0000 (03:02 +0200)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 4 Jul 2015 11:03:15 +0000 (12:03 +0100)
Same problem and fix as for nouveau's ZaphodHeads trouble.

See patch ...

"nouveau: Use dup fd as key in drm-winsys hash table to fix ZaphodHeads."

... for reference.

Cc: "10.3 10.4 10.5 10.6" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 28dda47ae4d974e3e032d60e8e0965c8c068c6d8)

src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index 12c351d..674c60a 100644 (file)
@@ -465,6 +465,10 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws)
     if (ws->gen >= DRV_R600) {
         radeon_surface_manager_free(ws->surf_man);
     }
+
+    if (ws->fd)
+        close(ws->fd);
+
     FREE(rws);
 }
 
@@ -666,7 +670,7 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t screen_create)
         return NULL;
     }
 
-    ws->fd = fd;
+    ws->fd = dup(fd);
 
     if (!do_winsys_init(ws))
         goto fail;
@@ -682,7 +686,7 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t screen_create)
         goto fail;
 
     if (ws->gen >= DRV_R600) {
-        ws->surf_man = radeon_surface_manager_new(fd);
+        ws->surf_man = radeon_surface_manager_new(ws->fd);
         if (!ws->surf_man)
             goto fail;
     }
@@ -723,7 +727,7 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t screen_create)
         return NULL;
     }
 
-    util_hash_table_set(fd_tab, intptr_to_pointer(fd), ws);
+    util_hash_table_set(fd_tab, intptr_to_pointer(ws->fd), ws);
 
     /* We must unlock the mutex once the winsys is fully initialized, so that
      * other threads attempting to create the winsys from the same fd will
@@ -740,6 +744,9 @@ fail:
         ws->kman->destroy(ws->kman);
     if (ws->surf_man)
         radeon_surface_manager_free(ws->surf_man);
+    if (ws->fd)
+        close(ws->fd);
+
     FREE(ws);
     return NULL;
 }