Skip to content

Commit ca25fe5

Browse files
Christian Königalexdeucher
authored andcommitted
dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace
The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now. Optimize the handling by replacing a signaled fence when adding a new shared one. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171114142436.1360-2-christian.koenig@amd.com
1 parent 4d9c62e commit ca25fe5

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎drivers/dma-buf/reservation.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
104104
struct reservation_object_list *fobj,
105105
struct dma_fence *fence)
106106
{
107-
u32 i;
107+
struct dma_fence *signaled = NULL;
108+
u32 i, signaled_idx;
108109

109110
dma_fence_get(fence);
110111

@@ -126,17 +127,28 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
126127
dma_fence_put(old_fence);
127128
return;
128129
}
130+
131+
if (!signaled && dma_fence_is_signaled(old_fence)) {
132+
signaled = old_fence;
133+
signaled_idx = i;
134+
}
129135
}
130136

131137
/*
132138
* memory barrier is added by write_seqcount_begin,
133139
* fobj->shared_count is protected by this lock too
134140
*/
135-
RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence);
136-
fobj->shared_count++;
141+
if (signaled) {
142+
RCU_INIT_POINTER(fobj->shared[signaled_idx], fence);
143+
} else {
144+
RCU_INIT_POINTER(fobj->shared[fobj->shared_count], fence);
145+
fobj->shared_count++;
146+
}
137147

138148
write_seqcount_end(&obj->seq);
139149
preempt_enable();
150+
151+
dma_fence_put(signaled);
140152
}
141153

142154
static void

0 commit comments

Comments
 (0)