File Index
Files and directories
Sign in
FILE

intel_pxp_huc.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/i915/pxp/intel_pxp_huc.c C
 1// SPDX-License-Identifier: MIT
 2/*
 3 * Copyright(c) 2021-2022, Intel Corporation. All rights reserved.
 4 */
 5
 6#include <drm/drm_print.h>
 7
 8#include "i915_drv.h"
 9
10#include "gem/i915_gem_region.h"
11#include "gt/intel_gt.h"
12
13#include "intel_pxp.h"
14#include "intel_pxp_huc.h"
15#include "intel_pxp_tee.h"
16#include "intel_pxp_types.h"
17#include "intel_pxp_cmd_interface_43.h"
18
19int intel_pxp_huc_load_and_auth(struct intel_pxp *pxp)
20{
21	struct intel_gt *gt;
22	struct intel_huc *huc;
23	struct pxp43_start_huc_auth_in huc_in = {};
24	struct pxp43_huc_auth_out huc_out = {};
25	dma_addr_t huc_phys_addr;
26	u8 client_id = 0;
27	u8 fence_id = 0;
28	int err;
29
30	if (!pxp || !pxp->pxp_component)
31		return -ENODEV;
32
33	gt = pxp->ctrl_gt;
34	huc = &gt->uc.huc;
35
36	huc_phys_addr = i915_gem_object_get_dma_address(huc->fw.obj, 0);
37
38	/* write the PXP message into the lmem (the sg list) */
39	huc_in.header.api_version = PXP_APIVER(4, 3);
40	huc_in.header.command_id  = PXP43_CMDID_START_HUC_AUTH;
41	huc_in.header.status      = 0;
42	huc_in.header.buffer_len  = sizeof(huc_in.huc_base_address);
43	huc_in.huc_base_address   = cpu_to_le64(huc_phys_addr);
44
45	err = intel_pxp_tee_stream_message(pxp, client_id, fence_id,
46					   &huc_in, sizeof(huc_in),
47					   &huc_out, sizeof(huc_out));
48	if (err < 0) {
49		drm_err(&gt->i915->drm,
50			"Failed to send HuC load and auth command to GSC [%d]!\n",
51			err);
52		return err;
53	}
54
55	/*
56	 * HuC does sometimes survive suspend/resume (it depends on how "deep"
57	 * a sleep state the device reaches) so we can end up here on resume
58	 * with HuC already loaded, in which case the GSC will return
59	 * PXP_STATUS_OP_NOT_PERMITTED. We can therefore consider the GuC
60	 * correctly transferred in this scenario; if the same error is ever
61	 * returned with HuC not loaded we'll still catch it when we check the
62	 * authentication bit later.
63	 */
64	if (huc_out.header.status != PXP_STATUS_SUCCESS &&
65	    huc_out.header.status != PXP_STATUS_OP_NOT_PERMITTED) {
66		drm_err(&gt->i915->drm,
67			"HuC load failed with GSC error = 0x%x\n",
68			huc_out.header.status);
69		return -EPROTO;
70	}
71
72	return 0;
73}
~/ Read-only file preview.