This makes the function much simpler since the complex retry logic is now handled elsewhere.
Signed-off-by: Christian König christian.koenig@amd.com --- drivers/dma-buf/dma-buf.c | 49 ++++----------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-)
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index b67fbf4e3705..4173f1f70ac1 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -207,15 +207,13 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
static __poll_t dma_buf_poll(struct file *file, poll_table *poll) { + struct dma_resv_cursor cursor; struct dma_buf_poll_cb_t *dcb; struct dma_buf *dmabuf; struct dma_resv *resv; - struct dma_resv_list *fobj; - struct dma_fence *fence_excl; - unsigned shared_count, seq; struct dma_fence *fence; __poll_t events; - int r, i; + int r;
dmabuf = file->private_data; if (!dmabuf || !dmabuf->resv) @@ -241,53 +239,14 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) if (!events) return 0;
-retry: - seq = read_seqcount_begin(&resv->seq); - rcu_read_lock(); - - fobj = rcu_dereference(resv->fence); - if (fobj && events & EPOLLOUT) - shared_count = fobj->shared_count; - else - shared_count = 0; - - for (i = 0; i < shared_count; ++i) { - fence = rcu_dereference(fobj->shared[i]); - fence = dma_fence_get_rcu(fence); - if (!fence || read_seqcount_retry(&resv->seq, seq)) { - /* Concurrent modify detected, force re-check */ - dma_fence_put(fence); - rcu_read_unlock(); - goto retry; - } - - r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); - if (!r) { - /* Callback queued */ - events = 0; - goto out; - } - dma_fence_put(fence); - } - - fence = dma_resv_excl_fence(resv); - if (fence) { - fence = dma_fence_get_rcu(fence); - if (!fence || read_seqcount_retry(&resv->seq, seq)) { - /* Concurrent modify detected, force re-check */ - dma_fence_put(fence); - rcu_read_unlock(); - goto retry; - - } - + dma_resv_for_each_fence_unlocked(resv, &cursor, events & EPOLLOUT, + fence) { r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); if (!r) { /* Callback queued */ events = 0; goto out; } - dma_fence_put(fence_excl); }
/* No callback queued, wake up any additional waiters. */