1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2014-2019 Intel Corporation
10 #include "intel_guc_submission.h"
11 #include "intel_huc.h"
12 #include "i915_params.h"
17 int (*sanitize)(struct intel_uc *uc);
18 void (*init_fw)(struct intel_uc *uc);
19 void (*fini_fw)(struct intel_uc *uc);
20 int (*init)(struct intel_uc *uc);
21 void (*fini)(struct intel_uc *uc);
22 int (*init_hw)(struct intel_uc *uc);
23 void (*fini_hw)(struct intel_uc *uc);
27 struct intel_uc_ops const *ops;
31 /* Snapshot of GuC log from last failed load */
32 struct drm_i915_gem_object *load_err_log;
35 void intel_uc_init_early(struct intel_uc *uc);
36 void intel_uc_driver_late_release(struct intel_uc *uc);
37 void intel_uc_init_mmio(struct intel_uc *uc);
38 void intel_uc_reset_prepare(struct intel_uc *uc);
39 void intel_uc_suspend(struct intel_uc *uc);
40 void intel_uc_runtime_suspend(struct intel_uc *uc);
41 int intel_uc_resume(struct intel_uc *uc);
42 int intel_uc_runtime_resume(struct intel_uc *uc);
45 * We need to know as early as possible if we're going to use GuC or not to
46 * take the correct setup paths. Additionally, once we've started loading the
47 * GuC, it is unsafe to keep executing without it because some parts of the HW,
48 * a subset of which is not cleaned on GT reset, will start expecting the GuC FW
50 * To solve both these requirements, we commit to using the microcontrollers if
51 * the relevant modparam is set and the blobs are found on the system. At this
52 * stage, the only thing that can stop us from attempting to load the blobs on
53 * the HW and use them is a fundamental issue (e.g. no memory for our
54 * structures); if we hit such a problem during driver load we're broken even
55 * without GuC, so there is no point in trying to fall back.
57 * Given the above, we can be in one of 4 states, with the last one implying
58 * we're committed to using the microcontroller:
59 * - Not supported: not available in HW and/or firmware not defined.
60 * - Supported: available in HW and firmware defined.
61 * - Wanted: supported + enabled in modparam.
62 * - In use: wanted + firmware found on the system and successfully fetched.
65 #define __uc_state_checker(x, func, state, required) \
66 static inline bool intel_uc_##state##_##func(struct intel_uc *uc) \
68 return intel_##func##_is_##required(&uc->x); \
71 #define uc_state_checkers(x, func) \
72 __uc_state_checker(x, func, supports, supported) \
73 __uc_state_checker(x, func, wants, wanted) \
74 __uc_state_checker(x, func, uses, used)
76 uc_state_checkers(guc, guc);
77 uc_state_checkers(huc, huc);
78 uc_state_checkers(guc, guc_submission);
80 #undef uc_state_checkers
81 #undef __uc_state_checker
83 #define intel_uc_ops_function(_NAME, _OPS, _TYPE, _RET) \
84 static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
87 return uc->ops->_OPS(uc); \
90 intel_uc_ops_function(sanitize, sanitize, int, 0);
91 intel_uc_ops_function(fetch_firmwares, init_fw, void, );
92 intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
93 intel_uc_ops_function(init, init, int, 0);
94 intel_uc_ops_function(fini, fini, void, );
95 intel_uc_ops_function(init_hw, init_hw, int, 0);
96 intel_uc_ops_function(fini_hw, fini_hw, void, );
97 #undef intel_uc_ops_function