Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2014-2019 Intel Corporation
0004  */
0005 
0006 #ifndef _INTEL_UC_H_
0007 #define _INTEL_UC_H_
0008 
0009 #include "intel_guc.h"
0010 #include "intel_guc_rc.h"
0011 #include "intel_guc_submission.h"
0012 #include "intel_guc_slpc.h"
0013 #include "intel_huc.h"
0014 #include "i915_params.h"
0015 
0016 struct intel_uc;
0017 
0018 struct intel_uc_ops {
0019     int (*sanitize)(struct intel_uc *uc);
0020     void (*init_fw)(struct intel_uc *uc);
0021     void (*fini_fw)(struct intel_uc *uc);
0022     int (*init)(struct intel_uc *uc);
0023     void (*fini)(struct intel_uc *uc);
0024     int (*init_hw)(struct intel_uc *uc);
0025     void (*fini_hw)(struct intel_uc *uc);
0026 };
0027 
0028 struct intel_uc {
0029     struct intel_uc_ops const *ops;
0030     struct intel_guc guc;
0031     struct intel_huc huc;
0032 
0033     /* Snapshot of GuC log from last failed load */
0034     struct drm_i915_gem_object *load_err_log;
0035 
0036     bool reset_in_progress;
0037 };
0038 
0039 void intel_uc_init_early(struct intel_uc *uc);
0040 void intel_uc_init_late(struct intel_uc *uc);
0041 void intel_uc_driver_late_release(struct intel_uc *uc);
0042 void intel_uc_driver_remove(struct intel_uc *uc);
0043 void intel_uc_init_mmio(struct intel_uc *uc);
0044 void intel_uc_reset_prepare(struct intel_uc *uc);
0045 void intel_uc_reset(struct intel_uc *uc, intel_engine_mask_t stalled);
0046 void intel_uc_reset_finish(struct intel_uc *uc);
0047 void intel_uc_cancel_requests(struct intel_uc *uc);
0048 void intel_uc_suspend(struct intel_uc *uc);
0049 void intel_uc_runtime_suspend(struct intel_uc *uc);
0050 int intel_uc_resume(struct intel_uc *uc);
0051 int intel_uc_runtime_resume(struct intel_uc *uc);
0052 
0053 /*
0054  * We need to know as early as possible if we're going to use GuC or not to
0055  * take the correct setup paths. Additionally, once we've started loading the
0056  * GuC, it is unsafe to keep executing without it because some parts of the HW,
0057  * a subset of which is not cleaned on GT reset, will start expecting the GuC FW
0058  * to be running.
0059  * To solve both these requirements, we commit to using the microcontrollers if
0060  * the relevant modparam is set and the blobs are found on the system. At this
0061  * stage, the only thing that can stop us from attempting to load the blobs on
0062  * the HW and use them is a fundamental issue (e.g. no memory for our
0063  * structures); if we hit such a problem during driver load we're broken even
0064  * without GuC, so there is no point in trying to fall back.
0065  *
0066  * Given the above, we can be in one of 4 states, with the last one implying
0067  * we're committed to using the microcontroller:
0068  * - Not supported: not available in HW and/or firmware not defined.
0069  * - Supported: available in HW and firmware defined.
0070  * - Wanted: supported + enabled in modparam.
0071  * - In use: wanted + firmware found on the system and successfully fetched.
0072  */
0073 
0074 #define __uc_state_checker(x, func, state, required) \
0075 static inline bool intel_uc_##state##_##func(struct intel_uc *uc) \
0076 { \
0077     return intel_##func##_is_##required(&uc->x); \
0078 }
0079 
0080 #define uc_state_checkers(x, func) \
0081 __uc_state_checker(x, func, supports, supported) \
0082 __uc_state_checker(x, func, wants, wanted) \
0083 __uc_state_checker(x, func, uses, used)
0084 
0085 uc_state_checkers(guc, guc);
0086 uc_state_checkers(huc, huc);
0087 uc_state_checkers(guc, guc_submission);
0088 uc_state_checkers(guc, guc_slpc);
0089 uc_state_checkers(guc, guc_rc);
0090 
0091 #undef uc_state_checkers
0092 #undef __uc_state_checker
0093 
0094 static inline int intel_uc_wait_for_idle(struct intel_uc *uc, long timeout)
0095 {
0096     return intel_guc_wait_for_idle(&uc->guc, timeout);
0097 }
0098 
0099 #define intel_uc_ops_function(_NAME, _OPS, _TYPE, _RET) \
0100 static inline _TYPE intel_uc_##_NAME(struct intel_uc *uc) \
0101 { \
0102     if (uc->ops->_OPS) \
0103         return uc->ops->_OPS(uc); \
0104     return _RET; \
0105 }
0106 intel_uc_ops_function(sanitize, sanitize, int, 0);
0107 intel_uc_ops_function(fetch_firmwares, init_fw, void, );
0108 intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );
0109 intel_uc_ops_function(init, init, int, 0);
0110 intel_uc_ops_function(fini, fini, void, );
0111 intel_uc_ops_function(init_hw, init_hw, int, 0);
0112 intel_uc_ops_function(fini_hw, fini_hw, void, );
0113 #undef intel_uc_ops_function
0114 
0115 #endif