linux/drivers/gpu/drm/i915/gt/intel_gt.h
<<
>>
Prefs
   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
  13struct drm_i915_private;
  14struct drm_printer;
  15
  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),             \
  19                  ##__VA_ARGS__);                                       \
  20} while (0)
  21
  22static inline struct intel_gt *uc_to_gt(struct intel_uc *uc)
  23{
  24        return container_of(uc, struct intel_gt, uc);
  25}
  26
  27static inline struct intel_gt *guc_to_gt(struct intel_guc *guc)
  28{
  29        return container_of(guc, struct intel_gt, uc.guc);
  30}
  31
  32static inline struct intel_gt *huc_to_gt(struct intel_huc *huc)
  33{
  34        return container_of(huc, struct intel_gt, uc.huc);
  35}
  36
  37void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915);
  38void intel_gt_init_hw_early(struct intel_gt *gt, struct i915_ggtt *ggtt);
  39int intel_gt_probe_lmem(struct intel_gt *gt);
  40int intel_gt_init_mmio(struct intel_gt *gt);
  41int __must_check intel_gt_init_hw(struct intel_gt *gt);
  42int intel_gt_init(struct intel_gt *gt);
  43void intel_gt_driver_register(struct intel_gt *gt);
  44
  45void intel_gt_driver_unregister(struct intel_gt *gt);
  46void intel_gt_driver_remove(struct intel_gt *gt);
  47void intel_gt_driver_release(struct intel_gt *gt);
  48
  49void intel_gt_driver_late_release(struct intel_gt *gt);
  50
  51int intel_gt_wait_for_idle(struct intel_gt *gt, long timeout);
  52
  53void intel_gt_check_and_clear_faults(struct intel_gt *gt);
  54void intel_gt_clear_error_registers(struct intel_gt *gt,
  55                                    intel_engine_mask_t engine_mask);
  56
  57void intel_gt_flush_ggtt_writes(struct intel_gt *gt);
  58void intel_gt_chipset_flush(struct intel_gt *gt);
  59
  60static inline u32 intel_gt_scratch_offset(const struct intel_gt *gt,
  61                                          enum intel_gt_scratch_field field)
  62{
  63        return i915_ggtt_offset(gt->scratch) + field;
  64}
  65
  66static inline bool intel_gt_has_unrecoverable_error(const struct intel_gt *gt)
  67{
  68        return test_bit(I915_WEDGED_ON_INIT, &gt->reset.flags) ||
  69               test_bit(I915_WEDGED_ON_FINI, &gt->reset.flags);
  70}
  71
  72static inline bool intel_gt_is_wedged(const struct intel_gt *gt)
  73{
  74        GEM_BUG_ON(intel_gt_has_unrecoverable_error(gt) &&
  75                   !test_bit(I915_WEDGED, &gt->reset.flags));
  76
  77        return unlikely(test_bit(I915_WEDGED, &gt->reset.flags));
  78}
  79
  80static inline bool intel_gt_needs_read_steering(struct intel_gt *gt,
  81                                                enum intel_steering_type type)
  82{
  83        return gt->steering_table[type];
  84}
  85
  86u32 intel_gt_read_register_fw(struct intel_gt *gt, i915_reg_t reg);
  87
  88void intel_gt_info_print(const struct intel_gt_info *info,
  89                         struct drm_printer *p);
  90
  91void intel_gt_watchdog_work(struct work_struct *work);
  92
  93#endif /* __INTEL_GT_H__ */
  94