Damien Lespiau | 51b63e3 | 2013-10-08 23:39:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2013 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 | |
| 25 | #ifndef __IGT_DEBUGFS_H__ |
| 26 | #define __IGT_DEBUGFS_H__ |
| 27 | |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 28 | #include <stdbool.h> |
| 29 | #include <stdint.h> |
Chris Wilson | 4bd9fe6 | 2014-05-05 10:57:12 +0100 | [diff] [blame] | 30 | #include <stdio.h> |
Damien Lespiau | ffa2107 | 2013-10-09 11:45:31 +0100 | [diff] [blame] | 31 | |
Daniel Vetter | 6cfcd71 | 2014-03-22 20:07:35 +0100 | [diff] [blame] | 32 | enum pipe; |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 33 | |
Chris Wilson | 5cbb714 | 2016-09-16 11:43:30 +0100 | [diff] [blame] | 34 | const char *igt_debugfs_mount(void); |
Chris Wilson | e56ab79 | 2017-08-22 13:47:33 +0100 | [diff] [blame] | 35 | char *igt_debugfs_path(int device, char *path, int pathlen); |
Chris Wilson | 5cbb714 | 2016-09-16 11:43:30 +0100 | [diff] [blame] | 36 | |
Chris Wilson | 58de785 | 2017-03-24 18:11:08 +0000 | [diff] [blame] | 37 | int igt_debugfs_dir(int device); |
| 38 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 39 | int igt_debugfs_open(int fd, const char *filename, int mode); |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 40 | void __igt_debugfs_read(int fd, const char *filename, char *buf, int buf_size); |
| 41 | bool igt_debugfs_search(int fd, const char *filename, const char *substring); |
Paulo Zanoni | 995f273 | 2015-07-13 14:04:25 -0300 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * igt_debugfs_read: |
| 45 | * @filename: name of the debugfs file |
| 46 | * @buf: buffer where the contents will be stored, allocated by the caller. |
| 47 | * |
| 48 | * This is just a convenience wrapper for __igt_debugfs_read. See its |
| 49 | * documentation. |
| 50 | */ |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 51 | #define igt_debugfs_read(fd, filename, buf) \ |
| 52 | __igt_debugfs_read(fd, (filename), (buf), sizeof(buf)) |
Damien Lespiau | 51b63e3 | 2013-10-08 23:39:33 +0100 | [diff] [blame] | 53 | |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 54 | /* |
| 55 | * Pipe CRC |
| 56 | */ |
| 57 | |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 58 | /** |
| 59 | * igt_pipe_crc_t: |
| 60 | * |
| 61 | * Pipe CRC support structure. Needs to be allocated and set up with |
| 62 | * igt_pipe_crc_new() for a specific pipe and pipe CRC source value. |
| 63 | */ |
| 64 | typedef struct _igt_pipe_crc igt_pipe_crc_t; |
| 65 | |
Tomeu Vizoso | a56a1f6 | 2016-09-08 09:31:09 +0200 | [diff] [blame] | 66 | #define DRM_MAX_CRC_NR 10 |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 67 | /** |
| 68 | * igt_crc_t: |
| 69 | * @frame: frame number of the capture CRC |
| 70 | * @n_words: internal field, don't access |
| 71 | * @crc: internal field, don't access |
| 72 | * |
| 73 | * Pipe CRC value. All other members than @frame are private and should not be |
| 74 | * inspected by testcases. |
| 75 | */ |
| 76 | typedef struct { |
| 77 | uint32_t frame; |
Tomeu Vizoso | a56a1f6 | 2016-09-08 09:31:09 +0200 | [diff] [blame] | 78 | bool has_valid_frame; |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 79 | int n_words; |
Tomeu Vizoso | a56a1f6 | 2016-09-08 09:31:09 +0200 | [diff] [blame] | 80 | uint32_t crc[DRM_MAX_CRC_NR]; |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 81 | } igt_crc_t; |
| 82 | |
| 83 | /** |
| 84 | * intel_pipe_crc_source: |
Thomas Wood | 0874c77 | 2015-12-01 15:07:10 +0000 | [diff] [blame] | 85 | * @INTEL_PIPE_CRC_SOURCE_NONE: No source |
| 86 | * @INTEL_PIPE_CRC_SOURCE_PLANE1: Plane 1 |
| 87 | * @INTEL_PIPE_CRC_SOURCE_PLANE2: Plane 2 |
| 88 | * @INTEL_PIPE_CRC_SOURCE_PF: Panel Filter |
| 89 | * @INTEL_PIPE_CRC_SOURCE_PIPE: Pipe |
| 90 | * @INTEL_PIPE_CRC_SOURCE_TV: TV |
| 91 | * @INTEL_PIPE_CRC_SOURCE_DP_B: DisplayPort B |
| 92 | * @INTEL_PIPE_CRC_SOURCE_DP_C: DisplayPort C |
| 93 | * @INTEL_PIPE_CRC_SOURCE_DP_D: DisplayPort D |
| 94 | * @INTEL_PIPE_CRC_SOURCE_AUTO: Automatic source selection |
| 95 | * @INTEL_PIPE_CRC_SOURCE_MAX: Number of available sources |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 96 | * |
| 97 | * Enumeration of all supported pipe CRC sources. Not all platforms and all |
| 98 | * outputs support all of them. Generic tests should just use |
| 99 | * INTEL_PIPE_CRC_SOURCE_AUTO. It should always map to an end-of-pipe CRC |
| 100 | * suitable for checking planes, cursor, color correction and any other |
| 101 | * output-agnostic features. |
| 102 | */ |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 103 | enum intel_pipe_crc_source { |
| 104 | INTEL_PIPE_CRC_SOURCE_NONE, |
| 105 | INTEL_PIPE_CRC_SOURCE_PLANE1, |
| 106 | INTEL_PIPE_CRC_SOURCE_PLANE2, |
| 107 | INTEL_PIPE_CRC_SOURCE_PF, |
Daniel Vetter | 173a4cf | 2013-10-16 22:49:24 +0200 | [diff] [blame] | 108 | INTEL_PIPE_CRC_SOURCE_PIPE, |
| 109 | INTEL_PIPE_CRC_SOURCE_TV, |
| 110 | INTEL_PIPE_CRC_SOURCE_DP_B, |
| 111 | INTEL_PIPE_CRC_SOURCE_DP_C, |
| 112 | INTEL_PIPE_CRC_SOURCE_DP_D, |
Daniel Vetter | 8420071 | 2013-10-31 14:02:44 +0100 | [diff] [blame] | 113 | INTEL_PIPE_CRC_SOURCE_AUTO, |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 114 | INTEL_PIPE_CRC_SOURCE_MAX, |
| 115 | }; |
| 116 | |
Lyude | 68c59ce | 2016-12-17 05:50:13 -0500 | [diff] [blame] | 117 | void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b); |
Paul Kocialkowski | 7422d75 | 2017-07-19 16:46:06 +0300 | [diff] [blame] | 118 | bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b); |
Paul Kocialkowski | 34a5419 | 2017-07-19 16:46:08 +0300 | [diff] [blame] | 119 | char *igt_crc_to_string_extended(igt_crc_t *crc, char delimiter, int crc_size); |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 120 | char *igt_crc_to_string(igt_crc_t *crc); |
| 121 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 122 | void igt_require_pipe_crc(int fd); |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 123 | igt_pipe_crc_t * |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 124 | igt_pipe_crc_new(int fd, enum pipe pipe, enum intel_pipe_crc_source source); |
Ville Syrjälä | 9090745 | 2015-12-18 14:35:05 +0200 | [diff] [blame] | 125 | igt_pipe_crc_t * |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 126 | igt_pipe_crc_new_nonblock(int fd, enum pipe pipe, enum intel_pipe_crc_source source); |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 127 | void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc); |
Daniel Vetter | a4d3a6c | 2013-12-06 10:48:25 +0100 | [diff] [blame] | 128 | void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc); |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 129 | void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc); |
Ville Syrjälä | 9090745 | 2015-12-18 14:35:05 +0200 | [diff] [blame] | 130 | __attribute__((warn_unused_result)) |
| 131 | int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs, |
| 132 | igt_crc_t **out_crcs); |
Damien Lespiau | 6954103 | 2014-02-06 16:17:38 +0000 | [diff] [blame] | 133 | void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc); |
Damien Lespiau | 4ba97dd | 2013-10-09 11:47:43 +0100 | [diff] [blame] | 134 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 135 | void igt_hpd_storm_set_threshold(int fd, unsigned int threshold); |
| 136 | void igt_hpd_storm_reset(int fd); |
| 137 | bool igt_hpd_storm_detected(int fd); |
| 138 | void igt_require_hpd_storm_ctl(int fd); |
Lyude | a8ea5dd | 2017-02-22 21:16:16 -0500 | [diff] [blame] | 139 | |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 140 | /* |
| 141 | * Drop caches |
| 142 | */ |
| 143 | |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 144 | /** |
| 145 | * DROP_UNBOUND: |
| 146 | * |
| 147 | * Drop all currently unbound gem buffer objects from the cache. |
| 148 | */ |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 149 | #define DROP_UNBOUND 0x1 |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 150 | /** |
| 151 | * DROP_BOUND: |
| 152 | * |
| 153 | * Drop all inactive objects which are bound into some gpu address space. |
| 154 | */ |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 155 | #define DROP_BOUND 0x2 |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 156 | /** |
| 157 | * DROP_RETIRE: |
| 158 | * |
| 159 | * Wait for all outstanding gpu commands to complete, but do not take any |
| 160 | * further actions. |
| 161 | */ |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 162 | #define DROP_RETIRE 0x4 |
Daniel Vetter | 9812768 | 2014-03-12 18:53:51 +0100 | [diff] [blame] | 163 | /** |
| 164 | * DROP_ACTIVE: |
| 165 | * |
| 166 | * Also drop active objects once retired. |
| 167 | */ |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 168 | #define DROP_ACTIVE 0x8 |
Daniel Vetter | 734ae3e | 2016-07-27 13:12:12 +0200 | [diff] [blame] | 169 | /** |
Chris Wilson | 9690d0a | 2016-04-06 21:50:12 +0100 | [diff] [blame] | 170 | * DROP_FREED: |
| 171 | * |
| 172 | * Also drop freed objects. |
| 173 | */ |
| 174 | #define DROP_FREED 0x10 |
| 175 | /** |
Chris Wilson | e8eb9af | 2017-03-08 13:09:00 +0000 | [diff] [blame] | 176 | * DROP_SHRINK_ALL: |
| 177 | * |
| 178 | * Force all unpinned buffers to be evicted from their GTT and returned to the |
| 179 | * system. |
| 180 | */ |
| 181 | #define DROP_SHRINK_ALL 0x20 |
| 182 | /** |
Daniel Vetter | 734ae3e | 2016-07-27 13:12:12 +0200 | [diff] [blame] | 183 | * DROP_ALL: |
| 184 | * |
| 185 | * All of the above DROP_ flags combined. |
| 186 | */ |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 187 | #define DROP_ALL (DROP_UNBOUND | \ |
| 188 | DROP_BOUND | \ |
Chris Wilson | e8eb9af | 2017-03-08 13:09:00 +0000 | [diff] [blame] | 189 | DROP_SHRINK_ALL | \ |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 190 | DROP_RETIRE | \ |
Chris Wilson | 9690d0a | 2016-04-06 21:50:12 +0100 | [diff] [blame] | 191 | DROP_ACTIVE | \ |
| 192 | DROP_FREED) |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 193 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 194 | bool igt_drop_caches_has(int fd, uint64_t val); |
| 195 | void igt_drop_caches_set(int fd, uint64_t val); |
Oscar Mateo | 5f0ab94 | 2013-11-04 16:30:47 +0000 | [diff] [blame] | 196 | |
Daniel Vetter | adb28fd | 2014-03-12 16:53:47 +0100 | [diff] [blame] | 197 | /* |
| 198 | * Prefault control |
| 199 | */ |
| 200 | |
| 201 | void igt_disable_prefault(void); |
| 202 | void igt_enable_prefault(void); |
| 203 | |
Derek Morton | 3953d2d | 2015-12-14 09:59:17 +0000 | [diff] [blame] | 204 | /* |
| 205 | * Put the driver into a stable (quiescent) state and get the current number of |
| 206 | * gem buffer objects |
| 207 | */ |
| 208 | int igt_get_stable_obj_count(int driver); |
Chris Wilson | 721d874 | 2016-10-27 11:32:47 +0100 | [diff] [blame] | 209 | void igt_debugfs_dump(int device, const char *filename); |
Chris Wilson | 8deba38 | 2016-06-20 19:21:26 +0100 | [diff] [blame] | 210 | |
Damien Lespiau | 51b63e3 | 2013-10-08 23:39:33 +0100 | [diff] [blame] | 211 | #endif /* __IGT_DEBUGFS_H__ */ |