sync_debug.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Sync File validation framework and debug infomation
  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. #ifndef _LINUX_SYNC_H
  13. #define _LINUX_SYNC_H
  14. #include <linux/list.h>
  15. #include <linux/rbtree.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/fence.h>
  18. #include <linux/sync_file.h>
  19. #include <uapi/linux/sync_file.h>
  20. /**
  21. * struct sync_timeline - sync object
  22. * @kref: reference count on fence.
  23. * @name: name of the sync_timeline. Useful for debugging
  24. * @lock: lock protecting @pt_list and @value
  25. * @pt_tree: rbtree of active (unsignaled/errored) sync_pts
  26. * @pt_list: list of active (unsignaled/errored) sync_pts
  27. * @sync_timeline_list: membership in global sync_timeline_list
  28. */
  29. struct sync_timeline {
  30. struct kref kref;
  31. char name[32];
  32. /* protected by lock */
  33. u64 context;
  34. int value;
  35. struct rb_root pt_tree;
  36. struct list_head pt_list;
  37. spinlock_t lock;
  38. struct list_head sync_timeline_list;
  39. };
  40. static inline struct sync_timeline *fence_parent(struct fence *fence)
  41. {
  42. return container_of(fence->lock, struct sync_timeline, lock);
  43. }
  44. /**
  45. * struct sync_pt - sync_pt object
  46. * @base: base fence object
  47. * @link: link on the sync timeline's list
  48. * @node: node in the sync timeline's tree
  49. */
  50. struct sync_pt {
  51. struct fence base;
  52. struct list_head link;
  53. struct rb_node node;
  54. };
  55. #ifdef CONFIG_SW_SYNC
  56. extern const struct file_operations sw_sync_debugfs_fops;
  57. void sync_timeline_debug_add(struct sync_timeline *obj);
  58. void sync_timeline_debug_remove(struct sync_timeline *obj);
  59. void sync_file_debug_add(struct sync_file *fence);
  60. void sync_file_debug_remove(struct sync_file *fence);
  61. void sync_dump(void);
  62. #else
  63. # define sync_timeline_debug_add(obj)
  64. # define sync_timeline_debug_remove(obj)
  65. # define sync_file_debug_add(fence)
  66. # define sync_file_debug_remove(fence)
  67. # define sync_dump()
  68. #endif
  69. #endif /* _LINUX_SYNC_H */