Skip to content

Commit 8735f16

Browse files
dma-buf: cleanup reservation_object_init/fini
They are not used that often and certainly not in a hot path. Make them normal functions instead of an inline. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/314480/
1 parent 5ed7191 commit 8735f16

File tree

2 files changed

+47
-44
lines changed

2 files changed

+47
-44
lines changed

drivers/dma-buf/reservation.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@ EXPORT_SYMBOL(reservation_seqcount_class);
5555
const char reservation_seqcount_string[] = "reservation_seqcount";
5656
EXPORT_SYMBOL(reservation_seqcount_string);
5757

58+
/**
59+
* reservation_object_init - initialize a reservation object
60+
* @obj: the reservation object
61+
*/
62+
void reservation_object_init(struct reservation_object *obj)
63+
{
64+
ww_mutex_init(&obj->lock, &reservation_ww_class);
65+
66+
__seqcount_init(&obj->seq, reservation_seqcount_string,
67+
&reservation_seqcount_class);
68+
RCU_INIT_POINTER(obj->fence, NULL);
69+
RCU_INIT_POINTER(obj->fence_excl, NULL);
70+
}
71+
EXPORT_SYMBOL(reservation_object_init);
72+
73+
/**
74+
* reservation_object_fini - destroys a reservation object
75+
* @obj: the reservation object
76+
*/
77+
void reservation_object_fini(struct reservation_object *obj)
78+
{
79+
int i;
80+
struct reservation_object_list *fobj;
81+
struct dma_fence *excl;
82+
83+
/*
84+
* This object should be dead and all references must have
85+
* been released to it, so no need to be protected with rcu.
86+
*/
87+
excl = rcu_dereference_protected(obj->fence_excl, 1);
88+
if (excl)
89+
dma_fence_put(excl);
90+
91+
fobj = rcu_dereference_protected(obj->fence, 1);
92+
if (fobj) {
93+
for (i = 0; i < fobj->shared_count; ++i)
94+
dma_fence_put(rcu_dereference_protected(fobj->shared[i], 1));
95+
96+
kfree(fobj);
97+
}
98+
99+
ww_mutex_destroy(&obj->lock);
100+
}
101+
EXPORT_SYMBOL(reservation_object_fini);
102+
58103
/**
59104
* reservation_object_reserve_shared - Reserve space to add shared fences to
60105
* a reservation_object.

include/linux/reservation.h

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -81,50 +81,6 @@ struct reservation_object {
8181
#define reservation_object_assert_held(obj) \
8282
lockdep_assert_held(&(obj)->lock.base)
8383

84-
/**
85-
* reservation_object_init - initialize a reservation object
86-
* @obj: the reservation object
87-
*/
88-
static inline void
89-
reservation_object_init(struct reservation_object *obj)
90-
{
91-
ww_mutex_init(&obj->lock, &reservation_ww_class);
92-
93-
__seqcount_init(&obj->seq, reservation_seqcount_string, &reservation_seqcount_class);
94-
RCU_INIT_POINTER(obj->fence, NULL);
95-
RCU_INIT_POINTER(obj->fence_excl, NULL);
96-
}
97-
98-
/**
99-
* reservation_object_fini - destroys a reservation object
100-
* @obj: the reservation object
101-
*/
102-
static inline void
103-
reservation_object_fini(struct reservation_object *obj)
104-
{
105-
int i;
106-
struct reservation_object_list *fobj;
107-
struct dma_fence *excl;
108-
109-
/*
110-
* This object should be dead and all references must have
111-
* been released to it, so no need to be protected with rcu.
112-
*/
113-
excl = rcu_dereference_protected(obj->fence_excl, 1);
114-
if (excl)
115-
dma_fence_put(excl);
116-
117-
fobj = rcu_dereference_protected(obj->fence, 1);
118-
if (fobj) {
119-
for (i = 0; i < fobj->shared_count; ++i)
120-
dma_fence_put(rcu_dereference_protected(fobj->shared[i], 1));
121-
122-
kfree(fobj);
123-
}
124-
125-
ww_mutex_destroy(&obj->lock);
126-
}
127-
12884
/**
12985
* reservation_object_get_list - get the reservation object's
13086
* shared fence list, with update-side lock held
@@ -271,6 +227,8 @@ reservation_object_get_excl_rcu(struct reservation_object *obj)
271227
return fence;
272228
}
273229

230+
void reservation_object_init(struct reservation_object *obj);
231+
void reservation_object_fini(struct reservation_object *obj);
274232
int reservation_object_reserve_shared(struct reservation_object *obj,
275233
unsigned int num_fences);
276234
void reservation_object_add_shared_fence(struct reservation_object *obj,

0 commit comments

Comments
 (0)