Changeset View
Changeset View
Standalone View
Standalone View
graphics/igt-gpu-tools/files/patch-tests_dmabuf__sync__file.c
- This file was added.
--- tests/dmabuf_sync_file.c.orig 2022-08-17 23:41:17 UTC | |||||
+++ tests/dmabuf_sync_file.c | |||||
@@ -4,7 +4,9 @@ | |||||
#include "igt_vgem.h" | |||||
#include "sw_sync.h" | |||||
+#ifdef __linux__ | |||||
#include <linux/dma-buf.h> | |||||
+#endif | |||||
#include <sys/poll.h> | |||||
IGT_TEST_DESCRIPTION("Tests for sync_file support in dma-buf"); | |||||
@@ -19,6 +21,7 @@ static bool has_dmabuf_export_sync_file(int fd) | |||||
static bool has_dmabuf_export_sync_file(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf, ret; | |||||
struct igt_dma_buf_sync_file arg; | |||||
@@ -39,10 +42,14 @@ static bool has_dmabuf_export_sync_file(int fd) | |||||
igt_assert(ret == 0 || errno == ENOTTY); | |||||
return ret == 0; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return false; | |||||
+#endif | |||||
} | |||||
static int dmabuf_export_sync_file(int dmabuf, uint32_t flags) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct igt_dma_buf_sync_file arg; | |||||
arg.flags = flags; | |||||
@@ -50,10 +57,14 @@ static int dmabuf_export_sync_file(int dmabuf, uint32_ | |||||
do_ioctl(dmabuf, IGT_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &arg); | |||||
return arg.fd; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return -ENOSYS; | |||||
+#endif | |||||
} | |||||
static bool has_dmabuf_import_sync_file(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf, timeline, fence, ret; | |||||
struct igt_dma_buf_sync_file arg; | |||||
@@ -79,30 +90,38 @@ static bool has_dmabuf_import_sync_file(int fd) | |||||
igt_assert(ret == 0 || errno == ENOTTY); | |||||
return ret == 0; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return false; | |||||
+#endif | |||||
} | |||||
static void dmabuf_import_sync_file(int dmabuf, uint32_t flags, int sync_fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct igt_dma_buf_sync_file arg; | |||||
arg.flags = flags; | |||||
arg.fd = sync_fd; | |||||
do_ioctl(dmabuf, IGT_DMA_BUF_IOCTL_IMPORT_SYNC_FILE, &arg); | |||||
+#endif | |||||
} | |||||
static void | |||||
dmabuf_import_timeline_fence(int dmabuf, uint32_t flags, | |||||
int timeline, uint32_t seqno) | |||||
{ | |||||
+#ifdef __linux__ | |||||
int fence; | |||||
fence = sw_sync_timeline_create_fence(timeline, seqno); | |||||
dmabuf_import_sync_file(dmabuf, flags, fence); | |||||
close(fence); | |||||
+#endif | |||||
} | |||||
static bool dmabuf_busy(int dmabuf, uint32_t flags) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct pollfd pfd = { .fd = dmabuf }; | |||||
/* If DMA_BUF_SYNC_WRITE is set, we don't want to set POLLIN or | |||||
@@ -115,6 +134,9 @@ static bool dmabuf_busy(int dmabuf, uint32_t flags) | |||||
pfd.events |= POLLIN; | |||||
return poll(&pfd, 1, 0) == 0; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return false; | |||||
+#endif | |||||
} | |||||
static bool sync_file_busy(int sync_file) | |||||
@@ -125,6 +147,7 @@ static bool dmabuf_sync_file_busy(int dmabuf, uint32_t | |||||
static bool dmabuf_sync_file_busy(int dmabuf, uint32_t flags) | |||||
{ | |||||
+#ifdef __linux__ | |||||
int sync_file; | |||||
bool busy; | |||||
@@ -133,10 +156,14 @@ static bool dmabuf_sync_file_busy(int dmabuf, uint32_t | |||||
close(sync_file); | |||||
return busy; | |||||
+#elif defined(__FreeBSD__) | |||||
+ return false; | |||||
+#endif | |||||
} | |||||
static void test_export_basic(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf; | |||||
uint32_t fence; | |||||
@@ -189,10 +216,12 @@ static void test_export_basic(int fd) | |||||
close(dmabuf); | |||||
gem_close(fd, bo.handle); | |||||
+#endif | |||||
} | |||||
static void test_export_before_signal(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf, read_fd, write_fd; | |||||
uint32_t fence; | |||||
@@ -243,10 +272,12 @@ static void test_export_before_signal(int fd) | |||||
close(dmabuf); | |||||
gem_close(fd, bo.handle); | |||||
+#endif | |||||
} | |||||
static void test_export_multiwait(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf, sync_file; | |||||
uint32_t fence1, fence2, fence3; | |||||
@@ -282,10 +313,12 @@ static void test_export_multiwait(int fd) | |||||
close(sync_file); | |||||
close(dmabuf); | |||||
gem_close(fd, bo.handle); | |||||
+#endif | |||||
} | |||||
static void test_export_wait_after_attach(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf, read_sync_file, write_sync_file; | |||||
uint32_t fence1, fence2; | |||||
@@ -333,10 +366,12 @@ static void test_export_wait_after_attach(int fd) | |||||
close(dmabuf); | |||||
gem_close(fd, bo.handle); | |||||
+#endif | |||||
} | |||||
static void test_import_basic(int fd) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int dmabuf, timeline; | |||||
@@ -402,10 +437,12 @@ static void test_import_basic(int fd) | |||||
igt_assert(!dmabuf_sync_file_busy(dmabuf, DMA_BUF_SYNC_READ)); | |||||
igt_assert(!dmabuf_sync_file_busy(dmabuf, DMA_BUF_SYNC_WRITE)); | |||||
igt_assert(!dmabuf_sync_file_busy(dmabuf, DMA_BUF_SYNC_RW)); | |||||
+#endif | |||||
} | |||||
static void test_import_multiple(int fd, bool write) | |||||
{ | |||||
+#ifdef __linux__ | |||||
struct vgem_bo bo; | |||||
int i, dmabuf, read_sync_file, write_sync_file; | |||||
int write_timeline = -1, read_timelines[32]; | |||||
@@ -459,6 +496,7 @@ static void test_import_multiple(int fd, bool write) | |||||
igt_assert(!sync_file_busy(read_sync_file)); | |||||
igt_assert(!dmabuf_busy(dmabuf, DMA_BUF_SYNC_WRITE)); | |||||
igt_assert(!sync_file_busy(write_sync_file)); | |||||
+#endif | |||||
} | |||||
igt_main |