diff options
Diffstat (limited to 'src/intel/vulkan')
-rw-r--r-- | src/intel/vulkan/anv_allocator.c | 28 | ||||
-rw-r--r-- | src/intel/vulkan/anv_gem_stubs.c | 15 |
2 files changed, 8 insertions, 35 deletions
diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 48d41891cfb..a6eeed79a02 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -25,13 +25,13 @@ #include <unistd.h> #include <limits.h> #include <assert.h> -#include <linux/memfd.h> #include <sys/mman.h> #include "anv_private.h" #include "util/hash_table.h" #include "util/simple_mtx.h" +#include "util/anon_file.h" #ifdef HAVE_VALGRIND #define VG_NOACCESS_READ(__ptr) ({ \ @@ -111,14 +111,6 @@ struct anv_mmap_cleanup { #define ANV_MMAP_CLEANUP_INIT ((struct anv_mmap_cleanup){0}) -#ifndef HAVE_MEMFD_CREATE -static inline int -memfd_create(const char *name, unsigned int flags) -{ - return syscall(SYS_memfd_create, name, flags); -} -#endif - static inline uint32_t ilog2_round_up(uint32_t value) { @@ -152,15 +144,12 @@ anv_state_table_init(struct anv_state_table *table, table->device = device; - table->fd = memfd_create("state table", MFD_CLOEXEC); - if (table->fd == -1) - return vk_error(VK_ERROR_INITIALIZATION_FAILED); - /* Just make it 2GB up-front. The Linux kernel won't actually back it * with pages until we either map and fault on one of them or we use * userptr and send a chunk of it off to the GPU. */ - if (ftruncate(table->fd, BLOCK_POOL_MEMFD_SIZE) == -1) { + table->fd = os_create_anonymous_file(BLOCK_POOL_MEMFD_SIZE, "state table"); + if (table->fd == -1) { result = vk_error(VK_ERROR_INITIALIZATION_FAILED); goto fail_fd; } @@ -446,18 +435,13 @@ anv_block_pool_init(struct anv_block_pool *pool, anv_bo_init(pool->bo, 0, 0); if (!(pool->bo_flags & EXEC_OBJECT_PINNED)) { - pool->fd = memfd_create("block pool", MFD_CLOEXEC); - if (pool->fd == -1) - return vk_error(VK_ERROR_INITIALIZATION_FAILED); - /* Just make it 2GB up-front. The Linux kernel won't actually back it * with pages until we either map and fault on one of them or we use * userptr and send a chunk of it off to the GPU. */ - if (ftruncate(pool->fd, BLOCK_POOL_MEMFD_SIZE) == -1) { - result = vk_error(VK_ERROR_INITIALIZATION_FAILED); - goto fail_fd; - } + pool->fd = os_create_anonymous_file(BLOCK_POOL_MEMFD_SIZE, "block pool"); + if (pool->fd == -1) + return vk_error(VK_ERROR_INITIALIZATION_FAILED); } else { pool->fd = -1; } diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index 8cc3ad1f22e..2c27ce26f37 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -21,32 +21,21 @@ * IN THE SOFTWARE. */ -#include <linux/memfd.h> #include <sys/mman.h> #include <sys/syscall.h> +#include "util/anon_file.h" #include "anv_private.h" -#ifndef HAVE_MEMFD_CREATE -static inline int -memfd_create(const char *name, unsigned int flags) -{ - return syscall(SYS_memfd_create, name, flags); -} -#endif - uint32_t anv_gem_create(struct anv_device *device, uint64_t size) { - int fd = memfd_create("fake bo", MFD_CLOEXEC); + int fd = os_create_anonymous_file(size, "fake bo"); if (fd == -1) return 0; assert(fd != 0); - if (ftruncate(fd, size) == -1) - return 0; - return fd; } |