sync_debug.h 2.2 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/spinlock.h>
  16. #include <linux/dma-fence.h>
  17. #include <linux/sync_file.h>
  18. #include <uapi/linux/sync_file.h>
  19. /**
  20. * struct sync_timeline - sync object
  21. * @kref: reference count on fence.
  22. * @name: name of the sync_timeline. Useful for debugging
  23. * @child_list_head: list of children sync_pts for this sync_timeline
  24. * @child_list_lock: lock protecting @child_list_head and fence.status
  25. * @active_list_head: list of active (unsignaled/errored) sync_pts
  26. * @sync_timeline_list: membership in global sync_timeline_list
  27. */
  28. struct sync_timeline {
  29. struct kref kref;
  30. char name[32];
  31. /* protected by child_list_lock */
  32. u64 context;
  33. int value;
  34. struct list_head child_list_head;
  35. spinlock_t child_list_lock;
  36. struct list_head active_list_head;
  37. struct list_head sync_timeline_list;
  38. };
  39. static inline struct sync_timeline *dma_fence_parent(struct dma_fence *fence)
  40. {
  41. return container_of(fence->lock, struct sync_timeline, child_list_lock);
  42. }
  43. /**
  44. * struct sync_pt - sync_pt object
  45. * @base: base fence object
  46. * @child_list: sync timeline child's list
  47. * @active_list: sync timeline active child's list
  48. */
  49. struct sync_pt {
  50. struct dma_fence base;
  51. struct list_head child_list;
  52. struct list_head active_list;
  53. };
  54. #ifdef CONFIG_SW_SYNC
  55. extern const struct file_operations sw_sync_debugfs_fops;
  56. void sync_timeline_debug_add(struct sync_timeline *obj);
  57. void sync_timeline_debug_remove(struct sync_timeline *obj);
  58. void sync_file_debug_add(struct sync_file *fence);
  59. void sync_file_debug_remove(struct sync_file *fence);
  60. void sync_dump(void);
  61. #else
  62. # define sync_timeline_debug_add(obj)
  63. # define sync_timeline_debug_remove(obj)
  64. # define sync_file_debug_add(fence)
  65. # define sync_file_debug_remove(fence)
  66. # define sync_dump()
  67. #endif
  68. #endif /* _LINUX_SYNC_H */