1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2014-2019 Intel Corporation
9 #include "i915_reg_defs.h"
10 #include "i915_sw_fence.h"
11 #include "intel_uc_fw.h"
12 #include "intel_huc_fw.h"
14 #include <linux/notifier.h>
15 #include <linux/hrtimer.h>
20 enum intel_huc_delayed_load_status {
21 INTEL_HUC_WAITING_ON_GSC = 0,
22 INTEL_HUC_WAITING_ON_PXP,
23 INTEL_HUC_DELAYED_LOAD_ERROR,
26 enum intel_huc_authentication_type {
27 INTEL_HUC_AUTH_BY_GUC = 0,
28 INTEL_HUC_AUTH_BY_GSC,
29 INTEL_HUC_AUTH_MAX_MODES
33 /* Generic uC firmware management */
34 struct intel_uc_fw fw;
36 /* HuC-specific additions */
41 } status[INTEL_HUC_AUTH_MAX_MODES];
44 struct i915_sw_fence fence;
46 struct notifier_block nb;
47 enum intel_huc_delayed_load_status status;
50 /* for load via GSCCS */
51 struct i915_vma *heci_pkt;
56 int intel_huc_sanitize(struct intel_huc *huc);
57 void intel_huc_init_early(struct intel_huc *huc);
58 int intel_huc_init(struct intel_huc *huc);
59 void intel_huc_fini(struct intel_huc *huc);
60 void intel_huc_suspend(struct intel_huc *huc);
61 int intel_huc_auth(struct intel_huc *huc, enum intel_huc_authentication_type type);
62 int intel_huc_wait_for_auth_complete(struct intel_huc *huc,
63 enum intel_huc_authentication_type type);
64 bool intel_huc_is_authenticated(struct intel_huc *huc,
65 enum intel_huc_authentication_type type);
66 int intel_huc_check_status(struct intel_huc *huc);
67 void intel_huc_update_auth_status(struct intel_huc *huc);
69 void intel_huc_register_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus);
70 void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus);
72 static inline bool intel_huc_is_supported(struct intel_huc *huc)
74 return intel_uc_fw_is_supported(&huc->fw);
77 static inline bool intel_huc_is_wanted(struct intel_huc *huc)
79 return intel_uc_fw_is_enabled(&huc->fw);
82 static inline bool intel_huc_is_used(struct intel_huc *huc)
84 GEM_BUG_ON(__intel_uc_fw_status(&huc->fw) == INTEL_UC_FIRMWARE_SELECTED);
85 return intel_uc_fw_is_available(&huc->fw);
88 static inline bool intel_huc_is_loaded_by_gsc(const struct intel_huc *huc)
90 return huc->loaded_via_gsc;
93 static inline bool intel_huc_wait_required(struct intel_huc *huc)
95 return intel_huc_is_used(huc) && intel_huc_is_loaded_by_gsc(huc) &&
96 !intel_huc_is_authenticated(huc, INTEL_HUC_AUTH_BY_GSC);
99 void intel_huc_load_status(struct intel_huc *huc, struct drm_printer *p);