2019-08-12 09:29:35 +00:00
/* SPDX-License-Identifier: MIT */
2015-08-12 15:43:36 +01:00
/*
2019-08-12 09:29:35 +00:00
* Copyright © 2014 - 2019 Intel Corporation
2015-08-12 15:43:36 +01:00
*/
2019-08-12 09:29:35 +00:00
2016-11-25 18:59:33 +01:00
# ifndef _INTEL_UC_H_
# define _INTEL_UC_H_
2015-08-12 15:43:36 +01:00
2017-10-04 18:13:41 +00:00
# include "intel_guc.h"
2020-02-18 14:33:24 -08:00
# include "intel_guc_submission.h"
2017-10-04 15:33:26 +00:00
# include "intel_huc.h"
2017-12-06 13:53:15 +00:00
# include "i915_params.h"
2016-12-24 19:31:46 +00:00
2020-01-10 22:27:20 +00:00
struct intel_uc ;
struct intel_uc_ops {
2020-01-10 22:27:23 +00:00
int ( * sanitize ) ( struct intel_uc * uc ) ;
2020-01-10 22:27:21 +00:00
void ( * init_fw ) ( struct intel_uc * uc ) ;
void ( * fini_fw ) ( struct intel_uc * uc ) ;
2020-02-18 14:33:25 -08:00
int ( * init ) ( struct intel_uc * uc ) ;
2020-01-10 22:27:22 +00:00
void ( * fini ) ( struct intel_uc * uc ) ;
2020-01-10 22:27:20 +00:00
int ( * init_hw ) ( struct intel_uc * uc ) ;
void ( * fini_hw ) ( struct intel_uc * uc ) ;
} ;
2019-07-13 11:00:12 +01:00
struct intel_uc {
2020-01-10 22:27:20 +00:00
struct intel_uc_ops const * ops ;
2019-07-13 11:00:12 +01:00
struct intel_guc guc ;
struct intel_huc huc ;
2019-08-02 18:40:53 +00:00
/* Snapshot of GuC log from last failed load */
struct drm_i915_gem_object * load_err_log ;
2019-07-13 11:00:12 +01:00
} ;
2019-07-13 11:00:13 +01:00
void intel_uc_init_early ( struct intel_uc * uc ) ;
2019-07-31 17:57:08 -07:00
void intel_uc_driver_late_release ( struct intel_uc * uc ) ;
2020-03-26 11:11:21 -07:00
void intel_uc_driver_remove ( struct intel_uc * uc ) ;
2019-07-13 11:00:13 +01:00
void intel_uc_init_mmio ( struct intel_uc * uc ) ;
void intel_uc_reset_prepare ( struct intel_uc * uc ) ;
void intel_uc_suspend ( struct intel_uc * uc ) ;
void intel_uc_runtime_suspend ( struct intel_uc * uc ) ;
int intel_uc_resume ( struct intel_uc * uc ) ;
2019-07-30 16:07:39 -07:00
int intel_uc_runtime_resume ( struct intel_uc * uc ) ;
2016-12-24 19:31:46 +00:00
2020-02-18 14:33:23 -08:00
/*
* We need to know as early as possible if we ' re going to use GuC or not to
* take the correct setup paths . Additionally , once we ' ve started loading the
* GuC , it is unsafe to keep executing without it because some parts of the HW ,
* a subset of which is not cleaned on GT reset , will start expecting the GuC FW
* to be running .
* To solve both these requirements , we commit to using the microcontrollers if
* the relevant modparam is set and the blobs are found on the system . At this
* stage , the only thing that can stop us from attempting to load the blobs on
* the HW and use them is a fundamental issue ( e . g . no memory for our
* structures ) ; if we hit such a problem during driver load we ' re broken even
* without GuC , so there is no point in trying to fall back .
*
* Given the above , we can be in one of 4 states , with the last one implying
* we ' re committed to using the microcontroller :
* - Not supported : not available in HW and / or firmware not defined .
* - Supported : available in HW and firmware defined .
* - Wanted : supported + enabled in modparam .
* - In use : wanted + firmware found on the system and successfully fetched .
*/
2020-02-18 14:33:24 -08:00
# define __uc_state_checker(x, func, state, required) \
static inline bool intel_uc_ # # state # # _ # # func ( struct intel_uc * uc ) \
2020-02-18 14:33:22 -08:00
{ \
2020-02-18 14:33:24 -08:00
return intel_ # # func # # _is_ # # required ( & uc - > x ) ; \
2017-12-06 13:53:15 +00:00
}
2020-02-18 14:33:24 -08:00
# define uc_state_checkers(x, func) \
__uc_state_checker ( x , func , supports , supported ) \
__uc_state_checker ( x , func , wants , wanted ) \
__uc_state_checker ( x , func , uses , used )
2020-02-18 14:33:22 -08:00
2020-02-18 14:33:24 -08:00
uc_state_checkers ( guc , guc ) ;
uc_state_checkers ( huc , huc ) ;
uc_state_checkers ( guc , guc_submission ) ;
2020-02-18 14:33:22 -08:00
# undef uc_state_checkers
# undef __uc_state_checker
2019-08-16 20:56:58 +00:00
2020-01-10 22:27:20 +00:00
# define intel_uc_ops_function(_NAME, _OPS, _TYPE, _RET) \
static inline _TYPE intel_uc_ # # _NAME ( struct intel_uc * uc ) \
{ \
if ( uc - > ops - > _OPS ) \
return uc - > ops - > _OPS ( uc ) ; \
return _RET ; \
}
2020-01-10 22:27:23 +00:00
intel_uc_ops_function ( sanitize , sanitize , int , 0 ) ;
2020-01-10 22:27:21 +00:00
intel_uc_ops_function ( fetch_firmwares , init_fw , void , ) ;
intel_uc_ops_function ( cleanup_firmwares , fini_fw , void , ) ;
2020-02-18 14:33:25 -08:00
intel_uc_ops_function ( init , init , int , 0 ) ;
2020-01-10 22:27:22 +00:00
intel_uc_ops_function ( fini , fini , void , ) ;
2020-01-10 22:27:20 +00:00
intel_uc_ops_function ( init_hw , init_hw , int , 0 ) ;
intel_uc_ops_function ( fini_hw , fini_hw , void , ) ;
# undef intel_uc_ops_function
2015-08-12 15:43:36 +01:00
# endif