summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/fence_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/fence_gk20a.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
new file mode 100644
index 00000000..50f1a9bd
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h
@@ -0,0 +1,100 @@
1/*
2 * drivers/video/tegra/host/gk20a/fence_gk20a.h
3 *
4 * GK20A Fences
5 *
6 * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26#ifndef _GK20A_FENCE_H_
27#define _GK20A_FENCE_H_
28
29#include <nvgpu/kref.h>
30
31struct platform_device;
32struct sync_timeline;
33struct sync_fence;
34struct nvgpu_semaphore;
35struct channel_gk20a;
36struct gk20a;
37
38struct gk20a_fence_ops;
39
40struct gk20a_fence {
41 struct gk20a *g;
42
43 /* Valid for all fence types: */
44 bool valid;
45 struct nvgpu_ref ref;
46 bool wfi;
47 struct sync_fence *sync_fence;
48 const struct gk20a_fence_ops *ops;
49
50 /* Valid for fences created from semaphores: */
51 struct nvgpu_semaphore *semaphore;
52 struct nvgpu_cond *semaphore_wq;
53
54 /* Valid for fences created from syncpoints: */
55 struct nvgpu_nvhost_dev *nvhost_dev;
56 u32 syncpt_id;
57 u32 syncpt_value;
58
59 /* Valid for fences part of a pre-allocated fence pool */
60 struct nvgpu_allocator *allocator;
61};
62
63/* Fences can be created from semaphores or syncpoint (id, value) pairs */
64int gk20a_fence_from_semaphore(
65 struct gk20a *g,
66 struct gk20a_fence *fence_out,
67 struct sync_timeline *timeline,
68 struct nvgpu_semaphore *semaphore,
69 struct nvgpu_cond *semaphore_wq,
70 bool wfi, bool need_sync_fence);
71
72int gk20a_fence_from_syncpt(
73 struct gk20a_fence *fence_out,
74 struct nvgpu_nvhost_dev *nvhost_dev,
75 u32 id, u32 value, bool wfi,
76 bool need_sync_fence);
77
78int gk20a_alloc_fence_pool(
79 struct channel_gk20a *c,
80 unsigned int count);
81
82void gk20a_free_fence_pool(
83 struct channel_gk20a *c);
84
85struct gk20a_fence *gk20a_alloc_fence(
86 struct channel_gk20a *c);
87
88void gk20a_init_fence(struct gk20a_fence *f,
89 const struct gk20a_fence_ops *ops,
90 struct sync_fence *sync_fence, bool wfi);
91
92/* Fence operations */
93void gk20a_fence_put(struct gk20a_fence *f);
94struct gk20a_fence *gk20a_fence_get(struct gk20a_fence *f);
95int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f,
96 unsigned long timeout);
97bool gk20a_fence_is_expired(struct gk20a_fence *f);
98int gk20a_fence_install_fd(struct gk20a_fence *f);
99
100#endif