diff options
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h | 42 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/os_fence.h | 111 |
2 files changed, 153 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h b/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h new file mode 100644 index 00000000..79cc51ea --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/os_fence_android.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_OS_FENCE_ANDROID_H__ | ||
24 | #define __NVGPU_OS_FENCE_ANDROID_H__ | ||
25 | |||
26 | struct gk20a; | ||
27 | struct nvgpu_os_fence; | ||
28 | struct sync_fence; | ||
29 | struct channel_gk20a; | ||
30 | |||
31 | struct sync_fence *nvgpu_get_sync_fence(struct nvgpu_os_fence *s); | ||
32 | |||
33 | void nvgpu_os_fence_android_drop_ref(struct nvgpu_os_fence *s); | ||
34 | |||
35 | int nvgpu_os_fence_sema_fdget(struct nvgpu_os_fence *fence_out, | ||
36 | struct channel_gk20a *c, int fd); | ||
37 | |||
38 | void nvgpu_os_fence_init(struct nvgpu_os_fence *fence_out, | ||
39 | struct gk20a *g, const struct nvgpu_os_fence_ops *fops, | ||
40 | struct sync_fence *fence); | ||
41 | |||
42 | #endif \ No newline at end of file | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_fence.h b/drivers/gpu/nvgpu/include/nvgpu/os_fence.h new file mode 100644 index 00000000..c8d24fc2 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/os_fence.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * nvgpu os fence | ||
3 | * | ||
4 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the "Software"), | ||
8 | * to deal in the Software without restriction, including without limitation | ||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included in | ||
14 | * all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
22 | * DEALINGS IN THE SOFTWARE. | ||
23 | */ | ||
24 | |||
25 | #ifndef __NVGPU_OS_FENCE__ | ||
26 | #define __NVGPU_OS_FENCE__ | ||
27 | |||
28 | struct nvgpu_semaphore; | ||
29 | struct channel_gk20a; | ||
30 | struct priv_cmd_entry; | ||
31 | |||
32 | /* | ||
33 | * struct nvgpu_os_fence adds an abstraction to the earlier Android Sync | ||
34 | * Framework, specifically the sync-fence mechanism and the newer DMA sync | ||
35 | * APIs from linux-4.9. This abstraction provides the high-level definition | ||
36 | * as well as APIs that can be used by other OSes in future to have their own | ||
37 | * alternatives for the sync-framework. | ||
38 | */ | ||
39 | struct nvgpu_os_fence; | ||
40 | |||
41 | /* | ||
42 | * struct nvgpu_os_fence depends on the following ops structure | ||
43 | */ | ||
44 | struct nvgpu_os_fence_ops { | ||
45 | /* | ||
46 | * This API is used to iterate through multiple fence points within the | ||
47 | * fence and program the pushbuffer method for wait command. | ||
48 | */ | ||
49 | int (*program_waits)(struct nvgpu_os_fence *s, | ||
50 | struct priv_cmd_entry *wait_cmd, | ||
51 | struct channel_gk20a *c, | ||
52 | int max_wait_cmds); | ||
53 | |||
54 | /* | ||
55 | * This should be the last operation on the OS fence. The | ||
56 | * OS fence acts as a place-holder for the underlying fence | ||
57 | * implementation e.g. sync_fences. For each construct/fdget call | ||
58 | * there needs to be a drop_ref call. This reduces a reference count | ||
59 | * for the underlying sync_fence. | ||
60 | */ | ||
61 | void (*drop_ref)(struct nvgpu_os_fence *s); | ||
62 | }; | ||
63 | |||
64 | /* | ||
65 | * The priv structure here is used to contain the struct sync_fence | ||
66 | * for LINUX_VERSION <= 4.9 and dma_fence for LINUX_VERSION > 4.9 | ||
67 | */ | ||
68 | struct nvgpu_os_fence { | ||
69 | void *priv; | ||
70 | struct gk20a *g; | ||
71 | const struct nvgpu_os_fence_ops *ops; | ||
72 | }; | ||
73 | |||
74 | /* | ||
75 | * This API is used to validate the nvgpu_os_fence | ||
76 | */ | ||
77 | static inline int nvgpu_os_fence_is_initialized(struct nvgpu_os_fence *fence) | ||
78 | { | ||
79 | return (fence->ops != NULL); | ||
80 | } | ||
81 | |||
82 | #ifdef CONFIG_SYNC | ||
83 | |||
84 | int nvgpu_os_fence_sema_create( | ||
85 | struct nvgpu_os_fence *fence_out, | ||
86 | struct channel_gk20a *c, | ||
87 | struct nvgpu_semaphore *sema); | ||
88 | |||
89 | int nvgpu_os_fence_fdget( | ||
90 | struct nvgpu_os_fence *fence_out, | ||
91 | struct channel_gk20a *c, int fd); | ||
92 | |||
93 | #else | ||
94 | |||
95 | static inline int nvgpu_os_fence_sema_create( | ||
96 | struct nvgpu_os_fence *fence_out, | ||
97 | struct channel_gk20a *c, | ||
98 | struct nvgpu_semaphore *sema) | ||
99 | { | ||
100 | return -ENOSYS; | ||
101 | } | ||
102 | static inline int nvgpu_os_fence_fdget( | ||
103 | struct nvgpu_os_fence *fence_out, | ||
104 | struct channel_gk20a *c, int fd) | ||
105 | { | ||
106 | return -ENOSYS; | ||
107 | } | ||
108 | |||
109 | #endif /* CONFIG_SYNC */ | ||
110 | |||
111 | #endif /* __NVGPU_OS_FENCE__ */ | ||