Chris Wilson | 16bafdf | 2014-09-04 09:26:24 +0100 | [diff] [blame] | 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 | |
Daniel Vetter | 3cd45de | 2015-02-10 17:46:43 +0100 | [diff] [blame] | 27 | #include "igt_debugfs.h" |
Antonio Argenziano | 140a67c | 2018-07-10 16:45:26 -0700 | [diff] [blame] | 28 | #include "igt_dummyload.h" |
Tvrtko Ursulin | 20d89b4 | 2017-09-18 09:06:19 +0100 | [diff] [blame] | 29 | #include "igt_core.h" |
Daniel Vetter | 3cd45de | 2015-02-10 17:46:43 +0100 | [diff] [blame] | 30 | |
Lionel Landwerlin | a938797 | 2017-12-05 16:43:01 +0000 | [diff] [blame] | 31 | #include "i915_drm.h" |
| 32 | |
Daniel Vetter | c66b242 | 2015-02-06 10:49:20 +0100 | [diff] [blame] | 33 | void igt_require_hang_ring(int fd, int ring); |
Chris Wilson | 16bafdf | 2014-09-04 09:26:24 +0100 | [diff] [blame] | 34 | |
Chris Wilson | 0a1fc45 | 2016-09-13 11:13:14 +0100 | [diff] [blame] | 35 | typedef struct igt_hang { |
Antonio Argenziano | 140a67c | 2018-07-10 16:45:26 -0700 | [diff] [blame] | 36 | igt_spin_t *spin; |
Chris Wilson | 19642c6 | 2015-12-11 13:27:49 +0000 | [diff] [blame] | 37 | unsigned ctx; |
Chris Wilson | 16bafdf | 2014-09-04 09:26:24 +0100 | [diff] [blame] | 38 | unsigned ban; |
Chris Wilson | 19642c6 | 2015-12-11 13:27:49 +0000 | [diff] [blame] | 39 | unsigned flags; |
Chris Wilson | 0a1fc45 | 2016-09-13 11:13:14 +0100 | [diff] [blame] | 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); |
Daniel Vetter | 3cd45de | 2015-02-10 17:46:43 +0100 | [diff] [blame] | 44 | |
Chris Wilson | 19642c6 | 2015-12-11 13:27:49 +0000 | [diff] [blame] | 45 | #define HANG_POISON 0xc5c5c5c5 |
| 46 | |
Antonio Argenziano | 140a67c | 2018-07-10 16:45:26 -0700 | [diff] [blame] | 47 | igt_hang_t igt_hang_ctx(int fd, uint32_t ctx, int ring, unsigned flags); |
Chris Wilson | 19642c6 | 2015-12-11 13:27:49 +0000 | [diff] [blame] | 48 | #define HANG_ALLOW_BAN 1 |
| 49 | #define HANG_ALLOW_CAPTURE 2 |
| 50 | |
Chris Wilson | 0a1fc45 | 2016-09-13 11:13:14 +0100 | [diff] [blame] | 51 | igt_hang_t igt_hang_ring(int fd, int ring); |
| 52 | void igt_post_hang_ring(int fd, igt_hang_t arg); |
Chris Wilson | 16bafdf | 2014-09-04 09:26:24 +0100 | [diff] [blame] | 53 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 54 | void igt_force_gpu_reset(int fd); |
Daniele Ceraolo Spurio | 03c7f84 | 2016-03-01 11:01:32 +0000 | [diff] [blame] | 55 | |
Daniel Vetter | d8d1eab | 2015-12-03 07:45:34 +0100 | [diff] [blame] | 56 | void igt_fork_hang_helper(void); |
Daniel Vetter | 3cd45de | 2015-02-10 17:46:43 +0100 | [diff] [blame] | 57 | void igt_stop_hang_helper(void); |
| 58 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 59 | int igt_open_forcewake_handle(int fd); |
Daniel Vetter | 3cd45de | 2015-02-10 17:46:43 +0100 | [diff] [blame] | 60 | |
Chris Wilson | a6090c7 | 2016-01-08 16:32:29 +0000 | [diff] [blame] | 61 | int igt_setup_clflush(void); |
| 62 | void igt_clflush_range(void *addr, int size); |
| 63 | |
Chris Wilson | 5b675f7 | 2016-01-22 17:33:40 +0000 | [diff] [blame] | 64 | unsigned intel_detect_and_clear_missed_interrupts(int fd); |
| 65 | |
Antonio Argenziano | 94e8862 | 2018-03-19 15:30:38 -0700 | [diff] [blame] | 66 | #define ALL_ENGINES ~0u /* Use in interfaces to iterate all engines */ |
| 67 | |
Chris Wilson | 04f5215 | 2016-01-27 14:07:27 +0000 | [diff] [blame] | 68 | extern const struct intel_execution_engine { |
| 69 | const char *name; |
Chris Wilson | 38fe49d | 2016-02-04 11:17:42 +0000 | [diff] [blame] | 70 | const char *full_name; |
Chris Wilson | 04f5215 | 2016-01-27 14:07:27 +0000 | [diff] [blame] | 71 | unsigned exec_id; |
| 72 | unsigned flags; |
| 73 | } intel_execution_engines[]; |
| 74 | |
Chris Wilson | 697c3f5 | 2016-03-04 10:19:38 +0000 | [diff] [blame] | 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__++) \ |
Chris Wilson | 7472447 | 2017-01-05 11:43:15 +0000 | [diff] [blame] | 81 | for_if (gem_has_ring(fd__, flags__ = e__->exec_id | e__->flags)) |
Chris Wilson | 697c3f5 | 2016-03-04 10:19:38 +0000 | [diff] [blame] | 82 | |
Chris Wilson | 305ebce | 2018-02-21 14:13:16 +0000 | [diff] [blame] | 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 | |
Chris Wilson | bc78776 | 2017-05-18 12:11:59 +0100 | [diff] [blame] | 92 | bool gem_can_store_dword(int fd, unsigned int engine); |
Andi Shyti | 949f854 | 2019-05-22 14:50:54 +0100 | [diff] [blame] | 93 | bool gem_class_can_store_dword(int fd, int class); |
Chris Wilson | 697c3f5 | 2016-03-04 10:19:38 +0000 | [diff] [blame] | 94 | |
Tvrtko Ursulin | 20d89b4 | 2017-09-18 09:06:19 +0100 | [diff] [blame] | 95 | extern const struct intel_execution_engine2 { |
| 96 | const char *name; |
| 97 | int class; |
| 98 | int instance; |
Andi Shyti | 17c77e7 | 2019-05-22 14:50:52 +0100 | [diff] [blame] | 99 | uint64_t flags; |
| 100 | bool is_virtual; |
Tvrtko Ursulin | 20d89b4 | 2017-09-18 09:06:19 +0100 | [diff] [blame] | 101 | } intel_execution_engines2[]; |
| 102 | |
Andi Shyti | 05ee0b1 | 2019-05-22 14:50:53 +0100 | [diff] [blame] | 103 | int gem_execbuf_flags_to_engine_class(unsigned int flags); |
| 104 | |
Chris Wilson | 16bafdf | 2014-09-04 09:26:24 +0100 | [diff] [blame] | 105 | #endif /* IGT_GT_H */ |