1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Sync File validation framework and debug infomation 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2012 Google, Inc. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, 7*4882a593Smuzhiyun * but WITHOUT ANY WARRANTY; without even the implied warranty of 8*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9*4882a593Smuzhiyun * GNU General Public License for more details. 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun */ 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun #ifndef _LINUX_SYNC_H 14*4882a593Smuzhiyun #define _LINUX_SYNC_H 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #include <linux/list.h> 17*4882a593Smuzhiyun #include <linux/rbtree.h> 18*4882a593Smuzhiyun #include <linux/spinlock.h> 19*4882a593Smuzhiyun #include <linux/dma-fence.h> 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun #include <linux/sync_file.h> 22*4882a593Smuzhiyun #include <uapi/linux/sync_file.h> 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun /** 25*4882a593Smuzhiyun * struct sync_timeline - sync object 26*4882a593Smuzhiyun * @kref: reference count on fence. 27*4882a593Smuzhiyun * @name: name of the sync_timeline. Useful for debugging 28*4882a593Smuzhiyun * @lock: lock protecting @pt_list and @value 29*4882a593Smuzhiyun * @pt_tree: rbtree of active (unsignaled/errored) sync_pts 30*4882a593Smuzhiyun * @pt_list: list of active (unsignaled/errored) sync_pts 31*4882a593Smuzhiyun * @sync_timeline_list: membership in global sync_timeline_list 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun struct sync_timeline { 34*4882a593Smuzhiyun struct kref kref; 35*4882a593Smuzhiyun char name[32]; 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun /* protected by lock */ 38*4882a593Smuzhiyun u64 context; 39*4882a593Smuzhiyun int value; 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun struct rb_root pt_tree; 42*4882a593Smuzhiyun struct list_head pt_list; 43*4882a593Smuzhiyun spinlock_t lock; 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun struct list_head sync_timeline_list; 46*4882a593Smuzhiyun }; 47*4882a593Smuzhiyun dma_fence_parent(struct dma_fence * fence)48*4882a593Smuzhiyunstatic inline struct sync_timeline *dma_fence_parent(struct dma_fence *fence) 49*4882a593Smuzhiyun { 50*4882a593Smuzhiyun return container_of(fence->lock, struct sync_timeline, lock); 51*4882a593Smuzhiyun } 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /** 54*4882a593Smuzhiyun * struct sync_pt - sync_pt object 55*4882a593Smuzhiyun * @base: base fence object 56*4882a593Smuzhiyun * @link: link on the sync timeline's list 57*4882a593Smuzhiyun * @node: node in the sync timeline's tree 58*4882a593Smuzhiyun */ 59*4882a593Smuzhiyun struct sync_pt { 60*4882a593Smuzhiyun struct dma_fence base; 61*4882a593Smuzhiyun struct list_head link; 62*4882a593Smuzhiyun struct rb_node node; 63*4882a593Smuzhiyun }; 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun extern const struct file_operations sw_sync_debugfs_fops; 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun #ifdef CONFIG_SW_SYNC_DEBUG 68*4882a593Smuzhiyun void sync_timeline_debug_add(struct sync_timeline *obj); 69*4882a593Smuzhiyun void sync_timeline_debug_remove(struct sync_timeline *obj); 70*4882a593Smuzhiyun void sync_file_debug_add(struct sync_file *fence); 71*4882a593Smuzhiyun void sync_file_debug_remove(struct sync_file *fence); 72*4882a593Smuzhiyun #else sync_timeline_debug_add(struct sync_timeline * obj)73*4882a593Smuzhiyunstatic inline void sync_timeline_debug_add(struct sync_timeline *obj) {} sync_timeline_debug_remove(struct sync_timeline * obj)74*4882a593Smuzhiyunstatic inline void sync_timeline_debug_remove(struct sync_timeline *obj) {} sync_file_debug_add(struct sync_file * fence)75*4882a593Smuzhiyunstatic inline void sync_file_debug_add(struct sync_file *fence) {} sync_file_debug_remove(struct sync_file * fence)76*4882a593Smuzhiyunstatic inline void sync_file_debug_remove(struct sync_file *fence) {} 77*4882a593Smuzhiyun #endif 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun #endif /* _LINUX_SYNC_H */ 80