Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1457104
| Path | csiph.com!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Gustavo Padovan <gustavo@padovan.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v6 5/5] dma-buf/sync_file: only enable fence signalling on poll() |
| Date | Fri, 05 Aug 2016 15:50:01 +0200 |
| Message-ID | <s2NFD-8dj-15@gated-at.bofh.it> (permalink) |
| References | <s2NvX-89z-1@gated-at.bofh.it> |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NSF6Kyqqaz2zoJswrLmXxIxbXM4LSKNvqV6cBZf9zEM=; b=L22ieuE8Xma3rw+h5+WMKMFIaDFPBjcCKh2DB9d9HMXdgxfm6izL2pkCIOHZwXT7ms MSTI5qAfy4dYbiu0Q29IVm1RVlgNjsRw8PqQfBdWJVUg2ZSMqPrfQOZcos9sDGtOPqOA +QqhEz1gw9+ePsm6NH7rN150Kmd8D8r+/xAGRDZExfr6whjNn69s90mNVPArl93U37ow egTLGIenNxSr0I4x6rlBNuKRKwBQm6DFw6OrK+OUyESuLtAfPPlmhFFfFbPiRSeV5+Gm 0Z03yLcK5gh/aXqIRkLB7CRQnPKUcAHwfPJi7H3F8e+AZO+TtiplCHZC0D8yPDva7lV/ +KQw== |
| X-Gm-Message-State | AEkooutYdcS96kQzexV036WJEvxW973YoGsA+icdFPz1J3wdtRDPFUXgf1fxMY2irtanaA== |
| X-Received | by 10.13.214.146 with SMTP id y140mr58128845ywd.0.1470404412824; Fri, 05 Aug 2016 06:40:12 -0700 (PDT) |
| X-Mailer | git-send-email 2.5.5 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 92 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-kernel@vger.kernel.org, Daniel Stone <daniels@collabora.com>, Daniel Vetter <daniel.vetter@ffwll.ch>, Rob Clark <robdclark@gmail.com>, Greg Hackmann <ghackmann@google.com>, John Harrison <John.C.Harrison@Intel.com>, laurent.pinchart@ideasonboard.com, seanpaul@google.com, marcheu@google.com, m.chehab@samsung.com, Sumit Semwal <sumit.semwal@linaro.org>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Gustavo Padovan <gustavo.padovan@collabora.co.uk> |
| X-Original-Date | Fri, 5 Aug 2016 10:39:38 -0300 |
| X-Original-Message-ID | <1470404378-27961-5-git-send-email-gustavo@padovan.org> |
| X-Original-References | <1470404378-27961-1-git-send-email-gustavo@padovan.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1457104 |
Show key headers only | View raw
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()
v4: use user bit from fence flags (comment from Chris Wilson)
v5: use ternary if on poll return (comment from Chris Wilson)
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/dma-buf/sync_file.c | 20 ++++++++------------
include/linux/sync_file.h | 2 ++
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index 2873760..82b5334 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);
@@ -274,9 +272,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;
@@ -291,7 +286,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 (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);
}
@@ -311,13 +307,13 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
poll_wait(file, &sync_file->wq, wait);
- status = fence_is_signaled(sync_file->fence);
+ 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);
+ }
- if (status)
- return POLLIN;
- if (status < 0)
- return POLLERR;
- return 0;
+ return fence_is_signaled(sync_file->fence) ? POLLIN : 0;
}
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..aa17ccf 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -45,6 +45,8 @@ struct sync_file {
struct fence_cb cb;
};
+#define POLL_ENABLED FENCE_FLAG_USER_BITS
+
struct sync_file *sync_file_create(struct fence *fence);
struct fence *sync_file_get_fence(int fd);
--
2.5.5
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v6 1/5] dma-buf/fence-array: add fence_is_array() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 15:40 +0200 [PATCH v6 2/5] dma-buf/sync_file: refactor fence storage in struct sync_file Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 15:50 +0200 [PATCH v6 5/5] dma-buf/sync_file: only enable fence signalling on poll() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 15:50 +0200 [PATCH v6 4/5] Documentation: add doc for sync_file_get_fence() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 15:50 +0200 [PATCH v6 3/5] dma-buf/sync_file: add sync_file_get_fence() Gustavo Padovan <gustavo@padovan.org> - 2016-08-05 15:50 +0200
csiph-web