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 28 #include <stdbool.h> 29 #include <stdint.h> 30 #include <stdio.h> 31 32 enum pipe; 33 34 const char *igt_debugfs_mount(void); 35 char *igt_debugfs_path(int device, char *path, int pathlen); 36 37 int igt_debugfs_dir(int device); 38 int igt_debugfs_connector_dir(int device, char *conn_name, int mode); 39 40 int igt_debugfs_open(int fd, const char *filename, int mode); 41 void __igt_debugfs_read(int fd, const char *filename, char *buf, int size); 42 int igt_debugfs_simple_read(int dir, const char *filename, char *buf, int size); 43 bool igt_debugfs_search(int fd, const char *filename, const char *substring); 44 45 /** 46 * igt_debugfs_read: 47 * @filename: name of the debugfs file 48 * @buf: buffer where the contents will be stored, allocated by the caller. 49 * 50 * This is just a convenience wrapper for __igt_debugfs_read. See its 51 * documentation. 52 */ 53 #define igt_debugfs_read(fd, filename, buf) \ 54 __igt_debugfs_read(fd, (filename), (buf), sizeof(buf)) 55 56 /* 57 * Pipe CRC 58 */ 59 60 /** 61 * igt_pipe_crc_t: 62 * 63 * Pipe CRC support structure. Needs to be allocated and set up with 64 * igt_pipe_crc_new() for a specific pipe and pipe CRC source value. 65 */ 66 typedef struct _igt_pipe_crc igt_pipe_crc_t; 67 68 #define DRM_MAX_CRC_NR 10 69 /** 70 * igt_crc_t: 71 * @frame: frame number of the capture CRC 72 * @n_words: internal field, don't access 73 * @crc: internal field, don't access 74 * 75 * Pipe CRC value. All other members than @frame are private and should not be 76 * inspected by testcases. 77 */ 78 typedef struct { 79 uint32_t frame; 80 bool has_valid_frame; 81 int n_words; 82 uint32_t crc[DRM_MAX_CRC_NR]; 83 } igt_crc_t; 84 85 #define INTEL_PIPE_CRC_SOURCE_AUTO "auto" 86 #define AMDGPU_PIPE_CRC_SOURCE_DPRX "dprx" 87 88 void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b); 89 bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b); 90 char *igt_crc_to_string_extended(igt_crc_t *crc, char delimiter, int crc_size); 91 char *igt_crc_to_string(igt_crc_t *crc); 92 93 void igt_require_pipe_crc(int fd); 94 igt_pipe_crc_t * 95 igt_pipe_crc_new(int fd, enum pipe pipe, const char *source); 96 igt_pipe_crc_t * 97 igt_pipe_crc_new_nonblock(int fd, enum pipe pipe, const char *source); 98 void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc); 99 void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc); 100 void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc); 101 __attribute__((warn_unused_result)) 102 int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs, 103 igt_crc_t **out_crcs); 104 void igt_pipe_crc_drain(igt_pipe_crc_t *pipe_crc); 105 void igt_pipe_crc_get_single(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc); 106 void igt_pipe_crc_get_current(int drm_fd, igt_pipe_crc_t *pipe_crc, igt_crc_t *crc); 107 108 void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc); 109 110 void igt_hpd_storm_set_threshold(int fd, unsigned int threshold); 111 void igt_hpd_storm_reset(int fd); 112 bool igt_hpd_storm_detected(int fd); 113 void igt_require_hpd_storm_ctl(int fd); 114 115 /* 116 * Drop caches 117 */ 118 119 /** 120 * DROP_UNBOUND: 121 * 122 * Drop all currently unbound gem buffer objects from the cache. 123 */ 124 #define DROP_UNBOUND 0x1 125 /** 126 * DROP_BOUND: 127 * 128 * Drop all inactive objects which are bound into some gpu address space. 129 */ 130 #define DROP_BOUND 0x2 131 /** 132 * DROP_RETIRE: 133 * 134 * Wait for all outstanding gpu commands to complete, but do not take any 135 * further actions. 136 */ 137 #define DROP_RETIRE 0x4 138 /** 139 * DROP_ACTIVE: 140 * 141 * Also drop active objects once retired. 142 */ 143 #define DROP_ACTIVE 0x8 144 /** 145 * DROP_FREED: 146 * 147 * Also drop freed objects. 148 */ 149 #define DROP_FREED 0x10 150 /** 151 * DROP_SHRINK_ALL: 152 * 153 * Force all unpinned buffers to be evicted from their GTT and returned to the 154 * system. 155 */ 156 #define DROP_SHRINK_ALL 0x20 157 /** 158 * DROP_IDLE: 159 * 160 * Flush the driver's idle_worker, releasing internal caches and wakerefs. 161 */ 162 #define DROP_IDLE 0x40 163 /** 164 * DROP_RESET_ACTIVE: 165 * 166 * Cancel all outstanding requests by forcing a gpu reset 167 */ 168 #define DROP_RESET_ACTIVE 0x80 169 /** 170 * DROP_RESET_SEQNO: 171 * 172 * Reset the global request seqno counter back to 0 173 */ 174 #define DROP_RESET_SEQNO 0x100 175 /** 176 * DROP_ALL: 177 * 178 * All of the above DROP_ flags combined. 179 */ 180 #define DROP_ALL (DROP_UNBOUND | \ 181 DROP_BOUND | \ 182 DROP_SHRINK_ALL | \ 183 DROP_RETIRE | \ 184 DROP_ACTIVE | \ 185 DROP_FREED | \ 186 DROP_IDLE) 187 188 void igt_reset_fifo_underrun_reporting(int drm_fd); 189 190 bool igt_drop_caches_has(int fd, uint64_t val); 191 void igt_drop_caches_set(int fd, uint64_t val); 192 193 /* 194 * Prefault control 195 */ 196 197 void igt_disable_prefault(void); 198 void igt_enable_prefault(void); 199 200 /* 201 * Put the driver into a stable (quiescent) state and get the current number of 202 * gem buffer objects 203 */ 204 int igt_get_stable_obj_count(int driver); 205 void __igt_debugfs_dump(int device, const char *filename, int level); 206 #define igt_debugfs_dump(d, f) __igt_debugfs_dump(d, f, IGT_LOG_DEBUG) 207 208 #endif /* __IGT_DEBUGFS_H__ */ 209