• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2014 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 IGT_GT_H
25 #define IGT_GT_H
26 
27 #include "igt_debugfs.h"
28 #include "igt_dummyload.h"
29 #include "igt_core.h"
30 
31 #include "i915_drm.h"
32 
33 void igt_require_hang_ring(int fd, int ring);
34 
35 typedef struct igt_hang {
36 	igt_spin_t *spin;
37 	unsigned ctx;
38 	unsigned ban;
39 	unsigned flags;
40 } igt_hang_t;
41 
42 igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags);
43 void igt_disallow_hang(int fd, igt_hang_t arg);
44 
45 #define HANG_POISON 0xc5c5c5c5
46 
47 igt_hang_t igt_hang_ctx(int fd, uint32_t ctx, int ring, unsigned flags);
48 #define HANG_ALLOW_BAN 1
49 #define HANG_ALLOW_CAPTURE 2
50 
51 igt_hang_t igt_hang_ring(int fd, int ring);
52 void igt_post_hang_ring(int fd, igt_hang_t arg);
53 
54 void igt_force_gpu_reset(int fd);
55 
56 void igt_fork_hang_helper(void);
57 void igt_stop_hang_helper(void);
58 
59 int igt_open_forcewake_handle(int fd);
60 
61 int igt_setup_clflush(void);
62 void igt_clflush_range(void *addr, int size);
63 
64 unsigned intel_detect_and_clear_missed_interrupts(int fd);
65 
66 #define ALL_ENGINES ~0u /* Use in interfaces to iterate all engines */
67 
68 extern const struct intel_execution_engine {
69 	const char *name;
70 	const char *full_name;
71 	unsigned exec_id;
72 	unsigned flags;
73 } intel_execution_engines[];
74 
75 #define for_if(expr__) if (!(expr__)) {} else
76 
77 #define for_each_engine(fd__, flags__) \
78 	for (const struct intel_execution_engine *e__ = intel_execution_engines;\
79 	     e__->name; \
80 	     e__++) \
81 		for_if (gem_has_ring(fd__, flags__ = e__->exec_id | e__->flags))
82 
83 #define for_each_physical_engine(fd__, flags__) \
84 	for (const struct intel_execution_engine *e__ = intel_execution_engines;\
85 	     e__->name; \
86 	     e__++) \
87 		for_if (gem_ring_has_physical_engine(fd__, flags__ = e__->exec_id | e__->flags))
88 
89 bool gem_ring_is_physical_engine(int fd, unsigned int ring);
90 bool gem_ring_has_physical_engine(int fd, unsigned int ring);
91 
92 bool gem_can_store_dword(int fd, unsigned int engine);
93 bool gem_class_can_store_dword(int fd, int class);
94 
95 extern const struct intel_execution_engine2 {
96 	const char *name;
97 	int class;
98 	int instance;
99 	uint64_t flags;
100 	bool is_virtual;
101 } intel_execution_engines2[];
102 
103 int gem_execbuf_flags_to_engine_class(unsigned int flags);
104 
105 #endif /* IGT_GT_H */
106