Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 1 | /* |
Gustavo Padovan | e912c88 | 2016-08-11 12:26:42 -0300 | [diff] [blame] | 2 | * Sync File validation framework and debug infomation |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2012 Google, Inc. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #ifndef _LINUX_SYNC_H |
| 14 | #define _LINUX_SYNC_H |
| 15 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 16 | #include <linux/list.h> |
Chris Wilson | db76740 | 2017-06-29 22:12:53 +0100 | [diff] [blame] | 17 | #include <linux/rbtree.h> |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 18 | #include <linux/spinlock.h> |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 19 | #include <linux/fence.h> |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 20 | |
Gustavo Padovan | 460bfc4 | 2016-04-28 10:46:57 -0300 | [diff] [blame] | 21 | #include <linux/sync_file.h> |
| 22 | #include <uapi/linux/sync_file.h> |
Colin Cross | 64907b9 | 2014-02-17 13:58:32 -0800 | [diff] [blame] | 23 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 24 | /** |
| 25 | * struct sync_timeline - sync object |
Erik Gilling | c5b86b7 | 2013-02-28 16:43:11 -0800 | [diff] [blame] | 26 | * @kref: reference count on fence. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 27 | * @name: name of the sync_timeline. Useful for debugging |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 28 | * @lock: lock protecting @pt_list and @value |
Chris Wilson | db76740 | 2017-06-29 22:12:53 +0100 | [diff] [blame] | 29 | * @pt_tree: rbtree of active (unsignaled/errored) sync_pts |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 30 | * @pt_list: list of active (unsignaled/errored) sync_pts |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 31 | * @sync_timeline_list: membership in global sync_timeline_list |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 32 | */ |
| 33 | struct sync_timeline { |
Erik Gilling | c5b86b7 | 2013-02-28 16:43:11 -0800 | [diff] [blame] | 34 | struct kref kref; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 35 | char name[32]; |
| 36 | |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 37 | /* protected by lock */ |
Linus Torvalds | 731c7d3 | 2016-08-01 21:44:08 -0400 | [diff] [blame] | 38 | u64 context; |
| 39 | int value; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 40 | |
Chris Wilson | db76740 | 2017-06-29 22:12:53 +0100 | [diff] [blame] | 41 | struct rb_root pt_tree; |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 42 | struct list_head pt_list; |
| 43 | spinlock_t lock; |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 44 | |
| 45 | struct list_head sync_timeline_list; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 46 | }; |
| 47 | |
Gustavo Padovan | b55b54b | 2016-01-21 10:49:21 -0200 | [diff] [blame] | 48 | static inline struct sync_timeline *fence_parent(struct fence *fence) |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 49 | { |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 50 | return container_of(fence->lock, struct sync_timeline, lock); |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 51 | } |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 52 | |
Gustavo Padovan | 0431b90 | 2016-05-31 16:59:04 -0300 | [diff] [blame] | 53 | /** |
| 54 | * struct sync_pt - sync_pt object |
| 55 | * @base: base fence object |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 56 | * @link: link on the sync timeline's list |
Chris Wilson | db76740 | 2017-06-29 22:12:53 +0100 | [diff] [blame] | 57 | * @node: node in the sync timeline's tree |
Gustavo Padovan | 0431b90 | 2016-05-31 16:59:04 -0300 | [diff] [blame] | 58 | */ |
| 59 | struct sync_pt { |
| 60 | struct fence base; |
Chris Wilson | e82ecb2 | 2017-06-29 22:05:32 +0100 | [diff] [blame] | 61 | struct list_head link; |
Chris Wilson | db76740 | 2017-06-29 22:12:53 +0100 | [diff] [blame] | 62 | struct rb_node node; |
Gustavo Padovan | 0431b90 | 2016-05-31 16:59:04 -0300 | [diff] [blame] | 63 | }; |
| 64 | |
Gustavo Padovan | b1f6560 | 2016-05-31 16:59:13 -0300 | [diff] [blame] | 65 | #ifdef CONFIG_SW_SYNC |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 66 | |
Gustavo Padovan | 1867a23 | 2016-05-31 16:59:05 -0300 | [diff] [blame] | 67 | extern const struct file_operations sw_sync_debugfs_fops; |
| 68 | |
Joe Perches | d30649a | 2015-08-10 14:51:16 -0700 | [diff] [blame] | 69 | void sync_timeline_debug_add(struct sync_timeline *obj); |
| 70 | void sync_timeline_debug_remove(struct sync_timeline *obj); |
Gustavo Padovan | d7fdb0a | 2016-01-21 10:49:19 -0200 | [diff] [blame] | 71 | void sync_file_debug_add(struct sync_file *fence); |
| 72 | void sync_file_debug_remove(struct sync_file *fence); |
Joe Perches | d30649a | 2015-08-10 14:51:16 -0700 | [diff] [blame] | 73 | void sync_dump(void); |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 74 | |
| 75 | #else |
| 76 | # define sync_timeline_debug_add(obj) |
| 77 | # define sync_timeline_debug_remove(obj) |
Gustavo Padovan | d7fdb0a | 2016-01-21 10:49:19 -0200 | [diff] [blame] | 78 | # define sync_file_debug_add(fence) |
| 79 | # define sync_file_debug_remove(fence) |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 80 | # define sync_dump() |
| 81 | #endif |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 82 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 83 | #endif /* _LINUX_SYNC_H */ |