1 // SPDX-License-Identifier: MIT
3 * Copyright(c) 2021-2022, Intel Corporation. All rights reserved.
8 #include "gem/i915_gem_region.h"
9 #include "gt/intel_gt.h"
11 #include "intel_pxp.h"
12 #include "intel_pxp_huc.h"
13 #include "intel_pxp_tee.h"
14 #include "intel_pxp_types.h"
15 #include "intel_pxp_cmd_interface_43.h"
17 int intel_pxp_huc_load_and_auth(struct intel_pxp *pxp)
20 struct intel_huc *huc;
21 struct pxp43_start_huc_auth_in huc_in = {0};
22 struct pxp43_huc_auth_out huc_out = {0};
23 dma_addr_t huc_phys_addr;
28 if (!pxp || !pxp->pxp_component)
34 huc_phys_addr = i915_gem_object_get_dma_address(huc->fw.obj, 0);
36 /* write the PXP message into the lmem (the sg list) */
37 huc_in.header.api_version = PXP_APIVER(4, 3);
38 huc_in.header.command_id = PXP43_CMDID_START_HUC_AUTH;
39 huc_in.header.status = 0;
40 huc_in.header.buffer_len = sizeof(huc_in.huc_base_address);
41 huc_in.huc_base_address = cpu_to_le64(huc_phys_addr);
43 err = intel_pxp_tee_stream_message(pxp, client_id, fence_id,
44 &huc_in, sizeof(huc_in),
45 &huc_out, sizeof(huc_out));
47 drm_err(>->i915->drm,
48 "Failed to send HuC load and auth command to GSC [%d]!\n",
54 * HuC does sometimes survive suspend/resume (it depends on how "deep"
55 * a sleep state the device reaches) so we can end up here on resume
56 * with HuC already loaded, in which case the GSC will return
57 * PXP_STATUS_OP_NOT_PERMITTED. We can therefore consider the GuC
58 * correctly transferred in this scenario; if the same error is ever
59 * returned with HuC not loaded we'll still catch it when we check the
60 * authentication bit later.
62 if (huc_out.header.status != PXP_STATUS_SUCCESS &&
63 huc_out.header.status != PXP_STATUS_OP_NOT_PERMITTED) {
64 drm_err(>->i915->drm,
65 "HuC load failed with GSC error = 0x%x\n",
66 huc_out.header.status);