1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2019 Intel Corporation
9 #include "intel_engine_types.h"
10 #include "intel_gt_types.h"
11 #include "intel_reset.h"
13 struct drm_i915_private;
16 #define GT_TRACE(gt, fmt, ...) do { \
17 const struct intel_gt *gt__ __maybe_unused = (gt); \
18 GEM_TRACE("%s " fmt, dev_name(gt__->i915->drm.dev), \
22 static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
24 return container_of(uc, struct intel_gt, uc);
27 static inline struct intel_gt *guc_to_gt(struct intel_guc *guc)
29 return container_of(guc, struct intel_gt, uc.guc);
32 static inline struct intel_gt *huc_to_gt(struct intel_huc *huc)
34 return container_of(huc, struct intel_gt, uc.huc);
37 void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
38 void __intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
39 void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt);
40 int intel_gt_probe_lmem(struct intel_gt *gt);
41 int intel_gt_init_mmio(struct intel_gt *gt);
42 int __must_check intel_gt_init_hw(struct intel_gt *gt);
43 int intel_gt_init(struct intel_gt *gt);
44 void intel_gt_driver_register(struct intel_gt *gt);
46 void intel_gt_driver_unregister(struct intel_gt *gt);
47 void intel_gt_driver_remove(struct intel_gt *gt);
48 void intel_gt_driver_release(struct intel_gt *gt);
50 void intel_gt_driver_late_release(struct intel_gt *gt);
52 int intel_gt_wait_for_idle(struct intel_gt *gt, long timeout);
54 void intel_gt_check_and_clear_faults(struct intel_gt *gt);
55 void intel_gt_clear_error_registers(struct intel_gt *gt,
56 intel_engine_mask_t engine_mask);
58 void intel_gt_flush_ggtt_writes(struct intel_gt *gt);
59 void intel_gt_chipset_flush(struct intel_gt *gt);
61 static inline u32 intel_gt_scratch_offset(const struct intel_gt *gt,
62 enum intel_gt_scratch_field field)
64 return i915_ggtt_offset(gt->scratch) + field;
67 static inline bool intel_gt_has_unrecoverable_error(const struct intel_gt *gt)
69 return test_bit(I915_WEDGED_ON_INIT, >->reset.flags) ||
70 test_bit(I915_WEDGED_ON_FINI, >->reset.flags);
73 static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
75 GEM_BUG_ON(intel_gt_has_unrecoverable_error(gt) &&
76 !test_bit(I915_WEDGED, >->reset.flags));
78 return unlikely(test_bit(I915_WEDGED, >->reset.flags));
81 static inline bool intel_gt_needs_read_steering(struct intel_gt *gt,
82 enum intel_steering_type type)
84 return gt->steering_table[type];
87 u32 intel_gt_read_register_fw(struct intel_gt *gt, i915_reg_t reg);
89 void intel_gt_info_print(const struct intel_gt_info *info,
90 struct drm_printer *p);
92 void intel_gt_watchdog_work(struct work_struct *work);
94 void intel_gt_invalidate_tlbs(struct intel_gt *gt);
96 #endif /* __INTEL_GT_H__ */