blob: 4fa49d21f2d31a368c7056d7d54deddb6ea4eec3 [file] [log] [blame]
Damien Lespiau51b63e32013-10-08 23:39:33 +01001/*
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 Lespiau4ba97dd2013-10-09 11:47:43 +010028#include <stdbool.h>
29#include <stdint.h>
Chris Wilson4bd9fe62014-05-05 10:57:12 +010030#include <stdio.h>
Damien Lespiauffa21072013-10-09 11:45:31 +010031
Daniel Vetter6cfcd712014-03-22 20:07:35 +010032enum pipe;
Damien Lespiau4ba97dd2013-10-09 11:47:43 +010033
Chris Wilson5cbb7142016-09-16 11:43:30 +010034const char *igt_debugfs_mount(void);
Chris Wilsone56ab792017-08-22 13:47:33 +010035char *igt_debugfs_path(int device, char *path, int pathlen);
Chris Wilson5cbb7142016-09-16 11:43:30 +010036
Chris Wilson58de7852017-03-24 18:11:08 +000037int igt_debugfs_dir(int device);
38
Chris Wilson83884e92017-03-21 17:16:03 +000039int igt_debugfs_open(int fd, const char *filename, int mode);
Chris Wilson83884e92017-03-21 17:16:03 +000040void __igt_debugfs_read(int fd, const char *filename, char *buf, int buf_size);
41bool igt_debugfs_search(int fd, const char *filename, const char *substring);
Paulo Zanoni995f2732015-07-13 14:04:25 -030042
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 Wilson83884e92017-03-21 17:16:03 +000051#define igt_debugfs_read(fd, filename, buf) \
52 __igt_debugfs_read(fd, (filename), (buf), sizeof(buf))
Damien Lespiau51b63e32013-10-08 23:39:33 +010053
Damien Lespiau4ba97dd2013-10-09 11:47:43 +010054/*
55 * Pipe CRC
56 */
57
Daniel Vetter98127682014-03-12 18:53:51 +010058/**
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 */
64typedef struct _igt_pipe_crc igt_pipe_crc_t;
65
Tomeu Vizosoa56a1f62016-09-08 09:31:09 +020066#define DRM_MAX_CRC_NR 10
Daniel Vetter98127682014-03-12 18:53:51 +010067/**
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 */
76typedef struct {
77 uint32_t frame;
Tomeu Vizosoa56a1f62016-09-08 09:31:09 +020078 bool has_valid_frame;
Daniel Vetter98127682014-03-12 18:53:51 +010079 int n_words;
Tomeu Vizosoa56a1f62016-09-08 09:31:09 +020080 uint32_t crc[DRM_MAX_CRC_NR];
Daniel Vetter98127682014-03-12 18:53:51 +010081} igt_crc_t;
82
83/**
84 * intel_pipe_crc_source:
Thomas Wood0874c772015-12-01 15:07:10 +000085 * @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 Vetter98127682014-03-12 18:53:51 +010096 *
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 Lespiau4ba97dd2013-10-09 11:47:43 +0100103enum 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 Vetter173a4cf2013-10-16 22:49:24 +0200108 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 Vetter84200712013-10-31 14:02:44 +0100113 INTEL_PIPE_CRC_SOURCE_AUTO,
Damien Lespiau4ba97dd2013-10-09 11:47:43 +0100114 INTEL_PIPE_CRC_SOURCE_MAX,
115};
116
Lyude68c59ce2016-12-17 05:50:13 -0500117void igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b);
Paul Kocialkowski7422d752017-07-19 16:46:06 +0300118bool igt_check_crc_equal(const igt_crc_t *a, const igt_crc_t *b);
Paul Kocialkowski34a54192017-07-19 16:46:08 +0300119char *igt_crc_to_string_extended(igt_crc_t *crc, char delimiter, int crc_size);
Damien Lespiau4ba97dd2013-10-09 11:47:43 +0100120char *igt_crc_to_string(igt_crc_t *crc);
121
Chris Wilson83884e92017-03-21 17:16:03 +0000122void igt_require_pipe_crc(int fd);
Damien Lespiau4ba97dd2013-10-09 11:47:43 +0100123igt_pipe_crc_t *
Chris Wilson83884e92017-03-21 17:16:03 +0000124igt_pipe_crc_new(int fd, enum pipe pipe, enum intel_pipe_crc_source source);
Ville Syrjälä90907452015-12-18 14:35:05 +0200125igt_pipe_crc_t *
Chris Wilson83884e92017-03-21 17:16:03 +0000126igt_pipe_crc_new_nonblock(int fd, enum pipe pipe, enum intel_pipe_crc_source source);
Damien Lespiau4ba97dd2013-10-09 11:47:43 +0100127void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
Daniel Vettera4d3a6c2013-12-06 10:48:25 +0100128void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
Damien Lespiau4ba97dd2013-10-09 11:47:43 +0100129void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
Ville Syrjälä90907452015-12-18 14:35:05 +0200130__attribute__((warn_unused_result))
131int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
132 igt_crc_t **out_crcs);
Damien Lespiau69541032014-02-06 16:17:38 +0000133void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
Damien Lespiau4ba97dd2013-10-09 11:47:43 +0100134
Chris Wilson83884e92017-03-21 17:16:03 +0000135void igt_hpd_storm_set_threshold(int fd, unsigned int threshold);
136void igt_hpd_storm_reset(int fd);
137bool igt_hpd_storm_detected(int fd);
138void igt_require_hpd_storm_ctl(int fd);
Lyudea8ea5dd2017-02-22 21:16:16 -0500139
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000140/*
141 * Drop caches
142 */
143
Daniel Vetter98127682014-03-12 18:53:51 +0100144/**
145 * DROP_UNBOUND:
146 *
147 * Drop all currently unbound gem buffer objects from the cache.
148 */
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000149#define DROP_UNBOUND 0x1
Daniel Vetter98127682014-03-12 18:53:51 +0100150/**
151 * DROP_BOUND:
152 *
153 * Drop all inactive objects which are bound into some gpu address space.
154 */
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000155#define DROP_BOUND 0x2
Daniel Vetter98127682014-03-12 18:53:51 +0100156/**
157 * DROP_RETIRE:
158 *
159 * Wait for all outstanding gpu commands to complete, but do not take any
160 * further actions.
161 */
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000162#define DROP_RETIRE 0x4
Daniel Vetter98127682014-03-12 18:53:51 +0100163/**
164 * DROP_ACTIVE:
165 *
166 * Also drop active objects once retired.
167 */
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000168#define DROP_ACTIVE 0x8
Daniel Vetter734ae3e2016-07-27 13:12:12 +0200169/**
Chris Wilson9690d0a2016-04-06 21:50:12 +0100170 * DROP_FREED:
171 *
172 * Also drop freed objects.
173 */
174#define DROP_FREED 0x10
175/**
Chris Wilsone8eb9af2017-03-08 13:09:00 +0000176 * 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 Vetter734ae3e2016-07-27 13:12:12 +0200183 * DROP_ALL:
184 *
185 * All of the above DROP_ flags combined.
186 */
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000187#define DROP_ALL (DROP_UNBOUND | \
188 DROP_BOUND | \
Chris Wilsone8eb9af2017-03-08 13:09:00 +0000189 DROP_SHRINK_ALL | \
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000190 DROP_RETIRE | \
Chris Wilson9690d0a2016-04-06 21:50:12 +0100191 DROP_ACTIVE | \
192 DROP_FREED)
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000193
Chris Wilson83884e92017-03-21 17:16:03 +0000194bool igt_drop_caches_has(int fd, uint64_t val);
195void igt_drop_caches_set(int fd, uint64_t val);
Oscar Mateo5f0ab942013-11-04 16:30:47 +0000196
Daniel Vetteradb28fd2014-03-12 16:53:47 +0100197/*
198 * Prefault control
199 */
200
201void igt_disable_prefault(void);
202void igt_enable_prefault(void);
203
Derek Morton3953d2d2015-12-14 09:59:17 +0000204/*
205 * Put the driver into a stable (quiescent) state and get the current number of
206 * gem buffer objects
207 */
208int igt_get_stable_obj_count(int driver);
Chris Wilson721d8742016-10-27 11:32:47 +0100209void igt_debugfs_dump(int device, const char *filename);
Chris Wilson8deba382016-06-20 19:21:26 +0100210
Damien Lespiau51b63e32013-10-08 23:39:33 +0100211#endif /* __IGT_DEBUGFS_H__ */