• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2019 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 
24 #ifndef GEM_ENGINE_TOPOLOGY_H
25 #define GEM_ENGINE_TOPOLOGY_H
26 
27 #include "igt_gt.h"
28 #include "i915_drm.h"
29 
30 #define GEM_MAX_ENGINES		I915_EXEC_RING_MASK + 1
31 
32 struct intel_engine_data {
33 	uint32_t nengines;
34 	uint32_t n;
35 	struct intel_execution_engine2 *current_engine;
36 	struct intel_execution_engine2 engines[GEM_MAX_ENGINES];
37 };
38 
39 bool gem_has_engine_topology(int fd);
40 struct intel_engine_data intel_init_engine_list(int fd, uint32_t ctx_id);
41 
42 /* iteration functions */
43 struct intel_execution_engine2 *
44 intel_get_current_engine(struct intel_engine_data *ed);
45 
46 struct intel_execution_engine2 *
47 intel_get_current_physical_engine(struct intel_engine_data *ed);
48 
49 void intel_next_engine(struct intel_engine_data *ed);
50 
51 int gem_context_lookup_engine(int fd, uint64_t engine, uint32_t ctx_id,
52 			      struct intel_execution_engine2 *e);
53 
54 void gem_context_set_all_engines(int fd, uint32_t ctx);
55 
56 bool gem_context_has_engine_map(int fd, uint32_t ctx);
57 
58 bool gem_engine_is_equal(const struct intel_execution_engine2 *e1,
59 			 const struct intel_execution_engine2 *e2);
60 
61 struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);
62 
63 #define __for_each_static_engine(e__) \
64 	for ((e__) = intel_execution_engines2; (e__)->name; (e__)++)
65 
66 #define for_each_context_engine(fd__, ctx__, e__) \
67 	for (struct intel_engine_data i__ = intel_init_engine_list(fd__, ctx__); \
68 	     ((e__) = intel_get_current_engine(&i__)); \
69 	     intel_next_engine(&i__))
70 
71 /* needs to replace "for_each_physical_engine" when conflicts are fixed */
72 #define __for_each_physical_engine(fd__, e__) \
73 	for (struct intel_engine_data i__ = intel_init_engine_list(fd__, 0); \
74 	     ((e__) = intel_get_current_physical_engine(&i__)); \
75 	     intel_next_engine(&i__))
76 
77 #endif /* GEM_ENGINE_TOPOLOGY_H */
78