summaryrefslogtreecommitdiff
authorChris Wilson <chris@chris-wilson.co.uk>2017-07-28 21:29:51 (GMT)
committer Shuide Chen <shuide.chen@amlogic.com>2018-08-10 07:37:54 (GMT)
commitc9e43a4b669acb6d946f737d2f77e27d6482787e (patch)
tree982cfa5e0c9fbe71e4bb8c05959a5d10d038bb0f
parent39169ed5d09e6bced2938c9e9462f94c16454a26 (diff)
downloadcommon-c9e43a4b669acb6d946f737d2f77e27d6482787e.zip
common-c9e43a4b669acb6d946f737d2f77e27d6482787e.tar.gz
common-c9e43a4b669acb6d946f737d2f77e27d6482787e.tar.bz2
BACKPORT: dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence
Up until recently sync_file were create to export a single dma-fence to userspace, and so we could canabalise a bit insie dma-fence to mark whether or not we had enable polling for the sync_file itself. However, with the advent of syncobj, we do allow userspace to create multiple sync_files for a single dma-fence. (Similarly, that the sw-sync validation framework also started returning multiple sync-files wrapping a single dma-fence for a syncpt also triggering the problem.) This patch reverts my suggestion in commit e24165537312 ("dma-buf/sync_file: only enable fence signalling on poll()") to use a single bit in the shared dma-fence and restores the sync_file->flags for tracking the bits individually. Reported-by: Gustavo Padovan <gustavo.padovan@collabora.com> Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline") Fixes: e9083420bbac ("drm: introduce sync objects (v4)") Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170728212951.7818-1-chris@chris-wilson.co.uk [astrachan: rediffed against changed context lines in 4.9] Bug: 79383895 PD#170298 [1/3] Change-Id: I70d1f19796c6cb33cd4c19e40276d7298aa4ba5d Signed-off-by: Alistair Strachan <astrachan@google.com>
Diffstat
-rw-r--r--drivers/dma-buf/sync_file.c5
-rw-r--r--include/linux/sync_file.h3
2 files changed, 5 insertions, 3 deletions
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index 56a45cd..267546a 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -278,7 +278,7 @@ static void sync_file_free(struct kref *kref)
struct sync_file *sync_file = container_of(kref, struct sync_file,
kref);
- if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
+ if (test_bit(POLL_ENABLED, &sync_file->flags))
fence_remove_callback(sync_file->fence, &sync_file->cb);
fence_put(sync_file->fence);
kfree(sync_file);
@@ -298,7 +298,8 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
poll_wait(file, &sync_file->wq, wait);
- if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
+ if (list_empty(&sync_file->cb.node) &&
+ !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
if (fence_add_callback(sync_file->fence, &sync_file->cb,
fence_check_cb_func) < 0)
wake_up_all(&sync_file->wq);
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index aa17ccf..35ec6c4 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -40,12 +40,13 @@ struct sync_file {
#endif
wait_queue_head_t wq;
+ unsigned long flags;
struct fence *fence;
struct fence_cb cb;
};
-#define POLL_ENABLED FENCE_FLAG_USER_BITS
+#define POLL_ENABLED 0
struct sync_file *sync_file_create(struct fence *fence);
struct fence *sync_file_get_fence(int fd);