igt_gt.h 3.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * Copyright © 2014 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef IGT_GT_H
#define IGT_GT_H

27
#include "igt_debugfs.h"
28
#include "igt_dummyload.h"
29
#include "igt_core.h"
30

31 32
#include "i915_drm.h"

33
void igt_require_hang_ring(int fd, int ring);
34

35
typedef struct igt_hang {
36
	igt_spin_t *spin;
37
	unsigned ctx;
38
	unsigned ban;
39
	unsigned flags;
40 41 42 43
} igt_hang_t;

igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags);
void igt_disallow_hang(int fd, igt_hang_t arg);
44

45 46
#define HANG_POISON 0xc5c5c5c5

47
igt_hang_t igt_hang_ctx(int fd, uint32_t ctx, int ring, unsigned flags);
48 49 50
#define HANG_ALLOW_BAN 1
#define HANG_ALLOW_CAPTURE 2

51 52
igt_hang_t igt_hang_ring(int fd, int ring);
void igt_post_hang_ring(int fd, igt_hang_t arg);
53

54
void igt_force_gpu_reset(int fd);
55

56
void igt_fork_hang_helper(void);
57 58
void igt_stop_hang_helper(void);

59
int igt_open_forcewake_handle(int fd);
60

61 62 63
int igt_setup_clflush(void);
void igt_clflush_range(void *addr, int size);

64 65
unsigned intel_detect_and_clear_missed_interrupts(int fd);

66 67
#define ALL_ENGINES ~0u /* Use in interfaces to iterate all engines */

68 69
extern const struct intel_execution_engine {
	const char *name;
70
	const char *full_name;
71 72 73 74
	unsigned exec_id;
	unsigned flags;
} intel_execution_engines[];

75 76 77 78 79 80
#define for_if(expr__) if (!(expr__)) {} else

#define for_each_engine(fd__, flags__) \
	for (const struct intel_execution_engine *e__ = intel_execution_engines;\
	     e__->name; \
	     e__++) \
Chris Wilson's avatar
Chris Wilson committed
81
		for_if (gem_has_ring(fd__, flags__ = e__->exec_id | e__->flags))
82

83 84 85 86 87 88 89 90 91
#define for_each_physical_engine(fd__, flags__) \
	for (const struct intel_execution_engine *e__ = intel_execution_engines;\
	     e__->name; \
	     e__++) \
		for_if (gem_ring_has_physical_engine(fd__, flags__ = e__->exec_id | e__->flags))

bool gem_ring_is_physical_engine(int fd, unsigned int ring);
bool gem_ring_has_physical_engine(int fd, unsigned int ring);

92
bool gem_can_store_dword(int fd, unsigned int engine);
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
extern const struct intel_execution_engine2 {
	const char *name;
	int class;
	int instance;
} intel_execution_engines2[];

unsigned int
gem_class_instance_to_eb_flags(int gem_fd,
			       enum drm_i915_gem_engine_class class,
			       unsigned int instance);

bool gem_has_engine(int gem_fd,
		    enum drm_i915_gem_engine_class class,
		    unsigned int instance);

static inline
void gem_require_engine(int gem_fd,
			enum drm_i915_gem_engine_class class,
			unsigned int instance)
{
	igt_require(gem_has_engine(gem_fd, class, instance));
}

117 118 119 120 121 122 123
#define __for_each_engine_class_instance(fd__, e__) \
	for ((e__) = intel_execution_engines2; (e__)->name; (e__)++)

#define for_each_engine_class_instance(fd__, e__) \
	for ((e__) = intel_execution_engines2; (e__)->name; (e__)++) \
		for_if (gem_has_engine((fd__), (e__)->class, (e__)->instance))

124
#endif /* IGT_GT_H */