122 lines · c
1/* SPDX-License-Identifier: MIT */2/*3 * Copyright © 2014-2019 Intel Corporation4 */5 6#ifndef _INTEL_UC_H_7#define _INTEL_UC_H_8 9#include "intel_gsc_uc.h"10#include "intel_guc.h"11#include "intel_guc_rc.h"12#include "intel_guc_submission.h"13#include "intel_guc_slpc.h"14#include "intel_huc.h"15#include "i915_params.h"16 17struct intel_uc;18 19struct intel_uc_ops {20 int (*sanitize)(struct intel_uc *uc);21 void (*init_fw)(struct intel_uc *uc);22 void (*fini_fw)(struct intel_uc *uc);23 int (*init)(struct intel_uc *uc);24 void (*fini)(struct intel_uc *uc);25 int (*init_hw)(struct intel_uc *uc);26 void (*fini_hw)(struct intel_uc *uc);27 void (*resume_mappings)(struct intel_uc *uc);28};29 30struct intel_uc {31 struct intel_uc_ops const *ops;32 struct intel_gsc_uc gsc;33 struct intel_guc guc;34 struct intel_huc huc;35 36 /* Snapshot of GuC log from last failed load */37 struct drm_i915_gem_object *load_err_log;38 39 bool reset_in_progress;40 bool fw_table_invalid;41};42 43void intel_uc_init_early(struct intel_uc *uc);44void intel_uc_init_late(struct intel_uc *uc);45void intel_uc_driver_late_release(struct intel_uc *uc);46void intel_uc_driver_remove(struct intel_uc *uc);47void intel_uc_init_mmio(struct intel_uc *uc);48void intel_uc_reset_prepare(struct intel_uc *uc);49void intel_uc_reset(struct intel_uc *uc, intel_engine_mask_t stalled);50void intel_uc_reset_finish(struct intel_uc *uc);51void intel_uc_cancel_requests(struct intel_uc *uc);52void intel_uc_suspend(struct intel_uc *uc);53void intel_uc_runtime_suspend(struct intel_uc *uc);54int intel_uc_resume(struct intel_uc *uc);55int intel_uc_runtime_resume(struct intel_uc *uc);56 57/*58 * We need to know as early as possible if we're going to use GuC or not to59 * take the correct setup paths. Additionally, once we've started loading the60 * GuC, it is unsafe to keep executing without it because some parts of the HW,61 * a subset of which is not cleaned on GT reset, will start expecting the GuC FW62 * to be running.63 * To solve both these requirements, we commit to using the microcontrollers if64 * the relevant modparam is set and the blobs are found on the system. At this65 * stage, the only thing that can stop us from attempting to load the blobs on66 * the HW and use them is a fundamental issue (e.g. no memory for our67 * structures); if we hit such a problem during driver load we're broken even68 * without GuC, so there is no point in trying to fall back.69 *70 * Given the above, we can be in one of 4 states, with the last one implying71 * we're committed to using the microcontroller:72 * - Not supported: not available in HW and/or firmware not defined.73 * - Supported: available in HW and firmware defined.74 * - Wanted: supported + enabled in modparam.75 * - In use: wanted + firmware found on the system and successfully fetched.76 */77 78#define __uc_state_checker(x, func, state, required) \79static inline bool intel_uc_##state##_##func(struct intel_uc *uc) \80{ \81 return intel_##func##_is_##required(&uc->x); \82}83 84#define uc_state_checkers(x, func) \85__uc_state_checker(x, func, supports, supported) \86__uc_state_checker(x, func, wants, wanted) \87__uc_state_checker(x, func, uses, used)88 89uc_state_checkers(guc, guc);90uc_state_checkers(huc, huc);91uc_state_checkers(guc, guc_submission);92uc_state_checkers(guc, guc_slpc);93uc_state_checkers(guc, guc_rc);94uc_state_checkers(gsc, gsc_uc);95 96#undef uc_state_checkers97#undef __uc_state_checker98 99static inline int intel_uc_wait_for_idle(struct intel_uc *uc, long timeout)100{101 return intel_guc_wait_for_idle(&uc->guc, timeout);102}103 104#define intel_uc_ops_function(_NAME, _OPS, _TYPE, _RET) \105static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \106{ \107 if (uc->ops->_OPS) \108 return uc->ops->_OPS(uc); \109 return _RET; \110}111intel_uc_ops_function(sanitize, sanitize, int, 0);112intel_uc_ops_function(fetch_firmwares, init_fw, void, );113intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );114intel_uc_ops_function(init, init, int, 0);115intel_uc_ops_function(fini, fini, void, );116intel_uc_ops_function(init_hw, init_hw, int, 0);117intel_uc_ops_function(fini_hw, fini_hw, void, );118intel_uc_ops_function(resume_mappings, resume_mappings, void, );119#undef intel_uc_ops_function120 121#endif122