summaryrefslogtreecommitdiff
path: root/lib
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
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')
-rw-r--r--lib/igt_draw.c6
-rw-r--r--lib/igt_fb.c4
-rw-r--r--lib/ioctl_wrappers.c68
-rw-r--r--lib/ioctl_wrappers.h4
4 files changed, 71 insertions, 11 deletions
diff --git a/lib/igt_draw.c b/lib/igt_draw.c
index 38ecae0f..07aa8129 100644
--- a/lib/igt_draw.c
+++ b/lib/igt_draw.c
@@ -252,7 +252,7 @@ static void draw_rect_mmap_cpu(int fd, struct buf_data *buf, struct rect *rect,
if (tiling != I915_TILING_NONE)
igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
- ptr = gem_mmap__cpu(fd, buf->handle, 0, buf->size, 0);
+ ptr = __gem_mmap__cpu(fd, buf->handle, 0, buf->size, 0);
igt_assert(ptr);
switch (tiling) {
@@ -281,7 +281,7 @@ static void draw_rect_mmap_gtt(int fd, struct buf_data *buf, struct rect *rect,
gem_set_domain(fd, buf->handle, I915_GEM_DOMAIN_GTT,
I915_GEM_DOMAIN_GTT);
- ptr = gem_mmap__gtt(fd, buf->handle, buf->size, PROT_READ | PROT_WRITE);
+ ptr = __gem_mmap__gtt(fd, buf->handle, buf->size, PROT_READ | PROT_WRITE);
igt_assert(ptr);
draw_rect_ptr_linear(ptr, buf->stride, rect, color, buf->bpp);
@@ -303,7 +303,7 @@ static void draw_rect_mmap_wc(int fd, struct buf_data *buf, struct rect *rect,
if (tiling != I915_TILING_NONE)
igt_require(intel_gen(intel_get_drm_devid(fd)) >= 5);
- ptr = gem_mmap__wc(fd, buf->handle, 0, buf->size,
+ ptr = __gem_mmap__wc(fd, buf->handle, 0, buf->size,
PROT_READ | PROT_WRITE);
igt_assert(ptr);
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index e225f8ac..5ab063fc 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -745,7 +745,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
/* Setup cairo context */
- blit->linear.map = gem_mmap__cpu(fd,
+ blit->linear.map = __gem_mmap__cpu(fd,
blit->linear.handle,
0,
blit->linear.size,
@@ -774,7 +774,7 @@ static void destroy_cairo_surface__gtt(void *arg)
static void create_cairo_surface__gtt(int fd, struct igt_fb *fb)
{
- void *ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size, PROT_READ | PROT_WRITE);
+ void *ptr = __gem_mmap__gtt(fd, fb->gem_handle, fb->size, PROT_READ | PROT_WRITE);
igt_assert(ptr);
fb->cairo_surface =
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
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 7c607a23..7505acbe 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -66,6 +66,10 @@ void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, uns
bool gem_mmap__has_wc(int fd);
void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
+void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot);
+void *__gem_mmap__cpu(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);
+
/**
* gem_require_mmap_wc:
* @fd: open i915 drm file descriptor