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>
This commit is contained in:
Ville Syrjälä
2015-10-09 18:29:28 +03:00
parent 106fe21373
commit b8a77dd6c8
52 changed files with 212 additions and 152 deletions
+4 -4
View File
@@ -544,7 +544,7 @@ static int test_invalid_gtt_mapping(int fd)
/* GTT mapping */
handle = create_bo(fd, 0);
ptr = gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
ptr = __gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
gem_close(fd, handle);
igt_assert(ptr);
igt_assert(((unsigned long)ptr & (PAGE_SIZE - 1)) == 0);
@@ -573,7 +573,7 @@ static void test_process_exit(int fd, int flags)
handle = create_userptr_bo(fd, sizeof(linear));
if (flags & PE_GTT_MAP) {
uint32_t *ptr = gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
uint32_t *ptr = __gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
if (ptr)
*ptr = 0;
}
@@ -688,12 +688,12 @@ static void *umap(int fd, uint32_t handle)
void *ptr;
if (gem_has_llc(fd)) {
ptr = gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
ptr = __gem_mmap__gtt(fd, handle, sizeof(linear), PROT_READ | PROT_WRITE);
igt_assert(ptr);
} else {
uint32_t tmp = gem_create(fd, sizeof(linear));
copy(fd, tmp, handle, 0);
ptr = gem_mmap__cpu(fd, tmp, 0, sizeof(linear), PROT_READ);
ptr = __gem_mmap__cpu(fd, tmp, 0, sizeof(linear), PROT_READ);
igt_assert(ptr);
gem_close(fd, tmp);
}