gallium/util: replace pipe_mutex_lock() with mtx_lock()
[mesa.git] / src / gallium / winsys / nouveau / drm / nouveau_drm_winsys.c
index 598ffcbd06967389b7bfa8c4b80ff655390e95c4..a2a9fd630f3ac7a49425b9fb5152ed63c3e577c7 100644 (file)
@@ -1,5 +1,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "util/u_format.h"
@@ -18,7 +19,7 @@
 
 static struct util_hash_table *fd_tab = NULL;
 
-pipe_static_mutex(nouveau_screen_mutex);
+static mtx_t nouveau_screen_mutex = _MTX_INITIALIZER_NP;
 
 bool nouveau_drm_screen_unref(struct nouveau_screen *screen)
 {
@@ -26,7 +27,7 @@ bool nouveau_drm_screen_unref(struct nouveau_screen *screen)
        if (screen->refcount == -1)
                return true;
 
-       pipe_mutex_lock(nouveau_screen_mutex);
+       mtx_lock(&nouveau_screen_mutex);
        ret = --screen->refcount;
        assert(ret >= 0);
        if (ret == 0)
@@ -66,7 +67,7 @@ nouveau_drm_screen_create(int fd)
        struct nouveau_screen *screen = NULL;
        int ret, dupfd;
 
-       pipe_mutex_lock(nouveau_screen_mutex);
+       mtx_lock(&nouveau_screen_mutex);
        if (!fd_tab) {
                fd_tab = util_hash_table_create(hash_fd, compare_fd);
                if (!fd_tab) {
@@ -91,7 +92,7 @@ nouveau_drm_screen_create(int fd)
         * nouveau_device_wrap does not close the fd in case of a device
         * creation error.
         */
-       dupfd = dup(fd);
+       dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
 
        ret = nouveau_drm_new(dupfd, &drm);
        if (ret)
@@ -123,6 +124,7 @@ nouveau_drm_screen_create(int fd)
        case 0x100:
        case 0x110:
        case 0x120:
+       case 0x130:
                init = nvc0_screen_create;
                break;
        default: