summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Janes <[email protected]>2019-07-25 10:50:36 -0700
committerMark Janes <[email protected]>2019-08-01 16:38:40 -0700
commit7852fe54159cb6602a4408b8107b52999890dc79 (patch)
treea81d986430509aedc6defb1f1cb3b78e2e6fb677 /src
parentb40ba2db6c81021f83465a4ac32922a064cc91b2 (diff)
intel/common: provide common ioctl routine
i965 links against libdrm for drmIoctl, but anv and iris both re-implement this routine to avoid the dependency. intel/dev also needs an ioctl wrapper, so lets share the same implementation everywhere. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/iris/iris_batch.c3
-rw-r--r--src/gallium/drivers/iris/iris_bufmgr.c58
-rw-r--r--src/gallium/drivers/iris/iris_fence.c15
-rw-r--r--src/gallium/drivers/iris/iris_screen.c3
-rw-r--r--src/intel/common/gen_gem.h16
-rw-r--r--src/intel/vulkan/anv_gem.c89
6 files changed, 89 insertions, 95 deletions
diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index 38405187772..27acf8a5387 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -44,6 +44,7 @@
#include "drm-uapi/i915_drm.h"
+#include "intel/common/gen_gem.h"
#include "util/hash_table.h"
#include "util/set.h"
#include "main/macros.h"
@@ -574,7 +575,7 @@ submit_batch(struct iris_batch *batch)
int ret = 0;
if (!batch->screen->no_hw &&
- drm_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf))
+ gen_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf))
ret = -errno;
for (int i = 0; i < batch->exec_count; i++) {
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index d8094582409..32adae53670 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -93,20 +93,6 @@
#define FILE_DEBUG_FLAG DEBUG_BUFMGR
-/**
- * Call ioctl, restarting if it is interupted
- */
-int
-drm_ioctl(int fd, unsigned long request, void *arg)
-{
- int ret;
-
- do {
- ret = ioctl(fd, request, arg);
- } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
- return ret;
-}
-
static inline int
atomic_add_unless(int *v, int add, int unless)
{
@@ -320,7 +306,7 @@ iris_bo_busy(struct iris_bo *bo)
struct iris_bufmgr *bufmgr = bo->bufmgr;
struct drm_i915_gem_busy busy = { .handle = bo->gem_handle };
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
if (ret == 0) {
bo->idle = !busy.busy;
return busy.busy;
@@ -337,7 +323,7 @@ iris_bo_madvise(struct iris_bo *bo, int state)
.retained = 1,
};
- drm_ioctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_MADVISE, &madv);
+ gen_ioctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_MADVISE, &madv);
return madv.retained;
}
@@ -429,7 +415,7 @@ alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size)
/* All new BOs we get from the kernel are zeroed, so we don't need to
* worry about that here.
*/
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CREATE, &create) != 0) {
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CREATE, &create) != 0) {
free(bo);
return NULL;
}
@@ -452,7 +438,7 @@ alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size)
.write_domain = 0,
};
- if (drm_ioctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd) != 0) {
+ if (gen_ioctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd) != 0) {
bo_free(bo);
return NULL;
}
@@ -531,7 +517,7 @@ bo_alloc_internal(struct iris_bufmgr *bufmgr,
.handle = bo->gem_handle,
.caching = 1,
};
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) == 0) {
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) == 0) {
bo->cache_coherent = true;
bo->reusable = false;
}
@@ -582,7 +568,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
.user_ptr = (uintptr_t)ptr,
.user_size = size,
};
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg))
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg))
goto err_free;
bo->gem_handle = arg.handle;
@@ -591,7 +577,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
.handle = bo->gem_handle,
.read_domains = I915_GEM_DOMAIN_CPU,
};
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd))
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd))
goto err_close;
bo->name = name;
@@ -617,7 +603,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name,
return bo;
err_close:
- drm_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &bo->gem_handle);
+ gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &bo->gem_handle);
err_free:
free(bo);
return NULL;
@@ -649,7 +635,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
}
struct drm_gem_open open_arg = { .name = handle };
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_GEM_OPEN, &open_arg);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_OPEN, &open_arg);
if (ret != 0) {
DBG("Couldn't reference %s handle 0x%08x: %s\n",
name, handle, strerror(errno));
@@ -687,7 +673,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr,
_mesa_hash_table_insert(bufmgr->name_table, &bo->global_name, bo);
struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
- ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
+ ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
if (ret != 0)
goto err_unref;
@@ -713,7 +699,7 @@ bo_close(struct iris_bo *bo)
/* Close this object */
struct drm_gem_close close = { .handle = bo->gem_handle };
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close);
if (ret != 0) {
DBG("DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n",
bo->gem_handle, bo->name, strerror(errno));
@@ -904,7 +890,7 @@ iris_bo_map_cpu(struct pipe_debug_callback *dbg,
.handle = bo->gem_handle,
.size = bo->size,
};
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg);
if (ret != 0) {
DBG("%s:%d: Error mapping buffer %d (%s): %s .\n",
__FILE__, __LINE__, bo->gem_handle, bo->name, strerror(errno));
@@ -965,7 +951,7 @@ iris_bo_map_wc(struct pipe_debug_callback *dbg,
.size = bo->size,
.flags = I915_MMAP_WC,
};
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP, &mmap_arg);
if (ret != 0) {
DBG("%s:%d: Error mapping buffer %d (%s): %s .\n",
__FILE__, __LINE__, bo->gem_handle, bo->name, strerror(errno));
@@ -1027,7 +1013,7 @@ iris_bo_map_gtt(struct pipe_debug_callback *dbg,
struct drm_i915_gem_mmap_gtt mmap_arg = { .handle = bo->gem_handle };
/* Get the fake offset back... */
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);
if (ret != 0) {
DBG("%s:%d: Error preparing buffer map %d (%s): %s .\n",
__FILE__, __LINE__, bo->gem_handle, bo->name, strerror(errno));
@@ -1185,7 +1171,7 @@ iris_bo_wait(struct iris_bo *bo, int64_t timeout_ns)
.bo_handle = bo->gem_handle,
.timeout_ns = timeout_ns,
};
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
if (ret != 0)
return -errno;
@@ -1322,7 +1308,7 @@ iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd)
bo->gtt_offset = vma_alloc(bufmgr, IRIS_MEMZONE_OTHER, bo->size, 1);
struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
goto err;
bo->tiling_mode = get_tiling.tiling_mode;
@@ -1393,7 +1379,7 @@ iris_bo_flink(struct iris_bo *bo, uint32_t *name)
if (!bo->global_name) {
struct drm_gem_flink flink = { .handle = bo->gem_handle };
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_GEM_FLINK, &flink))
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_GEM_FLINK, &flink))
return -errno;
mtx_lock(&bufmgr->lock);
@@ -1458,7 +1444,7 @@ uint32_t
iris_create_hw_context(struct iris_bufmgr *bufmgr)
{
struct drm_i915_gem_context_create create = { };
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
if (ret != 0) {
DBG("DRM_IOCTL_I915_GEM_CONTEXT_CREATE failed: %s\n", strerror(errno));
return 0;
@@ -1513,7 +1499,7 @@ iris_hw_context_set_priority(struct iris_bufmgr *bufmgr,
int err;
err = 0;
- if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
+ if (gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
err = -errno;
return err;
@@ -1538,7 +1524,7 @@ iris_destroy_hw_context(struct iris_bufmgr *bufmgr, uint32_t ctx_id)
struct drm_i915_gem_context_destroy d = { .ctx_id = ctx_id };
if (ctx_id != 0 &&
- drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &d) != 0) {
+ gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &d) != 0) {
fprintf(stderr, "DRM_IOCTL_I915_GEM_CONTEXT_DESTROY failed: %s\n",
strerror(errno));
}
@@ -1548,7 +1534,7 @@ int
iris_reg_read(struct iris_bufmgr *bufmgr, uint32_t offset, uint64_t *result)
{
struct drm_i915_reg_read reg_read = { .offset = offset };
- int ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_REG_READ, &reg_read);
+ int ret = gen_ioctl(bufmgr->fd, DRM_IOCTL_I915_REG_READ, &reg_read);
*result = reg_read.val;
return ret;
@@ -1563,7 +1549,7 @@ iris_gtt_size(int fd)
struct drm_i915_gem_context_param p = {
.param = I915_CONTEXT_PARAM_GTT_SIZE,
};
- if (!drm_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p))
+ if (!gen_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p))
return p.value;
return 0;
diff --git a/src/gallium/drivers/iris/iris_fence.c b/src/gallium/drivers/iris/iris_fence.c
index 53102dff3a0..d4ce3c16728 100644
--- a/src/gallium/drivers/iris/iris_fence.c
+++ b/src/gallium/drivers/iris/iris_fence.c
@@ -27,6 +27,7 @@
*/
#include "util/u_inlines.h"
+#include "intel/common/gen_gem.h"
#include "iris_batch.h"
#include "iris_bufmgr.h"
@@ -41,7 +42,7 @@ gem_syncobj_create(int fd, uint32_t flags)
.flags = flags,
};
- drm_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
+ gen_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
return args.handle;
}
@@ -53,7 +54,7 @@ gem_syncobj_destroy(int fd, uint32_t handle)
.handle = handle,
};
- drm_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
+ gen_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
}
/**
@@ -152,7 +153,7 @@ iris_wait_syncpt(struct pipe_screen *p_screen,
.count_handles = 1,
.timeout_nsec = timeout_nsec,
};
- return drm_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
+ return gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
}
static void
@@ -246,7 +247,7 @@ iris_fence_finish(struct pipe_screen *p_screen,
.timeout_nsec = rel2abs(timeout), /* XXX */
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL
};
- return drm_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args) == 0;
+ return gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args) == 0;
}
#ifndef SYNC_IOC_MAGIC
@@ -282,7 +283,7 @@ sync_merge_fd(int sync_fd, int new_fd)
.fence = -1,
};
- drm_ioctl(sync_fd, SYNC_IOC_MERGE, &args);
+ gen_ioctl(sync_fd, SYNC_IOC_MERGE, &args);
close(new_fd);
close(sync_fd);
@@ -303,7 +304,7 @@ iris_fence_get_fd(struct pipe_screen *p_screen,
.fd = -1,
};
- drm_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+ gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
fd = sync_merge_fd(fd, args.fd);
}
@@ -323,7 +324,7 @@ iris_fence_create_fd(struct pipe_context *ctx,
.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE,
.fd = fd,
};
- drm_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+ gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
struct iris_syncpt *syncpt = malloc(sizeof(*syncpt));
syncpt->handle = args.handle;
diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
index 0c497329dea..ceacae239a0 100644
--- a/src/gallium/drivers/iris/iris_screen.c
+++ b/src/gallium/drivers/iris/iris_screen.c
@@ -52,6 +52,7 @@
#include "iris_resource.h"
#include "iris_screen.h"
#include "intel/compiler/brw_compiler.h"
+#include "intel/common/gen_gem.h"
static void
iris_flush_frontbuffer(struct pipe_screen *_screen,
@@ -97,7 +98,7 @@ static uint64_t
get_aperture_size(int fd)
{
struct drm_i915_gem_get_aperture aperture = {};
- drm_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+ gen_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
return aperture.aper_size;
}
diff --git a/src/intel/common/gen_gem.h b/src/intel/common/gen_gem.h
index 8df2c249e48..c4dda6de657 100644
--- a/src/intel/common/gen_gem.h
+++ b/src/intel/common/gen_gem.h
@@ -24,7 +24,9 @@
#ifndef GEN_GEM_H
#define GEN_GEM_H
+#include <errno.h>
#include <stdint.h>
+#include <sys/ioctl.h>
static inline uint64_t
gen_canonical_address(uint64_t v)
@@ -54,4 +56,18 @@ gen_48b_address(uint64_t v)
return (uint64_t)(v << shift) >> shift;
}
+/**
+ * Call ioctl, restarting if it is interupted
+ */
+static inline int
+gen_ioctl(int fd, unsigned long request, void *arg)
+{
+ int ret;
+
+ do {
+ ret = ioctl(fd, request, arg);
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+ return ret;
+}
+
#endif /* GEN_GEM_H */
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 1bdf040c1a3..2deccb88b97 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -31,18 +31,7 @@
#include "anv_private.h"
#include "common/gen_defines.h"
-
-static int
-anv_ioctl(int fd, unsigned long request, void *arg)
-{
- int ret;
-
- do {
- ret = ioctl(fd, request, arg);
- } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
-
- return ret;
-}
+#include "common/gen_gem.h"
/**
* Wrapper around DRM_IOCTL_I915_GEM_CREATE.
@@ -56,7 +45,7 @@ anv_gem_create(struct anv_device *device, uint64_t size)
.size = size,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
if (ret != 0) {
/* FIXME: What do we do if this fails? */
return 0;
@@ -72,7 +61,7 @@ anv_gem_close(struct anv_device *device, uint32_t gem_handle)
.handle = gem_handle,
};
- anv_ioctl(device->fd, DRM_IOCTL_GEM_CLOSE, &close);
+ gen_ioctl(device->fd, DRM_IOCTL_GEM_CLOSE, &close);
}
/**
@@ -89,7 +78,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
.flags = flags,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_MMAP, &gem_mmap);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_MMAP, &gem_mmap);
if (ret != 0)
return MAP_FAILED;
@@ -116,7 +105,7 @@ anv_gem_userptr(struct anv_device *device, void *mem, size_t size)
.flags = 0,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr);
if (ret == -1)
return 0;
@@ -132,7 +121,7 @@ anv_gem_set_caching(struct anv_device *device,
.caching = caching,
};
- return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &gem_caching);
+ return gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &gem_caching);
}
int
@@ -145,7 +134,7 @@ anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
.write_domain = write_domain,
};
- return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &gem_set_domain);
+ return gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &gem_set_domain);
}
/**
@@ -158,7 +147,7 @@ anv_gem_busy(struct anv_device *device, uint32_t gem_handle)
.handle = gem_handle,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
if (ret < 0)
return ret;
@@ -177,7 +166,7 @@ anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns
.flags = 0,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_WAIT, &wait);
*timeout_ns = wait.timeout_ns;
return ret;
@@ -188,9 +177,9 @@ anv_gem_execbuffer(struct anv_device *device,
struct drm_i915_gem_execbuffer2 *execbuf)
{
if (execbuf->flags & I915_EXEC_FENCE_OUT)
- return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf);
+ return gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf);
else
- return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
+ return gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
}
/** Return -1 on error. */
@@ -201,7 +190,7 @@ anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
.handle = gem_handle,
};
- if (anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) {
+ if (gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) {
assert(!"Failed to get BO tiling");
return -1;
}
@@ -216,7 +205,7 @@ anv_gem_set_tiling(struct anv_device *device,
int ret;
/* set_tiling overwrites the input on the error path, so we have to open
- * code anv_ioctl.
+ * code gen_ioctl.
*/
do {
struct drm_i915_gem_set_tiling set_tiling = {
@@ -241,7 +230,7 @@ anv_gem_get_param(int fd, uint32_t param)
.value = &tmp,
};
- int ret = anv_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+ int ret = gen_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
if (ret == 0)
return tmp;
@@ -258,7 +247,7 @@ anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
.size = 4096,
};
- if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create)) {
+ if (gen_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create)) {
assert(!"Failed to create GEM BO");
return false;
}
@@ -266,7 +255,7 @@ anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
bool swizzled = false;
/* set_tiling overwrites the input on the error path, so we have to open
- * code anv_ioctl.
+ * code gen_ioctl.
*/
do {
struct drm_i915_gem_set_tiling set_tiling = {
@@ -287,7 +276,7 @@ anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
.handle = gem_create.handle,
};
- if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) {
+ if (gen_ioctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) {
assert(!"Failed to get BO tiling");
goto close_and_return;
}
@@ -298,7 +287,7 @@ close_and_return:
memset(&close, 0, sizeof(close));
close.handle = gem_create.handle;
- anv_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
+ gen_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
return swizzled;
}
@@ -315,7 +304,7 @@ anv_gem_create_context(struct anv_device *device)
{
struct drm_i915_gem_context_create create = { 0 };
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
if (ret == -1)
return -1;
@@ -329,7 +318,7 @@ anv_gem_destroy_context(struct anv_device *device, int context)
.ctx_id = context,
};
- return anv_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
+ return gen_ioctl(device->fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
}
int
@@ -342,7 +331,7 @@ anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
};
int err = 0;
- if (anv_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
+ if (gen_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p))
err = -errno;
return err;
}
@@ -355,7 +344,7 @@ anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
.param = param,
};
- int ret = anv_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &gp);
+ int ret = gen_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &gp);
if (ret == -1)
return -1;
@@ -368,7 +357,7 @@ anv_gem_get_aperture(int fd, uint64_t *size)
{
struct drm_i915_gem_get_aperture aperture = { 0 };
- int ret = anv_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+ int ret = gen_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
if (ret == -1)
return -1;
@@ -385,7 +374,7 @@ anv_gem_gpu_get_reset_stats(struct anv_device *device,
.ctx_id = device->context_id,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats);
if (ret == 0) {
*active = stats.batch_active;
*pending = stats.batch_pending;
@@ -402,7 +391,7 @@ anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
.flags = DRM_CLOEXEC,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
if (ret == -1)
return -1;
@@ -416,7 +405,7 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
.fd = fd,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);
if (ret == -1)
return 0;
@@ -430,7 +419,7 @@ anv_gem_reg_read(struct anv_device *device, uint32_t offset, uint64_t *result)
.offset = offset
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_I915_REG_READ, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_I915_REG_READ, &args);
*result = args.val;
return ret;
@@ -463,7 +452,7 @@ anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
.fence = -1,
};
- int ret = anv_ioctl(fd1, SYNC_IOC_MERGE, &args);
+ int ret = gen_ioctl(fd1, SYNC_IOC_MERGE, &args);
if (ret == -1)
return -1;
@@ -477,7 +466,7 @@ anv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
.flags = flags,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
if (ret)
return 0;
@@ -491,7 +480,7 @@ anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
.handle = handle,
};
- anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
+ gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
}
int
@@ -501,7 +490,7 @@ anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
.handle = handle,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
if (ret)
return -1;
@@ -515,7 +504,7 @@ anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
.fd = fd,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
if (ret)
return 0;
@@ -530,7 +519,7 @@ anv_gem_syncobj_export_sync_file(struct anv_device *device, uint32_t handle)
.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE,
};
- int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+ int ret = gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
if (ret)
return -1;
@@ -547,7 +536,7 @@ anv_gem_syncobj_import_sync_file(struct anv_device *device,
.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE,
};
- return anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+ return gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
}
void
@@ -558,7 +547,7 @@ anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
.count_handles = 1,
};
- anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_RESET, &args);
+ gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_RESET, &args);
}
bool
@@ -569,7 +558,7 @@ anv_gem_supports_syncobj_wait(int fd)
struct drm_syncobj_create create = {
.flags = 0,
};
- ret = anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
+ ret = gen_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
if (ret)
return false;
@@ -581,12 +570,12 @@ anv_gem_supports_syncobj_wait(int fd)
.timeout_nsec = 0,
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
};
- ret = anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
+ ret = gen_ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
struct drm_syncobj_destroy destroy = {
.handle = syncobj,
};
- anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
+ gen_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
/* If it timed out, then we have the ioctl and it supports the
* DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT flag.
@@ -609,5 +598,5 @@ anv_gem_syncobj_wait(struct anv_device *device,
if (wait_all)
args.flags |= DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL;
- return anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
+ return gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
}