Commit 0a42016d authored by Christian König's avatar Christian König

dma-buf: use the new iterator in dma_resv_poll

Simplify the code a bit.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211005113742.1101-10-christian.koenig@amd.com
parent 63639d01
...@@ -209,19 +209,14 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb) ...@@ -209,19 +209,14 @@ static void dma_buf_poll_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
dma_fence_put(fence); dma_fence_put(fence);
} }
static bool dma_buf_poll_shared(struct dma_resv *resv, static bool dma_buf_poll_add_cb(struct dma_resv *resv, bool write,
struct dma_buf_poll_cb_t *dcb) struct dma_buf_poll_cb_t *dcb)
{ {
struct dma_resv_list *fobj = dma_resv_shared_list(resv); struct dma_resv_iter cursor;
struct dma_fence *fence; struct dma_fence *fence;
int i, r; int r;
if (!fobj)
return false;
for (i = 0; i < fobj->shared_count; ++i) { dma_resv_for_each_fence(&cursor, resv, write, fence) {
fence = rcu_dereference_protected(fobj->shared[i],
dma_resv_held(resv));
dma_fence_get(fence); dma_fence_get(fence);
r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb); r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
if (!r) if (!r)
...@@ -232,24 +227,6 @@ static bool dma_buf_poll_shared(struct dma_resv *resv, ...@@ -232,24 +227,6 @@ static bool dma_buf_poll_shared(struct dma_resv *resv,
return false; return false;
} }
static bool dma_buf_poll_excl(struct dma_resv *resv,
struct dma_buf_poll_cb_t *dcb)
{
struct dma_fence *fence = dma_resv_excl_fence(resv);
int r;
if (!fence)
return false;
dma_fence_get(fence);
r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
if (!r)
return true;
dma_fence_put(fence);
return false;
}
static __poll_t dma_buf_poll(struct file *file, poll_table *poll) static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
{ {
struct dma_buf *dmabuf; struct dma_buf *dmabuf;
...@@ -282,8 +259,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) ...@@ -282,8 +259,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
spin_unlock_irq(&dmabuf->poll.lock); spin_unlock_irq(&dmabuf->poll.lock);
if (events & EPOLLOUT) { if (events & EPOLLOUT) {
if (!dma_buf_poll_shared(resv, dcb) && if (!dma_buf_poll_add_cb(resv, true, dcb))
!dma_buf_poll_excl(resv, dcb))
/* No callback queued, wake up any other waiters */ /* No callback queued, wake up any other waiters */
dma_buf_poll_cb(NULL, &dcb->cb); dma_buf_poll_cb(NULL, &dcb->cb);
else else
...@@ -303,7 +279,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) ...@@ -303,7 +279,7 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
spin_unlock_irq(&dmabuf->poll.lock); spin_unlock_irq(&dmabuf->poll.lock);
if (events & EPOLLIN) { if (events & EPOLLIN) {
if (!dma_buf_poll_excl(resv, dcb)) if (!dma_buf_poll_add_cb(resv, false, dcb))
/* No callback queued, wake up any other waiters */ /* No callback queued, wake up any other waiters */
dma_buf_poll_cb(NULL, &dcb->cb); dma_buf_poll_cb(NULL, &dcb->cb);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment