lib: Add prime_sync_start and prime_sync_end helpers

This patch adds dma-buf mmap synchronization ioctls that can be used by tests
for cache coherency management e.g. when CPU and GPU domains are being accessed
through dma-buf at the same time.

v7: add sync invalid flags test.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
This commit is contained in:
Tiago Vignatti
2015-12-11 18:50:35 -02:00
parent c0a1c4ea3e
commit ecdb9038d7
3 changed files with 68 additions and 0 deletions
+25
View File
@@ -401,6 +401,30 @@ test_errors(void)
gem_close(fd, handle);
}
/* Test for invalid flags on sync ioctl */
static void
test_invalid_sync_flags(void)
{
int i, dma_buf_fd;
uint32_t handle;
struct local_dma_buf_sync sync;
int invalid_flags[] = {-1,
0x00,
LOCAL_DMA_BUF_SYNC_RW + 1,
LOCAL_DMA_BUF_SYNC_VALID_FLAGS_MASK + 1};
handle = gem_create(fd, BO_SIZE);
dma_buf_fd = prime_handle_to_fd(fd, handle);
for (i = 0; i < sizeof(invalid_flags) / sizeof(invalid_flags[0]); i++) {
memset(&sync, 0, sizeof(sync));
sync.flags = invalid_flags[i];
drmIoctl(dma_buf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync);
igt_assert_eq(errno, EINVAL);
errno = 0;
}
}
static void
test_aperture_limit(void)
{
@@ -473,6 +497,7 @@ igt_main
{ "test_dup", test_dup },
{ "test_userptr", test_userptr },
{ "test_errors", test_errors },
{ "test_invalid_sync_flags", test_invalid_sync_flags },
{ "test_aperture_limit", test_aperture_limit },
};
int i;