提交 a35f2f34 编写于 作者: C Christian König 提交者: Alex Deucher

dma-buf: make returning the exclusive fence optional

Change reservation_object_get_fences_rcu to make the exclusive fence
pointer optional.

If not specified the exclusive fence is put into the fence array as
well.

This is helpful for a couple of cases where we need all fences in a
single array.
Reviewed-by: NChunming Zhou <david1.zhou@amd.com>
Acked-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: NChristian König <christian.koenig@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180110125341.3618-1-christian.koenig@amd.com
上级 c60c4af3
...@@ -374,8 +374,9 @@ EXPORT_SYMBOL(reservation_object_copy_fences); ...@@ -374,8 +374,9 @@ EXPORT_SYMBOL(reservation_object_copy_fences);
* @pshared: the array of shared fence ptrs returned (array is krealloc'd to * @pshared: the array of shared fence ptrs returned (array is krealloc'd to
* the required size, and must be freed by caller) * the required size, and must be freed by caller)
* *
* RETURNS * Retrieve all fences from the reservation object. If the pointer for the
* Zero or -errno * exclusive fence is not specified the fence is put into the array of the
* shared fences as well. Returns either zero or -ENOMEM.
*/ */
int reservation_object_get_fences_rcu(struct reservation_object *obj, int reservation_object_get_fences_rcu(struct reservation_object *obj,
struct dma_fence **pfence_excl, struct dma_fence **pfence_excl,
...@@ -389,8 +390,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, ...@@ -389,8 +390,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
do { do {
struct reservation_object_list *fobj; struct reservation_object_list *fobj;
unsigned seq; unsigned int i, seq;
unsigned int i; size_t sz = 0;
shared_count = i = 0; shared_count = i = 0;
...@@ -402,9 +403,14 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, ...@@ -402,9 +403,14 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
goto unlock; goto unlock;
fobj = rcu_dereference(obj->fence); fobj = rcu_dereference(obj->fence);
if (fobj) { if (fobj)
sz += sizeof(*shared) * fobj->shared_max;
if (!pfence_excl && fence_excl)
sz += sizeof(*shared);
if (sz) {
struct dma_fence **nshared; struct dma_fence **nshared;
size_t sz = sizeof(*shared) * fobj->shared_max;
nshared = krealloc(shared, sz, nshared = krealloc(shared, sz,
GFP_NOWAIT | __GFP_NOWARN); GFP_NOWAIT | __GFP_NOWARN);
...@@ -420,13 +426,19 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, ...@@ -420,13 +426,19 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
break; break;
} }
shared = nshared; shared = nshared;
shared_count = fobj->shared_count; shared_count = fobj ? fobj->shared_count : 0;
for (i = 0; i < shared_count; ++i) { for (i = 0; i < shared_count; ++i) {
shared[i] = rcu_dereference(fobj->shared[i]); shared[i] = rcu_dereference(fobj->shared[i]);
if (!dma_fence_get_rcu(shared[i])) if (!dma_fence_get_rcu(shared[i]))
break; break;
} }
if (!pfence_excl && fence_excl) {
shared[i] = fence_excl;
fence_excl = NULL;
++i;
++shared_count;
}
} }
if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) {
...@@ -448,7 +460,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj, ...@@ -448,7 +460,8 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
*pshared_count = shared_count; *pshared_count = shared_count;
*pshared = shared; *pshared = shared;
*pfence_excl = fence_excl; if (pfence_excl)
*pfence_excl = fence_excl;
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册