diff options
author | Christian König <christian.koenig@amd.com> | 2019-06-26 17:31:46 +0300 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2019-06-28 13:55:06 +0300 |
commit | 8735f16803f00f5efca7738afe3b9a304b539181 (patch) | |
tree | 9866af24d282bbc97f03497eb9c0b1ad750fd725 /drivers/dma-buf | |
parent | 5ed7191dd97b212887a9cb4715c2ef09ea50ae47 (diff) | |
download | linux-8735f16803f00f5efca7738afe3b9a304b539181.tar.xz |
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 <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/314480/
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r-- | drivers/dma-buf/reservation.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c index 4447e13d1e89..a6ac2b3a0185 100644 --- a/drivers/dma-buf/reservation.c +++ b/drivers/dma-buf/reservation.c @@ -56,6 +56,51 @@ const char reservation_seqcount_string[] = "reservation_seqcount"; EXPORT_SYMBOL(reservation_seqcount_string); /** + * reservation_object_init - initialize a reservation object + * @obj: the reservation object + */ +void reservation_object_init(struct reservation_object *obj) +{ + ww_mutex_init(&obj->lock, &reservation_ww_class); + + __seqcount_init(&obj->seq, reservation_seqcount_string, + &reservation_seqcount_class); + RCU_INIT_POINTER(obj->fence, NULL); + RCU_INIT_POINTER(obj->fence_excl, NULL); +} +EXPORT_SYMBOL(reservation_object_init); + +/** + * reservation_object_fini - destroys a reservation object + * @obj: the reservation object + */ +void reservation_object_fini(struct reservation_object *obj) +{ + int i; + struct reservation_object_list *fobj; + struct dma_fence *excl; + + /* + * This object should be dead and all references must have + * been released to it, so no need to be protected with rcu. + */ + excl = rcu_dereference_protected(obj->fence_excl, 1); + if (excl) + dma_fence_put(excl); + + fobj = rcu_dereference_protected(obj->fence, 1); + if (fobj) { + for (i = 0; i < fobj->shared_count; ++i) + dma_fence_put(rcu_dereference_protected(fobj->shared[i], 1)); + + kfree(fobj); + } + + ww_mutex_destroy(&obj->lock); +} +EXPORT_SYMBOL(reservation_object_fini); + +/** * reservation_object_reserve_shared - Reserve space to add shared fences to * a reservation_object. * @obj: reservation object |