18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Sync File validation framework and debug infomation 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Google, Inc. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 78c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 88c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 98c2ecf20Sopenharmony_ci * GNU General Public License for more details. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef _LINUX_SYNC_H 148c2ecf20Sopenharmony_ci#define _LINUX_SYNC_H 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/list.h> 178c2ecf20Sopenharmony_ci#include <linux/rbtree.h> 188c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 198c2ecf20Sopenharmony_ci#include <linux/dma-fence.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include <linux/sync_file.h> 228c2ecf20Sopenharmony_ci#include <uapi/linux/sync_file.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/** 258c2ecf20Sopenharmony_ci * struct sync_timeline - sync object 268c2ecf20Sopenharmony_ci * @kref: reference count on fence. 278c2ecf20Sopenharmony_ci * @name: name of the sync_timeline. Useful for debugging 288c2ecf20Sopenharmony_ci * @lock: lock protecting @pt_list and @value 298c2ecf20Sopenharmony_ci * @pt_tree: rbtree of active (unsignaled/errored) sync_pts 308c2ecf20Sopenharmony_ci * @pt_list: list of active (unsignaled/errored) sync_pts 318c2ecf20Sopenharmony_ci * @sync_timeline_list: membership in global sync_timeline_list 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_cistruct sync_timeline { 348c2ecf20Sopenharmony_ci struct kref kref; 358c2ecf20Sopenharmony_ci char name[32]; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci /* protected by lock */ 388c2ecf20Sopenharmony_ci u64 context; 398c2ecf20Sopenharmony_ci int value; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci struct rb_root pt_tree; 428c2ecf20Sopenharmony_ci struct list_head pt_list; 438c2ecf20Sopenharmony_ci spinlock_t lock; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci struct list_head sync_timeline_list; 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline struct sync_timeline *dma_fence_parent(struct dma_fence *fence) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci return container_of(fence->lock, struct sync_timeline, lock); 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/** 548c2ecf20Sopenharmony_ci * struct sync_pt - sync_pt object 558c2ecf20Sopenharmony_ci * @base: base fence object 568c2ecf20Sopenharmony_ci * @link: link on the sync timeline's list 578c2ecf20Sopenharmony_ci * @node: node in the sync timeline's tree 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_cistruct sync_pt { 608c2ecf20Sopenharmony_ci struct dma_fence base; 618c2ecf20Sopenharmony_ci struct list_head link; 628c2ecf20Sopenharmony_ci struct rb_node node; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ciextern const struct file_operations sw_sync_debugfs_fops; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_civoid sync_timeline_debug_add(struct sync_timeline *obj); 688c2ecf20Sopenharmony_civoid sync_timeline_debug_remove(struct sync_timeline *obj); 698c2ecf20Sopenharmony_civoid sync_file_debug_add(struct sync_file *fence); 708c2ecf20Sopenharmony_civoid sync_file_debug_remove(struct sync_file *fence); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#endif /* _LINUX_SYNC_H */ 73