Debian Codegraph @

media_softlet/linux/common/os/xe/include/mos_synchronization_xe.h

raw
1 /*
2 * Copyright © 2023 Intel Corporation
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Xu, Zhengguo <[email protected]>
25 */
26
27 #ifndef __MOS_SYNCHRONIZATION_XE_
28 #define __MOS_SYNCHRONIZATION_XE_
29
30
31 #include <stdint.h>
32 #include <vector>
33 #include <map>
34 #include <queue>
35 #include <list>
36 #include "xe_drm.h"
37
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif
41
42 struct mos_xe_dep {
43 /**
44 * Indicate to the handle for timeline syncobj.
45 */
46 uint32_t syncobj_handle;
47 /**
48 * Indicate to latest avaiable timeline value(index) for fence out point.
49 */
50 uint64_t timeline_index;
51 };
52
53 struct mos_xe_bo_dep
54 {
55 /**
56 * Indicate to reusable dep in the ctx queue.
57 */
58 struct mos_xe_dep *dep;
59
60 /**
61 * Indicate to the timeline point that bo execution on certain exec queue.
62 */
63 uint64_t exec_timeline_index;
64 };
65
66 int mos_sync_syncobj_create(int fd, uint32_t flags);
67 int mos_sync_syncobj_destroy(int fd, uint32_t handle);
68 int mos_sync_syncobj_reset(int fd, uint32_t *handles, uint32_t count);
69 int mos_sync_syncobj_wait_err(int fd, uint32_t *handles, uint32_t count,
70 int64_t abs_timeout_nsec, uint32_t flags, uint32_t *first_signaled);
71 int mos_sync_syncobj_timeline_wait(int fd, uint32_t *handles, uint64_t *points,
72 unsigned num_handles,
73 int64_t timeout_nsec, unsigned flags,
74 uint32_t *first_signaled);
75
76 int mos_sync_syncobj_handle_to_syncfile_fd(int fd, int syncobj_handle);
77 int mos_sync_import_syncfile_to_external_bo(int fd, int prime_fd, int syncfile_fd);
78 int mos_sync_syncobj_timeline_to_binary(int fd, uint32_t binary_handle,
79 uint32_t timeline_handle,
80 uint64_t point,
81 uint32_t flags);
82 void mos_sync_update_timeline_dep(struct mos_xe_dep *dep);
83 int mos_sync_update_exec_syncs_from_timeline_deps(uint32_t curr_engine,
84 uint32_t lst_write_engine, uint32_t flags,
85 std::set<uint32_t> &engine_ids,
86 std::map<uint32_t, struct mos_xe_bo_dep> &read_deps,
87 std::map<uint32_t, struct mos_xe_bo_dep> &write_deps,
88 std::vector<drm_xe_sync> &syncs);
89 int mos_sync_update_exec_syncs_from_handle(int fd,
90 uint32_t bo_handle, uint32_t flags,
91 std::vector<struct drm_xe_sync> &syncs,
92 int &out_prime_fd);
93 struct mos_xe_dep *mos_sync_create_timeline_dep(int fd);
94 void mos_sync_update_exec_syncs_from_timeline_dep(int fd,
95 struct mos_xe_dep *dep,
96 std::vector<struct drm_xe_sync> &syncs);
97 int mos_sync_update_bo_deps(uint32_t curr_engine,
98 uint32_t flags, mos_xe_dep *dep,
99 std::map<uint32_t, struct mos_xe_bo_dep> &read_deps,
100 std::map<uint32_t, struct mos_xe_bo_dep> &write_deps);
101 void mos_sync_get_bo_wait_timeline_deps(std::set<uint32_t> &engine_ids,
102 std::map<uint32_t, struct mos_xe_bo_dep> &read_deps,
103 std::map<uint32_t, struct mos_xe_bo_dep> &write_deps,
104 std::map<uint32_t, uint64_t> &max_timeline_data,
105 uint32_t lst_write_engine,
106 uint32_t rw_flags);
107 void mos_sync_destroy_timeline_dep(int fd, struct mos_xe_dep *dep);
108
109
110 #if defined(__cplusplus)
111 }
112 #endif
113
114 #endif //__MOS_SYNCHRONIZATION_XE_