diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:50:50 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:50:50 +0000 |
commit | 9130ec005fbc78a62420643414d8354d0929ca50 (patch) | |
tree | 6762777acdd2d4eee17ef87290e80dc7afe2b73d /lib/mesa/src/gallium/winsys/nouveau | |
parent | ca11beabae33eb59fb981b8adf50b1d47a2a98f0 (diff) |
Merge Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/winsys/nouveau')
-rw-r--r-- | lib/mesa/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/lib/mesa/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/lib/mesa/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c index 3e790aa65..3c8345b24 100644 --- a/lib/mesa/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c @@ -4,9 +4,11 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/format/u_format.h" +#include "util/os_file.h" #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_hash_table.h" +#include "util/u_pointer.h" #include "os/os_thread.h" #include "nouveau_drm_public.h" @@ -17,7 +19,7 @@ #include <nvif/class.h> #include <nvif/cl0080.h> -static struct util_hash_table *fd_tab = NULL; +static struct hash_table *fd_tab = NULL; static mtx_t nouveau_screen_mutex = _MTX_INITIALIZER_NP; @@ -31,33 +33,11 @@ bool nouveau_drm_screen_unref(struct nouveau_screen *screen) ret = --screen->refcount; assert(ret >= 0); if (ret == 0) - util_hash_table_remove(fd_tab, intptr_to_pointer(screen->drm->fd)); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(screen->drm->fd)); mtx_unlock(&nouveau_screen_mutex); return ret == 0; } -static unsigned hash_fd(void *key) -{ - int fd = pointer_to_intptr(key); - struct stat stat; - fstat(fd, &stat); - - return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ - int fd1 = pointer_to_intptr(key1); - int fd2 = pointer_to_intptr(key2); - struct stat stat1, stat2; - fstat(fd1, &stat1); - fstat(fd2, &stat2); - - return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - PUBLIC struct pipe_screen * nouveau_drm_screen_create(int fd) { @@ -69,7 +49,7 @@ nouveau_drm_screen_create(int fd) mtx_lock(&nouveau_screen_mutex); if (!fd_tab) { - fd_tab = util_hash_table_create(hash_fd, compare_fd); + fd_tab = util_hash_table_create_fd_keys(); if (!fd_tab) { mtx_unlock(&nouveau_screen_mutex); return NULL; @@ -92,7 +72,7 @@ nouveau_drm_screen_create(int fd) * nouveau_device_wrap does not close the fd in case of a device * creation error. */ - dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 3); + dupfd = os_dupfd_cloexec(fd); ret = nouveau_drm_new(dupfd, &drm); if (ret) @@ -125,6 +105,8 @@ nouveau_drm_screen_create(int fd) case 0x110: case 0x120: case 0x130: + case 0x140: + case 0x160: init = nvc0_screen_create; break; default: @@ -141,7 +123,7 @@ nouveau_drm_screen_create(int fd) * closed by its owner. The hash key needs to live at least as long as * the screen. */ - util_hash_table_set(fd_tab, intptr_to_pointer(dupfd), screen); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(dupfd), screen); screen->refcount = 1; mtx_unlock(&nouveau_screen_mutex); return &screen->base; |