blob: 73b5002a04bd08d3ccc079d9c081c0c5f829a0c4 [file] [log] [blame]
Chris Wilson16bafdf2014-09-04 09:26:24 +01001/*
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
Daniel Vetter3cd45de2015-02-10 17:46:43 +010027#include "igt_debugfs.h"
Antonio Argenziano140a67c2018-07-10 16:45:26 -070028#include "igt_dummyload.h"
Tvrtko Ursulin20d89b42017-09-18 09:06:19 +010029#include "igt_core.h"
Daniel Vetter3cd45de2015-02-10 17:46:43 +010030
Lionel Landwerlina9387972017-12-05 16:43:01 +000031#include "i915_drm.h"
32
Daniel Vetterc66b2422015-02-06 10:49:20 +010033void igt_require_hang_ring(int fd, int ring);
Chris Wilson16bafdf2014-09-04 09:26:24 +010034
Chris Wilson0a1fc452016-09-13 11:13:14 +010035typedef struct igt_hang {
Antonio Argenziano140a67c2018-07-10 16:45:26 -070036 igt_spin_t *spin;
Chris Wilson19642c62015-12-11 13:27:49 +000037 unsigned ctx;
Chris Wilson16bafdf2014-09-04 09:26:24 +010038 unsigned ban;
Chris Wilson19642c62015-12-11 13:27:49 +000039 unsigned flags;
Chris Wilson0a1fc452016-09-13 11:13:14 +010040} igt_hang_t;
41
42igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags);
43void igt_disallow_hang(int fd, igt_hang_t arg);
Daniel Vetter3cd45de2015-02-10 17:46:43 +010044
Chris Wilson19642c62015-12-11 13:27:49 +000045#define HANG_POISON 0xc5c5c5c5
46
Antonio Argenziano140a67c2018-07-10 16:45:26 -070047igt_hang_t igt_hang_ctx(int fd, uint32_t ctx, int ring, unsigned flags);
Chris Wilson19642c62015-12-11 13:27:49 +000048#define HANG_ALLOW_BAN 1
49#define HANG_ALLOW_CAPTURE 2
50
Chris Wilson0a1fc452016-09-13 11:13:14 +010051igt_hang_t igt_hang_ring(int fd, int ring);
52void igt_post_hang_ring(int fd, igt_hang_t arg);
Chris Wilson16bafdf2014-09-04 09:26:24 +010053
Chris Wilson83884e92017-03-21 17:16:03 +000054void igt_force_gpu_reset(int fd);
Daniele Ceraolo Spurio03c7f842016-03-01 11:01:32 +000055
Daniel Vetterd8d1eab2015-12-03 07:45:34 +010056void igt_fork_hang_helper(void);
Daniel Vetter3cd45de2015-02-10 17:46:43 +010057void igt_stop_hang_helper(void);
58
Chris Wilson83884e92017-03-21 17:16:03 +000059int igt_open_forcewake_handle(int fd);
Daniel Vetter3cd45de2015-02-10 17:46:43 +010060
Chris Wilsona6090c72016-01-08 16:32:29 +000061int igt_setup_clflush(void);
62void igt_clflush_range(void *addr, int size);
63
Chris Wilson5b675f72016-01-22 17:33:40 +000064unsigned intel_detect_and_clear_missed_interrupts(int fd);
65
Antonio Argenziano94e88622018-03-19 15:30:38 -070066#define ALL_ENGINES ~0u /* Use in interfaces to iterate all engines */
67
Chris Wilson04f52152016-01-27 14:07:27 +000068extern const struct intel_execution_engine {
69 const char *name;
Chris Wilson38fe49d2016-02-04 11:17:42 +000070 const char *full_name;
Chris Wilson04f52152016-01-27 14:07:27 +000071 unsigned exec_id;
72 unsigned flags;
73} intel_execution_engines[];
74
Chris Wilson697c3f52016-03-04 10:19:38 +000075#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__++) \
Chris Wilson74724472017-01-05 11:43:15 +000081 for_if (gem_has_ring(fd__, flags__ = e__->exec_id | e__->flags))
Chris Wilson697c3f52016-03-04 10:19:38 +000082
Chris Wilson305ebce2018-02-21 14:13:16 +000083#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
89bool gem_ring_is_physical_engine(int fd, unsigned int ring);
90bool gem_ring_has_physical_engine(int fd, unsigned int ring);
91
Chris Wilsonbc787762017-05-18 12:11:59 +010092bool gem_can_store_dword(int fd, unsigned int engine);
Andi Shyti949f8542019-05-22 14:50:54 +010093bool gem_class_can_store_dword(int fd, int class);
Chris Wilson697c3f52016-03-04 10:19:38 +000094
Tvrtko Ursulin20d89b42017-09-18 09:06:19 +010095extern const struct intel_execution_engine2 {
96 const char *name;
97 int class;
98 int instance;
Andi Shyti17c77e72019-05-22 14:50:52 +010099 uint64_t flags;
100 bool is_virtual;
Tvrtko Ursulin20d89b42017-09-18 09:06:19 +0100101} intel_execution_engines2[];
102
Andi Shyti05ee0b12019-05-22 14:50:53 +0100103int gem_execbuf_flags_to_engine_class(unsigned int flags);
104
Chris Wilson16bafdf2014-09-04 09:26:24 +0100105#endif /* IGT_GT_H */