summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2015-10-09 18:29:28 +0300
committerVille Syrjälä <ville.syrjala@linux.intel.com>2015-10-09 19:16:26 +0300
commitb8a77dd6c8e9f73493b2f86f293ff9c06fc08049 (patch)
tree7e43c045f1ff755144818b71b6d89942667c3565 /lib/ioctl_wrappers.c
parent106fe21373f9c3eadcd95fb4b48e452f9b328ffa (diff)
Make gem_mmap__{cpu,gtt,wc}() assert on failure
Rename the current gem_mmap__{cpu,gtt,wc}() functions into __gem_mmap__{cpu,gtt,wc}(), and add back wrappers with the original name that assert that the pointer is valid. Most callers will expect a valid pointer and shouldn't have to bother with failures. To avoid changing anything (yet), sed 's/gem_mmap__/__gem_mmap__/g' over the entire codebase. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c68
1 files changed, 62 insertions, 6 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index eb745bc0..36982a73 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -447,7 +447,7 @@ void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
}
/**
- * gem_mmap__gtt:
+ * __gem_mmap__gtt:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @size: size of the gem buffer
@@ -458,7 +458,7 @@ void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
*
* Returns: A pointer to the created memory mapping, NULL on failure.
*/
-void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
+void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
{
struct drm_i915_gem_mmap_gtt mmap_arg;
void *ptr;
@@ -477,6 +477,24 @@ void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
return ptr;
}
+/**
+ * gem_mmap__gtt:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @size: size of the gem buffer
+ * @prot: memory protection bits as used by mmap()
+ *
+ * Like __gem_mmap__gtt() except we assert on failure.
+ *
+ * Returns: A pointer to the created memory mapping
+ */
+void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap__gtt(fd, handle, size, prot);
+ igt_assert(ptr);
+ return ptr;
+}
+
struct local_i915_gem_mmap_v2 {
uint32_t handle;
uint32_t pad;
@@ -523,7 +541,7 @@ bool gem_mmap__has_wc(int fd)
}
/**
- * gem_mmap__wc:
+ * __gem_mmap__wc:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset in the gem buffer of the mmap arena
@@ -537,7 +555,7 @@ bool gem_mmap__has_wc(int fd)
*
* Returns: A pointer to the created memory mapping, NULL on failure.
*/
-void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
{
struct local_i915_gem_mmap_v2 arg;
@@ -559,7 +577,26 @@ void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsi
}
/**
- * gem_mmap__cpu:
+ * gem_mmap__wc:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ *
+ * Like __gem_mmap__wc() except we assert on failure.
+ *
+ * Returns: A pointer to the created memory mapping
+ */
+void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap__wc(fd, handle, offset, size, prot);
+ igt_assert(ptr);
+ return ptr;
+}
+
+/**
+ * __gem_mmap__cpu:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle
* @offset: offset in the gem buffer of the mmap arena
@@ -571,7 +608,7 @@ void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsi
*
* Returns: A pointer to the created memory mapping, NULL on failure.
*/
-void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
{
struct drm_i915_gem_mmap mmap_arg;
@@ -587,6 +624,25 @@ void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, uns
}
/**
+ * gem_mmap__cpu:
+ * @fd: open i915 drm file descriptor
+ * @handle: gem buffer object handle
+ * @offset: offset in the gem buffer of the mmap arena
+ * @size: size of the mmap arena
+ * @prot: memory protection bits as used by mmap()
+ *
+ * Like __gem_mmap__cpu() except we assert on failure.
+ *
+ * Returns: A pointer to the created memory mapping
+ */
+void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot)
+{
+ void *ptr = __gem_mmap__cpu(fd, handle, offset, size, prot);
+ igt_assert(ptr);
+ return ptr;
+}
+
+/**
* gem_madvise:
* @fd: open i915 drm file descriptor
* @handle: gem buffer object handle