summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-08-17 10:47:34 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2019-08-17 13:03:00 -0400
commitf86a802bf3a7c28e4c4ea032fa2e61398dbccd5d (patch)
tree9461feb021ab3950edcb90efe4c2936f09c67bf0
parent4fe3997a68f3300c73adc196ff33a952febe6974 (diff)
dma-fence: Avoid list_del during fence->cb_list iteration
Before we notify the fence signal callback, we remove the cb from the list. However, since we are processing the entire list from underneath the spinlock, we do not need to individual delete each element, but can simply reset the link and the entire list. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Christian König <christian.koenig@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190817144736.7826-4-chris@chris-wilson.co.uk
-rw-r--r--drivers/dma-buf/dma-fence.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 8025a891d3e9..ff0cd6eae766 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -149,9 +149,12 @@ int dma_fence_signal_locked(struct dma_fence *fence)
149 trace_dma_fence_signaled(fence); 149 trace_dma_fence_signaled(fence);
150 } 150 }
151 151
152 list_for_each_entry_safe(cur, tmp, &fence->cb_list, node) { 152 if (!list_empty(&fence->cb_list)) {
153 list_del_init(&cur->node); 153 list_for_each_entry_safe(cur, tmp, &fence->cb_list, node) {
154 cur->func(fence, cur); 154 INIT_LIST_HEAD(&cur->node);
155 cur->func(fence, cur);
156 }
157 INIT_LIST_HEAD(&fence->cb_list);
155 } 158 }
156 return ret; 159 return ret;
157} 160}