Linux Audio

Check our new training course

Loading...
Note: File does not exist in v4.6.
 1// SPDX-License-Identifier: MIT
 2/*
 3 * Copyright © 2014-2019 Intel Corporation
 4 */
 5
 6#include "gt/intel_gsc.h"
 7#include "gt/intel_gt.h"
 8#include "intel_huc.h"
 9#include "intel_huc_fw.h"
10#include "i915_drv.h"
11#include "pxp/intel_pxp_huc.h"
12
13int intel_huc_fw_load_and_auth_via_gsc(struct intel_huc *huc)
14{
15	int ret;
16
17	if (!intel_huc_is_loaded_by_gsc(huc))
18		return -ENODEV;
19
20	if (!intel_uc_fw_is_loadable(&huc->fw))
21		return -ENOEXEC;
22
23	/*
24	 * If we abort a suspend, HuC might still be loaded when the mei
25	 * component gets re-bound and this function called again. If so, just
26	 * mark the HuC as loaded.
27	 */
28	if (intel_huc_is_authenticated(huc)) {
29		intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_RUNNING);
30		return 0;
31	}
32
33	GEM_WARN_ON(intel_uc_fw_is_loaded(&huc->fw));
34
35	ret = intel_pxp_huc_load_and_auth(&huc_to_gt(huc)->pxp);
36	if (ret)
37		return ret;
38
39	intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_TRANSFERRED);
40
41	return intel_huc_wait_for_auth_complete(huc);
42}
43
44/**
45 * intel_huc_fw_upload() - load HuC uCode to device via DMA transfer
46 * @huc: intel_huc structure
47 *
48 * Called from intel_uc_init_hw() during driver load, resume from sleep and
49 * after a GPU reset. Note that HuC must be loaded before GuC.
50 *
51 * The firmware image should have already been fetched into memory, so only
52 * check that fetch succeeded, and then transfer the image to the h/w.
53 *
54 * Return:	non-zero code on error
55 */
56int intel_huc_fw_upload(struct intel_huc *huc)
57{
58	if (intel_huc_is_loaded_by_gsc(huc))
59		return -ENODEV;
60
61	/* HW doesn't look at destination address for HuC, so set it to 0 */
62	return intel_uc_fw_upload(&huc->fw, 0, HUC_UKERNEL);
63}