intel_gt.h revision 1.1
1/*	$NetBSD: intel_gt.h,v 1.1 2021/12/18 20:15:32 riastradh Exp $	*/
2
3/* SPDX-License-Identifier: MIT */
4/*
5 * Copyright �� 2019 Intel Corporation
6 */
7
8#ifndef __INTEL_GT__
9#define __INTEL_GT__
10
11#include "intel_engine_types.h"
12#include "intel_gt_types.h"
13#include "intel_reset.h"
14
15struct drm_i915_private;
16
17#define GT_TRACE(gt, fmt, ...) do {					\
18	const struct intel_gt *gt__ __maybe_unused = (gt);		\
19	GEM_TRACE("%s  " fmt, dev_name(gt__->i915->drm.dev),		\
20		  ##__VA_ARGS__);					\
21} while (0)
22
23static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
24{
25	return container_of(uc, struct intel_gt, uc);
26}
27
28static inline struct intel_gt *guc_to_gt(struct intel_guc *guc)
29{
30	return container_of(guc, struct intel_gt, uc.guc);
31}
32
33static inline struct intel_gt *huc_to_gt(struct intel_huc *huc)
34{
35	return container_of(huc, struct intel_gt, uc.huc);
36}
37
38void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
39void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt);
40int __must_check intel_gt_init_hw(struct intel_gt *gt);
41int intel_gt_init(struct intel_gt *gt);
42void intel_gt_driver_register(struct intel_gt *gt);
43
44void intel_gt_driver_unregister(struct intel_gt *gt);
45void intel_gt_driver_remove(struct intel_gt *gt);
46void intel_gt_driver_release(struct intel_gt *gt);
47
48void intel_gt_driver_late_release(struct intel_gt *gt);
49
50void intel_gt_check_and_clear_faults(struct intel_gt *gt);
51void intel_gt_clear_error_registers(struct intel_gt *gt,
52				    intel_engine_mask_t engine_mask);
53
54void intel_gt_flush_ggtt_writes(struct intel_gt *gt);
55void intel_gt_chipset_flush(struct intel_gt *gt);
56
57static inline u32 intel_gt_scratch_offset(const struct intel_gt *gt,
58					  enum intel_gt_scratch_field field)
59{
60	return i915_ggtt_offset(gt->scratch) + field;
61}
62
63static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
64{
65	return __intel_reset_failed(&gt->reset);
66}
67
68static inline bool intel_gt_has_init_error(const struct intel_gt *gt)
69{
70	return test_bit(I915_WEDGED_ON_INIT, &gt->reset.flags);
71}
72
73#endif /* __INTEL_GT_H__ */
74