aboutsummaryrefslogtreecommitdiffstats
path: root/include/gk20a/fence_gk20a.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/gk20a/fence_gk20a.h')
-rw-r--r--include/gk20a/fence_gk20a.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/include/gk20a/fence_gk20a.h b/include/gk20a/fence_gk20a.h
new file mode 100644
index 0000000..0311279
--- /dev/null
+++ b/include/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-2018, 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 NVGPU_GK20A_FENCE_GK20A_H
27#define NVGPU_GK20A_FENCE_GK20A_H
28
29#include <nvgpu/types.h>
30#include <nvgpu/kref.h>
31#include <nvgpu/os_fence.h>
32
33struct platform_device;
34struct nvgpu_semaphore;
35struct channel_gk20a;
36struct gk20a;
37struct nvgpu_os_fence;
38
39struct gk20a_fence_ops;
40
41struct gk20a_fence {
42 struct gk20a *g;
43
44 /* Valid for all fence types: */
45 bool valid;
46 struct nvgpu_ref ref;
47 const struct gk20a_fence_ops *ops;
48
49 struct nvgpu_os_fence os_fence;
50
51 /* Valid for fences created from semaphores: */
52 struct nvgpu_semaphore *semaphore;
53 struct nvgpu_cond *semaphore_wq;
54
55 /* Valid for fences created from syncpoints: */
56 struct nvgpu_nvhost_dev *nvhost_dev;
57 u32 syncpt_id;
58 u32 syncpt_value;
59
60 /* Valid for fences part of a pre-allocated fence pool */
61 struct nvgpu_allocator *allocator;
62};
63
64/* Fences can be created from semaphores or syncpoint (id, value) pairs */
65int gk20a_fence_from_semaphore(
66 struct gk20a_fence *fence_out,
67 struct nvgpu_semaphore *semaphore,
68 struct nvgpu_cond *semaphore_wq,
69 struct nvgpu_os_fence os_fence);
70
71int gk20a_fence_from_syncpt(
72 struct gk20a_fence *fence_out,
73 struct nvgpu_nvhost_dev *nvhost_dev,
74 u32 id, u32 value,
75 struct nvgpu_os_fence os_fence);
76
77int gk20a_alloc_fence_pool(
78 struct channel_gk20a *c,
79 unsigned int count);
80
81void gk20a_free_fence_pool(
82 struct channel_gk20a *c);
83
84struct gk20a_fence *gk20a_alloc_fence(
85 struct channel_gk20a *c);
86
87void gk20a_init_fence(struct gk20a_fence *f,
88 const struct gk20a_fence_ops *ops,
89 struct nvgpu_os_fence os_fence);
90
91/* Fence operations */
92void gk20a_fence_put(struct gk20a_fence *f);
93struct gk20a_fence *gk20a_fence_get(struct gk20a_fence *f);
94int gk20a_fence_wait(struct gk20a *g, struct gk20a_fence *f,
95 unsigned long timeout);
96bool gk20a_fence_is_expired(struct gk20a_fence *f);
97bool gk20a_fence_is_valid(struct gk20a_fence *f);
98int gk20a_fence_install_fd(struct gk20a_fence *f, int fd);
99
100#endif /* NVGPU_GK20A_FENCE_GK20A_H */