diff options
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/os_fence_android.c')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/os_fence_android.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/os_fence_android.c b/drivers/gpu/nvgpu/os/linux/os_fence_android.c new file mode 100644 index 00000000..9be8c6c0 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_fence_android.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | #include <nvgpu/types.h> | ||
17 | #include <nvgpu/os_fence.h> | ||
18 | #include <nvgpu/linux/os_fence_android.h> | ||
19 | |||
20 | #include "gk20a/gk20a.h" | ||
21 | |||
22 | #include "../drivers/staging/android/sync.h" | ||
23 | |||
24 | inline struct sync_fence *nvgpu_get_sync_fence(struct nvgpu_os_fence *s) | ||
25 | { | ||
26 | struct sync_fence *fence = (struct sync_fence *)s->priv; | ||
27 | return fence; | ||
28 | } | ||
29 | |||
30 | static void nvgpu_os_fence_clear(struct nvgpu_os_fence *fence_out) | ||
31 | { | ||
32 | fence_out->priv = NULL; | ||
33 | fence_out->g = NULL; | ||
34 | fence_out->ops = NULL; | ||
35 | } | ||
36 | |||
37 | void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out, | ||
38 | struct gk20a *g, const struct nvgpu_os_fence_ops *fops, | ||
39 | struct sync_fence *fence) | ||
40 | { | ||
41 | fence_out->g = g; | ||
42 | fence_out->ops = fops; | ||
43 | fence_out->priv = (void *)fence; | ||
44 | } | ||
45 | |||
46 | void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s) | ||
47 | { | ||
48 | struct sync_fence *fence = nvgpu_get_sync_fence(s); | ||
49 | |||
50 | sync_fence_put(fence); | ||
51 | |||
52 | nvgpu_os_fence_clear(s); | ||
53 | } | ||
54 | |||
55 | void nvgpu_os_fence_android_install_fd(struct nvgpu_os_fence *s, int fd) | ||
56 | { | ||
57 | struct sync_fence *fence = nvgpu_get_sync_fence(s); | ||
58 | |||
59 | sync_fence_get(fence); | ||
60 | sync_fence_install(fence, fd); | ||
61 | } | ||
62 | |||
63 | int nvgpu_os_fence_fdget(struct nvgpu_os_fence *fence_out, | ||
64 | struct channel_gk20a *c, int fd) | ||
65 | { | ||
66 | int err = -ENOSYS; | ||
67 | |||
68 | #ifdef CONFIG_TEGRA_GK20A_NVHOST | ||
69 | err = nvgpu_os_fence_syncpt_fdget(fence_out, c, fd); | ||
70 | #endif | ||
71 | |||
72 | if (err) | ||
73 | err = nvgpu_os_fence_sema_fdget(fence_out, c, fd); | ||
74 | |||
75 | if (err) | ||
76 | nvgpu_err(c->g, "error obtaining fence from fd %d", fd); | ||
77 | |||
78 | return err; | ||
79 | } | ||