diff options
author | Gustavo Padovan | 2016-06-10 14:09:36 -0500 |
---|---|---|
committer | Dmitry Shmidt | 2017-01-17 16:28:00 -0600 |
commit | d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1 (patch) | |
tree | 8d28229412eb8edf4bb4906ce5a94e38a0e0d1d9 /libsync | |
parent | 60c763ed52004a3c2330fd8ab7c5b2b6968e7822 (diff) | |
download | platform-system-core-d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1.tar.gz platform-system-core-d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1.tar.xz platform-system-core-d6bbc5de66fc7ac51773bc92d6a48a94e622f9b1.zip |
libsync: move kernel headers for sync ioctls to sync.h
This patch moves the legacy API to the internal sync.h header
and add documentation to it.
Test: Sync unit tests still passes.
Change-Id: I9b17eb23af30043b3df5fb9e857affad68ba8521
Diffstat (limited to 'libsync')
-rw-r--r-- | libsync/include/sync/sync.h | 51 | ||||
-rw-r--r-- | libsync/sync.c | 20 |
2 files changed, 54 insertions, 17 deletions
diff --git a/libsync/include/sync/sync.h b/libsync/include/sync/sync.h index 2e5d82f15..60989f2e3 100644 --- a/libsync/include/sync/sync.h +++ b/libsync/include/sync/sync.h | |||
@@ -22,9 +22,16 @@ | |||
22 | #include <sys/cdefs.h> | 22 | #include <sys/cdefs.h> |
23 | #include <stdint.h> | 23 | #include <stdint.h> |
24 | 24 | ||
25 | #include <linux/types.h> | ||
26 | |||
25 | __BEGIN_DECLS | 27 | __BEGIN_DECLS |
26 | 28 | ||
27 | // XXX: These structs are copied from the header "linux/sync.h". | 29 | struct sync_legacy_merge_data { |
30 | int32_t fd2; | ||
31 | char name[32]; | ||
32 | int32_t fence; | ||
33 | }; | ||
34 | |||
28 | struct sync_fence_info_data { | 35 | struct sync_fence_info_data { |
29 | uint32_t len; | 36 | uint32_t len; |
30 | char name[32]; | 37 | char name[32]; |
@@ -41,6 +48,48 @@ struct sync_pt_info { | |||
41 | uint8_t driver_data[0]; | 48 | uint8_t driver_data[0]; |
42 | }; | 49 | }; |
43 | 50 | ||
51 | #define SYNC_IOC_MAGIC '>' | ||
52 | |||
53 | /** | ||
54 | * DOC: SYNC_IOC_LEGACY_WAIT - wait for a fence to signal | ||
55 | * | ||
56 | * pass timeout in milliseconds. Waits indefinitely timeout < 0. | ||
57 | * | ||
58 | * This is the legacy version of the Sync API before the de-stage that happened | ||
59 | * on Linux kernel 4.7. | ||
60 | */ | ||
61 | #define SYNC_IOC_LEGACY_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) | ||
62 | |||
63 | /** | ||
64 | * DOC: SYNC_IOC_MERGE - merge two fences | ||
65 | * | ||
66 | * Takes a struct sync_merge_data. Creates a new fence containing copies of | ||
67 | * the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the | ||
68 | * new fence's fd in sync_merge_data.fence | ||
69 | * | ||
70 | * This is the legacy version of the Sync API before the de-stage that happened | ||
71 | * on Linux kernel 4.7. | ||
72 | */ | ||
73 | #define SYNC_IOC_LEGACY_MERGE _IOWR(SYNC_IOC_MAGIC, 1, \ | ||
74 | struct sync_legacy_merge_data) | ||
75 | |||
76 | /** | ||
77 | * DOC: SYNC_IOC_LEGACY_FENCE_INFO - get detailed information on a fence | ||
78 | * | ||
79 | * Takes a struct sync_fence_info_data with extra space allocated for pt_info. | ||
80 | * Caller should write the size of the buffer into len. On return, len is | ||
81 | * updated to reflect the total size of the sync_fence_info_data including | ||
82 | * pt_info. | ||
83 | * | ||
84 | * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence. | ||
85 | * To iterate over the sync_pt_infos, use the sync_pt_info.len field. | ||
86 | * | ||
87 | * This is the legacy version of the Sync API before the de-stage that happened | ||
88 | * on Linux kernel 4.7. | ||
89 | */ | ||
90 | #define SYNC_IOC_LEGACY_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\ | ||
91 | struct sync_fence_info_data) | ||
92 | |||
44 | /* timeout in msecs */ | 93 | /* timeout in msecs */ |
45 | int sync_wait(int fd, int timeout); | 94 | int sync_wait(int fd, int timeout); |
46 | int sync_merge(const char *name, int fd1, int fd2); | 95 | int sync_merge(const char *name, int fd1, int fd2); |
diff --git a/libsync/sync.c b/libsync/sync.c index 6281b205c..fff62e77c 100644 --- a/libsync/sync.c +++ b/libsync/sync.c | |||
@@ -27,18 +27,6 @@ | |||
27 | 27 | ||
28 | #include <sync/sync.h> | 28 | #include <sync/sync.h> |
29 | 29 | ||
30 | // The sync code is undergoing a major change. Add enough in to get | ||
31 | // everything to compile wih the latest uapi headers. | ||
32 | struct sync_merge_data { | ||
33 | int32_t fd2; | ||
34 | char name[32]; | ||
35 | int32_t fence; | ||
36 | }; | ||
37 | |||
38 | #define SYNC_IOC_MAGIC '>' | ||
39 | #define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) | ||
40 | #define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) | ||
41 | #define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data) | ||
42 | 30 | ||
43 | struct sw_sync_create_fence_data { | 31 | struct sw_sync_create_fence_data { |
44 | __u32 value; | 32 | __u32 value; |
@@ -54,18 +42,18 @@ int sync_wait(int fd, int timeout) | |||
54 | { | 42 | { |
55 | __s32 to = timeout; | 43 | __s32 to = timeout; |
56 | 44 | ||
57 | return ioctl(fd, SYNC_IOC_WAIT, &to); | 45 | return ioctl(fd, SYNC_IOC_LEGACY_WAIT, &to); |
58 | } | 46 | } |
59 | 47 | ||
60 | int sync_merge(const char *name, int fd1, int fd2) | 48 | int sync_merge(const char *name, int fd1, int fd2) |
61 | { | 49 | { |
62 | struct sync_merge_data data; | 50 | struct sync_legacy_merge_data data; |
63 | int err; | 51 | int err; |
64 | 52 | ||
65 | data.fd2 = fd2; | 53 | data.fd2 = fd2; |
66 | strlcpy(data.name, name, sizeof(data.name)); | 54 | strlcpy(data.name, name, sizeof(data.name)); |
67 | 55 | ||
68 | err = ioctl(fd1, SYNC_IOC_MERGE, &data); | 56 | err = ioctl(fd1, SYNC_IOC_LEGACY_MERGE, &data); |
69 | if (err < 0) | 57 | if (err < 0) |
70 | return err; | 58 | return err; |
71 | 59 | ||
@@ -82,7 +70,7 @@ struct sync_fence_info_data *sync_fence_info(int fd) | |||
82 | return NULL; | 70 | return NULL; |
83 | 71 | ||
84 | info->len = 4096; | 72 | info->len = 4096; |
85 | err = ioctl(fd, SYNC_IOC_FENCE_INFO, info); | 73 | err = ioctl(fd, SYNC_IOC_LEGACY_FENCE_INFO, info); |
86 | if (err < 0) { | 74 | if (err < 0) { |
87 | free(info); | 75 | free(info); |
88 | return NULL; | 76 | return NULL; |