Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1441632 > unrolled thread
| Started by | Gustavo Padovan <gustavo@padovan.org> |
|---|---|
| First post | 2016-07-12 20:10 +0200 |
| Last post | 2016-07-14 15:30 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v4 5/5] dma-buf/sync_file: only enable fence signalling on poll() Gustavo Padovan <gustavo@padovan.org> - 2016-07-12 20:10 +0200
Re: [PATCH v4 5/5] dma-buf/sync_file: only enable fence signalling on poll() John Harrison <John.C.Harrison@Intel.com> - 2016-07-14 15:30 +0200
| From | Gustavo Padovan <gustavo@padovan.org> |
|---|---|
| Date | 2016-07-12 20:10 +0200 |
| Subject | [PATCH v4 5/5] dma-buf/sync_file: only enable fence signalling on poll() |
| Message-ID | <rUai6-8w1-15@gated-at.bofh.it> |
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signalling doesn't need to be enabled at sync_file creation, it is only
required if userspace waiting the fence to signal through poll().
Thus we delay fence_add_callback() until poll is called. It only adds the
callback the first time poll() is called. This avoid re-adding the same
callback multiple times.
v2: rebase and update to work with new fence support for sync_file
v3: use atomic operation to set enabled and protect fence_add_callback()
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
drivers/dma-buf/sync_file.c | 22 +++++++++++++---------
include/linux/sync_file.h | 2 ++
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index 61a687c..240ef22 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -86,8 +86,6 @@ struct sync_file *sync_file_create(struct fence *fence)
fence->ops->get_timeline_name(fence), fence->context,
fence->seqno);
- fence_add_callback(fence, &sync_file->cb, fence_check_cb_func);
-
return sync_file;
}
EXPORT_SYMBOL(sync_file_create);
@@ -269,9 +267,6 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
goto err;
}
- fence_add_callback(sync_file->fence, &sync_file->cb,
- fence_check_cb_func);
-
strlcpy(sync_file->name, name, sizeof(sync_file->name));
return sync_file;
@@ -286,7 +281,8 @@ static void sync_file_free(struct kref *kref)
struct sync_file *sync_file = container_of(kref, struct sync_file,
kref);
- fence_remove_callback(sync_file->fence, &sync_file->cb);
+ if (atomic_read(&sync_file->enabled))
+ fence_remove_callback(sync_file->fence, &sync_file->cb);
fence_put(sync_file->fence);
kfree(sync_file);
}
@@ -306,13 +302,21 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
poll_wait(file, &sync_file->wq, wait);
+ if (!atomic_xchg(&sync_file->enabled, 1)) {
+ if (fence_add_callback(sync_file->fence, &sync_file->cb,
+ fence_check_cb_func) < 0)
+ wake_up_all(&sync_file->wq);
+ }
+
status = fence_is_signaled(sync_file->fence);
- if (status)
- return POLLIN;
+ if (!status)
+ return 0;
+
if (status < 0)
return POLLERR;
- return 0;
+
+ return POLLIN;
}
static long sync_file_ioctl_merge(struct sync_file *sync_file,
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index f7de5a0..4ced13b 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -28,6 +28,7 @@
* @name: name of sync_file. Useful for debugging
* @sync_file_list: membership in global file list
* @wq: wait queue for fence signaling
+ * @enabled: wether fence signal is enabled or not
* @fence: fence with the fences in the sync_file
* @cb: fence callback information
*/
@@ -40,6 +41,7 @@ struct sync_file {
#endif
wait_queue_head_t wq;
+ atomic_t enabled;
struct fence *fence;
struct fence_cb cb;
--
2.5.5
[toc] | [next] | [standalone]
| From | John Harrison <John.C.Harrison@Intel.com> |
|---|---|
| Date | 2016-07-14 15:30 +0200 |
| Subject | Re: [PATCH v4 5/5] dma-buf/sync_file: only enable fence signalling on poll() |
| Message-ID | <rUOSd-1Ni-17@gated-at.bofh.it> |
| In reply to | #1441632 |
On 12/07/2016 19:08, Gustavo Padovan wrote: > ... > > +++ b/include/linux/sync_file.h > @@ -28,6 +28,7 @@ > * @name: name of sync_file. Useful for debugging > * @sync_file_list: membership in global file list > * @wq: wait queue for fence signaling > + * @enabled: wether fence signal is enabled or not Minor typo: should be 'whether'.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web