blob: 3d81ec95fb21873b78a970f264964327463af50d [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"
28
Daniel Vetterc66b2422015-02-06 10:49:20 +010029void igt_require_hang_ring(int fd, int ring);
Chris Wilson16bafdf2014-09-04 09:26:24 +010030
Daniel Vetter3cd45de2015-02-10 17:46:43 +010031typedef struct igt_hang_ring {
Chris Wilson16bafdf2014-09-04 09:26:24 +010032 unsigned handle;
Chris Wilson19642c62015-12-11 13:27:49 +000033 unsigned ctx;
Chris Wilson16bafdf2014-09-04 09:26:24 +010034 unsigned ban;
Chris Wilson19642c62015-12-11 13:27:49 +000035 unsigned flags;
Daniel Vetter3cd45de2015-02-10 17:46:43 +010036} igt_hang_ring_t;
37
Chris Wilson19642c62015-12-11 13:27:49 +000038#define HANG_POISON 0xc5c5c5c5
39
40struct igt_hang_ring igt_hang_ctx(int fd,
41 uint32_t ctx,
42 int ring,
43 unsigned flags,
44 uint64_t *offset);
45#define HANG_ALLOW_BAN 1
46#define HANG_ALLOW_CAPTURE 2
47
Daniel Vetter3cd45de2015-02-10 17:46:43 +010048struct igt_hang_ring igt_hang_ring(int fd, int ring);
Thomas Wood26f40812015-02-20 11:31:01 +000049void igt_post_hang_ring(int fd, struct igt_hang_ring arg);
Chris Wilson16bafdf2014-09-04 09:26:24 +010050
Daniel Vetterd8d1eab2015-12-03 07:45:34 +010051void igt_fork_hang_helper(void);
Daniel Vetter3cd45de2015-02-10 17:46:43 +010052void igt_stop_hang_helper(void);
53
54int igt_open_forcewake_handle(void);
55
56/**
57 * stop_ring_flags:
58 * @STOP_RING_NONE: Can be used to clear the pending stop (warning: hang might
59 * be declared already). Returned by igt_get_stop_rings() if there is
60 * no currently stopped rings.
61 * @STOP_RING_RENDER: Render ring
62 * @STOP_RING_BSD: Video encoding/decoding ring
63 * @STOP_RING_BLT: Blitter ring
64 * @STOP_RING_VEBOX: Video enhancement ring
65 * @STOP_RING_ALL: All rings
66 * @STOP_RING_ALLOW_ERRORS: Driver will not omit expected DRM_ERRORS
67 * @STOP_RING_ALLOW_BAN: Driver will use context ban policy
68 * @STOP_RING_DEFAULTS: STOP_RING_ALL | STOP_RING_ALLOW_ERRORS
69 *
70 * Enumeration of all supported flags for igt_set_stop_rings().
71 *
72 */
73enum stop_ring_flags {
74 STOP_RING_NONE = 0x00,
75 STOP_RING_RENDER = (1 << 0),
76 STOP_RING_BSD = (1 << 1),
77 STOP_RING_BLT = (1 << 2),
78 STOP_RING_VEBOX = (1 << 3),
79 STOP_RING_ALL = 0xff,
80 STOP_RING_ALLOW_ERRORS = (1 << 30),
81 STOP_RING_ALLOW_BAN = (1 << 31),
82 STOP_RING_DEFAULTS = STOP_RING_ALL | STOP_RING_ALLOW_ERRORS,
83};
84
85enum stop_ring_flags igt_to_stop_ring_flag(int ring);
86void igt_set_stop_rings(enum stop_ring_flags flags);
87enum stop_ring_flags igt_get_stop_rings(void);
88
Chris Wilsona6090c72016-01-08 16:32:29 +000089int igt_setup_clflush(void);
90void igt_clflush_range(void *addr, int size);
91
Chris Wilson16bafdf2014-09-04 09:26:24 +010092#endif /* IGT_GT_H */