diff options
author | Maarten Lankhorst <maarten.lankhorst@canonical.com> | 2014-07-01 06:57:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-08 16:37:35 -0400 |
commit | 04a5faa8cbe5a8eaf152cb88959ba6360c26e702 (patch) | |
tree | fee24a356ead0c38b98d8c3d3b671cd0dd981714 /include/linux/reservation.h | |
parent | 9b495a5887994a6d74d5c261d012083a92b94738 (diff) |
reservation: update api and add some helpers
Move the list of shared fences to a struct, and return it in
reservation_object_get_list().
Add reservation_object_get_excl to get the exclusive fence.
Add reservation_object_reserve_shared(), which reserves space
in the reservation_object for 1 more shared fence.
reservation_object_add_shared_fence() and
reservation_object_add_excl_fence() are used to assign a new
fence to a reservation_object pointer, to complete a reservation.
Changes since v1:
- Add reservation_object_get_excl, reorder code a bit.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/reservation.h')
-rw-r--r-- | include/linux/reservation.h | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/include/linux/reservation.h b/include/linux/reservation.h index f3f57460a205..2affe67dea6e 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h | |||
@@ -45,36 +45,78 @@ | |||
45 | 45 | ||
46 | extern struct ww_class reservation_ww_class; | 46 | extern struct ww_class reservation_ww_class; |
47 | 47 | ||
48 | struct reservation_object_list { | ||
49 | u32 shared_count, shared_max; | ||
50 | struct fence *shared[]; | ||
51 | }; | ||
52 | |||
48 | struct reservation_object { | 53 | struct reservation_object { |
49 | struct ww_mutex lock; | 54 | struct ww_mutex lock; |
50 | 55 | ||
51 | struct fence *fence_excl; | 56 | struct fence *fence_excl; |
52 | struct fence **fence_shared; | 57 | struct reservation_object_list *fence; |
53 | u32 fence_shared_count, fence_shared_max; | 58 | struct reservation_object_list *staged; |
54 | }; | 59 | }; |
55 | 60 | ||
61 | #define reservation_object_assert_held(obj) \ | ||
62 | lockdep_assert_held(&(obj)->lock.base) | ||
63 | |||
56 | static inline void | 64 | static inline void |
57 | reservation_object_init(struct reservation_object *obj) | 65 | reservation_object_init(struct reservation_object *obj) |
58 | { | 66 | { |
59 | ww_mutex_init(&obj->lock, &reservation_ww_class); | 67 | ww_mutex_init(&obj->lock, &reservation_ww_class); |
60 | 68 | ||
61 | obj->fence_shared_count = obj->fence_shared_max = 0; | ||
62 | obj->fence_shared = NULL; | ||
63 | obj->fence_excl = NULL; | 69 | obj->fence_excl = NULL; |
70 | obj->fence = NULL; | ||
71 | obj->staged = NULL; | ||
64 | } | 72 | } |
65 | 73 | ||
66 | static inline void | 74 | static inline void |
67 | reservation_object_fini(struct reservation_object *obj) | 75 | reservation_object_fini(struct reservation_object *obj) |
68 | { | 76 | { |
69 | int i; | 77 | int i; |
78 | struct reservation_object_list *fobj; | ||
70 | 79 | ||
80 | /* | ||
81 | * This object should be dead and all references must have | ||
82 | * been released to it. | ||
83 | */ | ||
71 | if (obj->fence_excl) | 84 | if (obj->fence_excl) |
72 | fence_put(obj->fence_excl); | 85 | fence_put(obj->fence_excl); |
73 | for (i = 0; i < obj->fence_shared_count; ++i) | 86 | |
74 | fence_put(obj->fence_shared[i]); | 87 | fobj = obj->fence; |
75 | kfree(obj->fence_shared); | 88 | if (fobj) { |
89 | for (i = 0; i < fobj->shared_count; ++i) | ||
90 | fence_put(fobj->shared[i]); | ||
91 | |||
92 | kfree(fobj); | ||
93 | } | ||
94 | kfree(obj->staged); | ||
76 | 95 | ||
77 | ww_mutex_destroy(&obj->lock); | 96 | ww_mutex_destroy(&obj->lock); |
78 | } | 97 | } |
79 | 98 | ||
99 | static inline struct reservation_object_list * | ||
100 | reservation_object_get_list(struct reservation_object *obj) | ||
101 | { | ||
102 | reservation_object_assert_held(obj); | ||
103 | |||
104 | return obj->fence; | ||
105 | } | ||
106 | |||
107 | static inline struct fence * | ||
108 | reservation_object_get_excl(struct reservation_object *obj) | ||
109 | { | ||
110 | reservation_object_assert_held(obj); | ||
111 | |||
112 | return obj->fence_excl; | ||
113 | } | ||
114 | |||
115 | int reservation_object_reserve_shared(struct reservation_object *obj); | ||
116 | void reservation_object_add_shared_fence(struct reservation_object *obj, | ||
117 | struct fence *fence); | ||
118 | |||
119 | void reservation_object_add_excl_fence(struct reservation_object *obj, | ||
120 | struct fence *fence); | ||
121 | |||
80 | #endif /* _LINUX_RESERVATION_H */ | 122 | #endif /* _LINUX_RESERVATION_H */ |