aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/common/gen_gem.h
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/intel/common/gen_gem.h
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/intel/common/gen_gem.h')
-rw-r--r--src/intel/common/gen_gem.h16
1 files changed, 16 insertions, 0 deletions
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 */