summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci/drm/drm_linux.c
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2019-06-04 12:08:22 +0000
committerjsg <jsg@openbsd.org>2019-06-04 12:08:22 +0000
commit13e5339c767d677c4f402440ab863de3f42a6344 (patch)
tree0bc19b3b74987bc42b69d2e0747e5b9e60d5863a /sys/dev/pci/drm/drm_linux.c
parentAdd several missing .In lines (diff)
downloadwireguard-openbsd-13e5339c767d677c4f402440ab863de3f42a6344.tar.xz
wireguard-openbsd-13e5339c767d677c4f402440ab863de3f42a6344.zip
Move a function used as a callback out of a header so there will only be
one function with a single address.
Diffstat (limited to 'sys/dev/pci/drm/drm_linux.c')
-rw-r--r--sys/dev/pci/drm/drm_linux.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c
index 60c9889451f..f7a961c083d 100644
--- a/sys/dev/pci/drm/drm_linux.c
+++ b/sys/dev/pci/drm/drm_linux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.c,v 1.36 2019/05/11 17:13:59 jsg Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.37 2019/06/04 12:08:22 jsg Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -904,6 +904,66 @@ dma_fence_context_alloc(unsigned int num)
return __sync_add_and_fetch(&drm_fence_count, num) - num;
}
+static void
+dma_fence_default_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
+{
+ wakeup(fence);
+}
+
+long
+dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
+{
+ long ret = timeout ? timeout : 1;
+ int err;
+ struct dma_fence_cb cb;
+ bool was_set;
+
+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
+ return ret;
+
+ mtx_enter(fence->lock);
+
+ was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+ &fence->flags);
+
+ if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
+ goto out;
+
+ if (!was_set && fence->ops->enable_signaling) {
+ if (!fence->ops->enable_signaling(fence)) {
+ dma_fence_signal_locked(fence);
+ goto out;
+ }
+ }
+
+ if (timeout == 0) {
+ ret = 0;
+ goto out;
+ }
+
+ cb.func = dma_fence_default_wait_cb;
+ list_add(&cb.node, &fence->cb_list);
+
+ while (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
+ err = msleep(fence, fence->lock, intr ? PCATCH : 0, "dmafence",
+ timeout);
+ if (err == EINTR || err == ERESTART) {
+ ret = -ERESTARTSYS;
+ break;
+ } else if (err == EWOULDBLOCK) {
+ ret = 0;
+ break;
+ }
+ }
+
+ if (!list_empty(&cb.node))
+ list_del(&cb.node);
+out:
+ mtx_leave(fence->lock);
+
+ return ret;
+}
+
static const char *
dma_fence_array_get_driver_name(struct dma_fence *fence)
{