Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad597759 authored by Chris Wilson's avatar Chris Wilson Committed by Gerrit - the friendly Code Review server
Browse files

dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence



commit 99f828436788f0155798145853607ca8f0e6de93 upstream.

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 e2416553
("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.

Change-Id: I8608a6dbce38d84c1f94e97eece3998884bfa035
Reported-by: default avatarGustavo 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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: dri-devel@lists.freedesktop.org
Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.13-rc1+
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170728212951.7818-1-chris@chris-wilson.co.uk
(cherry picked from commit db1fc97ca0c0d3fdeeadf314d99a26188438940a)
Git-commit: 99f828436788f0155798145853607ca8f0e6de93
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Signed-off-by: default avatarDhaval Patel <pdhaval@codeaurora.org>
parent e08dfa6b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -285,7 +285,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);
@@ -305,7 +305,7 @@ 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 (!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);
+2 −1
Original line number Diff line number Diff line
@@ -43,9 +43,10 @@ struct sync_file {

	struct fence		*fence;
	struct fence_cb cb;
	unsigned long flags;
};

#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);