1 /* SPDX-License-Identifier: MIT */
2 /*
3 * Copyright © 2019 Intel Corporation
4 */
5
6 #ifndef __INTEL_GT__
7 #define __INTEL_GT__
8
9 #include "intel_engine_types.h"
10 #include "intel_gt_types.h"
11 #include "intel_reset.h"
12
13 struct drm_i915_private;
14
uc_to_gt(struct intel_uc * uc)15 static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
16 {
17 return container_of(uc, struct intel_gt, uc);
18 }
19
guc_to_gt(struct intel_guc * guc)20 static inline struct intel_gt *guc_to_gt(struct intel_guc *guc)
21 {
22 return container_of(guc, struct intel_gt, uc.guc);
23 }
24
huc_to_gt(struct intel_huc * huc)25 static inline struct intel_gt *huc_to_gt(struct intel_huc *huc)
26 {
27 return container_of(huc, struct intel_gt, uc.huc);
28 }
29
30 void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
31 void intel_gt_init_hw(struct drm_i915_private *i915);
32
33 void intel_gt_driver_late_release(struct intel_gt *gt);
34
35 void intel_gt_check_and_clear_faults(struct intel_gt *gt);
36 void intel_gt_clear_error_registers(struct intel_gt *gt,
37 intel_engine_mask_t engine_mask);
38
39 void intel_gt_flush_ggtt_writes(struct intel_gt *gt);
40 void intel_gt_chipset_flush(struct intel_gt *gt);
41
42 void intel_gt_init_hangcheck(struct intel_gt *gt);
43
44 int intel_gt_init_scratch(struct intel_gt *gt, unsigned int size);
45 void intel_gt_fini_scratch(struct intel_gt *gt);
46
intel_gt_scratch_offset(const struct intel_gt * gt,enum intel_gt_scratch_field field)47 static inline u32 intel_gt_scratch_offset(const struct intel_gt *gt,
48 enum intel_gt_scratch_field field)
49 {
50 return i915_ggtt_offset(gt->scratch) + field;
51 }
52
intel_gt_is_wedged(struct intel_gt * gt)53 static inline bool intel_gt_is_wedged(struct intel_gt *gt)
54 {
55 return __intel_reset_failed(>->reset);
56 }
57
58 void intel_gt_queue_hangcheck(struct intel_gt *gt);
59
60 #endif /* __INTEL_GT_H__ */
61