intel_huc_fw.c 1.6 KB
Newer Older
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 10
#include "intel_huc_fw.h"
#include "i915_drv.h"
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include "pxp/intel_pxp_huc.h"

int intel_huc_fw_load_and_auth_via_gsc(struct intel_huc *huc)
{
	int ret;

	if (!intel_huc_is_loaded_by_gsc(huc))
		return -ENODEV;

	if (!intel_uc_fw_is_loadable(&huc->fw))
		return -ENOEXEC;

	/*
	 * If we abort a suspend, HuC might still be loaded when the mei
	 * component gets re-bound and this function called again. If so, just
	 * mark the HuC as loaded.
	 */
	if (intel_huc_is_authenticated(huc)) {
		intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_RUNNING);
		return 0;
	}

	GEM_WARN_ON(intel_uc_fw_is_loaded(&huc->fw));

35
	ret = intel_pxp_huc_load_and_auth(huc_to_gt(huc)->i915->pxp);
36 37 38 39 40 41 42
	if (ret)
		return ret;

	intel_uc_fw_change_status(&huc->fw, INTEL_UC_FIRMWARE_TRANSFERRED);

	return intel_huc_wait_for_auth_complete(huc);
}
43 44

/**
45
 * intel_huc_fw_upload() - load HuC uCode to device via DMA transfer
46 47 48 49 50
 * @huc: intel_huc structure
 *
 * Called from intel_uc_init_hw() during driver load, resume from sleep and
 * after a GPU reset. Note that HuC must be loaded before GuC.
 *
51 52
 * The firmware image should have already been fetched into memory, so only
 * check that fetch succeeded, and then transfer the image to the h/w.
53 54 55 56 57
 *
 * Return:	non-zero code on error
 */
int intel_huc_fw_upload(struct intel_huc *huc)
{
58 59 60
	if (intel_huc_is_loaded_by_gsc(huc))
		return -ENODEV;

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
}