Revert "BACKPORT: dma-buf/sync_file: Allow multiple sync_files to wrap a single dma...
authorVictor Wan <victor.wan@amlogic.com>
Tue, 7 Aug 2018 06:45:33 +0000 (14:45 +0800)
committerVictor Wan <victor.wan@amlogic.com>
Tue, 7 Aug 2018 06:46:15 +0000 (14:46 +0800)
This reverts commit 74fa0af47306baf118b32b7acdba4ae98eda7a7d.

The commit 74fa0af caused GPU driver loading failed.

Change-Id: I255eb6b7a26e3b00e4f11489ece49896ff004d79

drivers/dma-buf/sync_file.c
include/linux/sync_file.h

index 267546a009875b9cea78df14d231463c1edcdece..56a45cd8505e4dfed739c3623e30b742fb6442c5 100644 (file)
@@ -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->flags))
+       if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
                fence_remove_callback(sync_file->fence, &sync_file->cb);
        fence_put(sync_file->fence);
        kfree(sync_file);
@@ -298,8 +298,7 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
 
        poll_wait(file, &sync_file->wq, wait);
 
-       if (list_empty(&sync_file->cb.node) &&
-           !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
+       if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
                if (fence_add_callback(sync_file->fence, &sync_file->cb,
                                           fence_check_cb_func) < 0)
                        wake_up_all(&sync_file->wq);
index 35ec6c45e190464035619edafce532898d8e8bcb..aa17ccfc2f573c01f2f0505fc92d7c207f655a8d 100644 (file)
@@ -40,13 +40,12 @@ struct sync_file {
 #endif
 
        wait_queue_head_t       wq;
-       unsigned long           flags;
 
        struct fence            *fence;
        struct fence_cb cb;
 };
 
-#define POLL_ENABLED 0
+#define POLL_ENABLED FENCE_FLAG_USER_BITS
 
 struct sync_file *sync_file_create(struct fence *fence);
 struct fence *sync_file_get_fence(int fd);