summaryrefslogtreecommitdiff
path: root/lib/sw_sync.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-12-19 15:00:03 +0000
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2017-12-27 12:44:27 +0200
commit4cd4cc4873fc1c916b6bf7b058b12294e16dfd98 (patch)
tree8297d56486efa0f6dcdd1abd4d76b6b0dc6abc5d /lib/sw_sync.c
parent6d27acafa3a2d80b6330e2380a3548bc98dcc3e5 (diff)
lib: Convert sw_sync to use sync_file uapi imported from the kernel
Similar to how we are now importing the drm uapi directly into igt, we also would like to have a copy of auxiliary uAPI such as sync_file. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/sw_sync.c')
-rw-r--r--lib/sw_sync.c59
1 files changed, 13 insertions, 46 deletions
diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index 9b36dd85..619049b3 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -33,6 +33,8 @@
#include <stdint.h>
#include <sys/ioctl.h>
+#include "sync_file.h"
+
#include "igt_debugfs.h"
#include "igt_kmod.h"
#include "sw_sync.h"
@@ -56,41 +58,6 @@ struct int_sync_create_fence_data {
#define INT_SYNC_IOC_CREATE_FENCE _IOWR(INT_SYNC_IOC_MAGIC, 0, struct int_sync_create_fence_data)
#define INT_SYNC_IOC_INC _IOW(INT_SYNC_IOC_MAGIC, 1, __u32)
-struct local_sync_merge_data {
- char name[32];
-
- __s32 fd2;
- __s32 fence;
-
- __u32 flags;
- __u32 pad;
-};
-
-struct local_sync_fence_info {
- char obj_name[32];
- char driver_name[32];
-
- __s32 status;
- __u32 flags;
-
- __u64 timestamp_ns;
-};
-
-struct local_sync_file_info {
- char name[32];
-
- __s32 status;
- __u32 flags;
- __u32 num_fences;
- __u32 pad;
-
- __u64 sync_fence_info;
-};
-
-#define UABI_SYNC_IOC_MAGIC '>'
-#define LOCAL_SYNC_IOC_MERGE _IOWR(UABI_SYNC_IOC_MAGIC, 3, struct local_sync_merge_data)
-#define LOCAL_SYNC_IOC_FILE_INFO _IOWR(UABI_SYNC_IOC_MAGIC, 4, struct local_sync_file_info)
-
static bool kernel_sw_sync_path(char *path, int length)
{
snprintf(path, length, "%s", "/dev/sw_sync");
@@ -159,9 +126,9 @@ void sw_sync_timeline_inc(int fd, uint32_t count)
int sync_fence_merge(int fd1, int fd2)
{
- struct local_sync_merge_data data = { .fd2 = fd2};
+ struct sync_merge_data data = { .fd2 = fd2};
- if (ioctl(fd1, LOCAL_SYNC_IOC_MERGE, &data))
+ if (ioctl(fd1, SYNC_IOC_MERGE, &data))
return -errno;
return data.fence;
@@ -192,9 +159,9 @@ int sync_fence_wait(int fd, int timeout)
int sync_fence_count(int fd)
{
- struct local_sync_file_info info = {};
+ struct sync_file_info info = {};
- if (ioctl(fd, LOCAL_SYNC_IOC_FILE_INFO, &info))
+ if (ioctl(fd, SYNC_IOC_FILE_INFO, &info))
return -errno;
return info.num_fences;
@@ -202,12 +169,12 @@ int sync_fence_count(int fd)
static int __sync_fence_count_status(int fd, int status)
{
- struct local_sync_file_info info = {};
- struct local_sync_fence_info *fence_info;
+ struct sync_file_info info = {};
+ struct sync_fence_info *fence_info;
int count;
int i;
- if (ioctl(fd, LOCAL_SYNC_IOC_FILE_INFO, &info))
+ if (ioctl(fd, SYNC_IOC_FILE_INFO, &info))
return -errno;
fence_info = calloc(info.num_fences, sizeof(*fence_info));
@@ -215,7 +182,7 @@ static int __sync_fence_count_status(int fd, int status)
return -ENOMEM;
info.sync_fence_info = to_user_pointer(fence_info);
- if (ioctl(fd, LOCAL_SYNC_IOC_FILE_INFO, &info)) {
+ if (ioctl(fd, SYNC_IOC_FILE_INFO, &info)) {
count = -errno;
} else {
count = 0;
@@ -239,13 +206,13 @@ int sync_fence_count_status(int fd, int status)
int sync_fence_status(int fence)
{
- struct local_sync_fence_info fence_info;
- struct local_sync_file_info file_info = {
+ struct sync_fence_info fence_info;
+ struct sync_file_info file_info = {
.sync_fence_info = to_user_pointer(&fence_info),
.num_fences = 1,
};
- if (ioctl(fence, LOCAL_SYNC_IOC_FILE_INFO, &file_info))
+ if (ioctl(fence, SYNC_IOC_FILE_INFO, &file_info))
return -errno;
if (file_info.num_fences != 1)