linux/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c

// SPDX-License-Identifier: MIT
/*
 * Copyright © 2016-2019 Intel Corporation
 */

#include <linux/bitfield.h>
#include <linux/firmware.h>
#include <linux/highmem.h>

#include <drm/drm_cache.h>
#include <drm/drm_print.h>

#include "gem/i915_gem_lmem.h"
#include "gt/intel_gt.h"
#include "gt/intel_gt_print.h"
#include "intel_gsc_binary_headers.h"
#include "intel_gsc_fw.h"
#include "intel_uc_fw.h"
#include "intel_uc_fw_abi.h"
#include "i915_drv.h"
#include "i915_reg.h"

#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
#define UNEXPECTED
#else
#define UNEXPECTED
#endif

static inline struct intel_gt *
____uc_fw_to_gt(struct intel_uc_fw *uc_fw, enum intel_uc_fw_type type)
{}

static inline struct intel_gt *__uc_fw_to_gt(struct intel_uc_fw *uc_fw)
{}

#ifdef CONFIG_DRM_I915_DEBUG_GUC
void intel_uc_fw_change_status(struct intel_uc_fw *uc_fw,
			       enum intel_uc_fw_status status)
{}
#endif

/*
 * List of required GuC and HuC binaries per-platform.
 * Must be ordered based on platform + revid, from newer to older.
 *
 * Note that RKL and ADL-S have the same GuC/HuC device ID's and use the same
 * firmware as TGL.
 *
 * Version numbers:
 * Originally, the driver required an exact match major/minor/patch furmware
 * file and only supported that one version for any given platform. However,
 * the new direction from upstream is to be backwards compatible with all
 * prior releases and to be as flexible as possible as to what firmware is
 * loaded.
 *
 * For GuC, the major version number signifies a backwards breaking API change.
 * So, new format GuC firmware files are labelled by their major version only.
 * For HuC, there is no KMD interaction, hence no version matching requirement.
 * So, new format HuC firmware files have no version number at all.
 *
 * All of which means that the table below must keep all old format files with
 * full three point version number. But newer files have reduced requirements.
 * Having said that, the driver still needs to track the minor version number
 * for GuC at least. As it is useful to report to the user that they are not
 * running with a recent enough version for all KMD supported features,
 * security fixes, etc. to be enabled.
 */
#define INTEL_GUC_FIRMWARE_DEFS(fw_def, guc_maj, guc_mmp)

#define INTEL_HUC_FIRMWARE_DEFS(fw_def, huc_raw, huc_mmp, huc_gsc)

/*
 * The GSC FW has multiple version (see intel_gsc_uc.h for details); since what
 * we care about is the interface, we use the compatibility version in the
 * binary names.
 * Same as with the GuC, a major version bump indicate a
 * backward-incompatible change, while a minor version bump indicates a
 * backward-compatible one, so we use only the former in the file name.
 */
#define INTEL_GSC_FIRMWARE_DEFS(fw_def, gsc_def)

/*
 * Set of macros for producing a list of filenames from the above table.
 */
#define __MAKE_UC_FW_PATH_BLANK(prefix_, name_)

#define __MAKE_UC_FW_PATH_MAJOR(prefix_, name_, major_)

#define __MAKE_UC_FW_PATH_MMP(prefix_, name_, major_, minor_, patch_)

/* Minor for internal driver use, not part of file name */
#define MAKE_GUC_FW_PATH_MAJOR(prefix_, major_, minor_, patch_)

#define MAKE_GUC_FW_PATH_MMP(prefix_, major_, minor_, patch_)

#define MAKE_HUC_FW_PATH_BLANK(prefix_)

#define MAKE_HUC_FW_PATH_GSC(prefix_)

#define MAKE_HUC_FW_PATH_MMP(prefix_, major_, minor_, patch_)

#define MAKE_GSC_FW_PATH(prefix_, major_, minor_)

/*
 * All blobs need to be declared via MODULE_FIRMWARE().
 * This first expansion of the table macros is solely to provide
 * that declaration.
 */
#define INTEL_UC_MODULE_FW(platform_, revid_, uc_)

INTEL_GUC_FIRMWARE_DEFS()
INTEL_HUC_FIRMWARE_DEFS()
INTEL_GSC_FIRMWARE_DEFS()

/*
 * The next expansion of the table macros (in __uc_fw_auto_select below) provides
 * actual data structures with both the filename and the version information.
 * These structure arrays are then iterated over to the list of suitable files
 * for the current platform and to then attempt to load those files, in the order
 * listed, until one is successfully found.
 */
struct __packed uc_fw_blob {};

#define UC_FW_BLOB_BASE(major_, minor_, patch_, path_)

#define UC_FW_BLOB_NEW(major_, minor_, patch_, gsc_, path_)

#define UC_FW_BLOB_OLD(major_, minor_, patch_, path_)

#define GUC_FW_BLOB(prefix_, major_, minor_, patch_)

#define GUC_FW_BLOB_MMP(prefix_, major_, minor_, patch_)

#define HUC_FW_BLOB(prefix_)

#define HUC_FW_BLOB_MMP(prefix_, major_, minor_, patch_)

#define HUC_FW_BLOB_GSC(prefix_)

#define GSC_FW_BLOB(prefix_, major_, minor_)

struct __packed uc_fw_platform_requirement {};

#define MAKE_FW_LIST(platform_, revid_, uc_)

struct fw_blobs_by_type {};

static const struct uc_fw_platform_requirement blobs_guc[] =;

static const struct uc_fw_platform_requirement blobs_huc[] =;

static const struct uc_fw_platform_requirement blobs_gsc[] =;

static const struct fw_blobs_by_type blobs_all[INTEL_UC_FW_NUM_TYPES] =;

static void
__uc_fw_auto_select(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw)
{}

static bool validate_fw_table_type(struct drm_i915_private *i915, enum intel_uc_fw_type type)
{}

static const char *__override_guc_firmware_path(struct drm_i915_private *i915)
{}

static const char *__override_huc_firmware_path(struct drm_i915_private *i915)
{}

static const char *__override_gsc_firmware_path(struct drm_i915_private *i915)
{}

static void __uc_fw_user_override(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw)
{}

void intel_uc_fw_version_from_gsc_manifest(struct intel_uc_fw_ver *ver,
					   const void *data)
{}

/**
 * intel_uc_fw_init_early - initialize the uC object and select the firmware
 * @uc_fw: uC firmware
 * @type: type of uC
 * @needs_ggtt_mapping: whether the FW needs to be GGTT mapped for loading
 *
 * Initialize the state of our uC object and relevant tracking and select the
 * firmware to fetch and load.
 */
void intel_uc_fw_init_early(struct intel_uc_fw *uc_fw,
			    enum intel_uc_fw_type type,
			    bool needs_ggtt_mapping)
{}

static void __force_fw_fetch_failures(struct intel_uc_fw *uc_fw, int e)
{}

static void uc_unpack_css_version(struct intel_uc_fw_ver *ver, u32 css_value)
{}

static void guc_read_css_info(struct intel_uc_fw *uc_fw, struct uc_css_header *css)
{}

static int __check_ccs_header(struct intel_gt *gt,
			      const void *fw_data, size_t fw_size,
			      struct intel_uc_fw *uc_fw)
{}

static int check_gsc_manifest(struct intel_gt *gt,
			      const struct firmware *fw,
			      struct intel_uc_fw *uc_fw)
{}

static int check_ccs_header(struct intel_gt *gt,
			    const struct firmware *fw,
			    struct intel_uc_fw *uc_fw)
{}

static bool is_ver_8bit(struct intel_uc_fw_ver *ver)
{}

static int guc_check_version_range(struct intel_uc_fw *uc_fw)
{}

static int check_fw_header(struct intel_gt *gt,
			   const struct firmware *fw,
			   struct intel_uc_fw *uc_fw)
{}

static int try_firmware_load(struct intel_uc_fw *uc_fw, const struct firmware **fw)
{}

static int check_mtl_huc_guc_compatibility(struct intel_gt *gt,
					   struct intel_uc_fw_file *huc_selected)
{}

int intel_uc_check_file_version(struct intel_uc_fw *uc_fw, bool *old_ver)
{}

/**
 * intel_uc_fw_fetch - fetch uC firmware
 * @uc_fw: uC firmware
 *
 * Fetch uC firmware into GEM obj.
 *
 * Return: 0 on success, a negative errno code on failure.
 */
int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw)
{}

static u32 uc_fw_ggtt_offset(struct intel_uc_fw *uc_fw)
{}

static void uc_fw_bind_ggtt(struct intel_uc_fw *uc_fw)
{}

static void uc_fw_unbind_ggtt(struct intel_uc_fw *uc_fw)
{}

static int uc_fw_xfer(struct intel_uc_fw *uc_fw, u32 dst_offset, u32 dma_flags)
{}

int intel_uc_fw_mark_load_failed(struct intel_uc_fw *uc_fw, int err)
{}

/**
 * intel_uc_fw_upload - load uC firmware using custom loader
 * @uc_fw: uC firmware
 * @dst_offset: destination offset
 * @dma_flags: flags for flags for dma ctrl
 *
 * Loads uC firmware and updates internal flags.
 *
 * Return: 0 on success, non-zero on failure.
 */
int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, u32 dst_offset, u32 dma_flags)
{}

static inline bool uc_fw_need_rsa_in_memory(struct intel_uc_fw *uc_fw)
{}

static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
{}

static void uc_fw_rsa_data_destroy(struct intel_uc_fw *uc_fw)
{}

int intel_uc_fw_init(struct intel_uc_fw *uc_fw)
{}

void intel_uc_fw_fini(struct intel_uc_fw *uc_fw)
{}

void intel_uc_fw_resume_mapping(struct intel_uc_fw *uc_fw)
{}

/**
 * intel_uc_fw_cleanup_fetch - cleanup uC firmware
 * @uc_fw: uC firmware
 *
 * Cleans up uC firmware by releasing the firmware GEM obj.
 */
void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw)
{}

/**
 * intel_uc_fw_copy_rsa - copy fw RSA to buffer
 *
 * @uc_fw: uC firmware
 * @dst: dst buffer
 * @max_len: max number of bytes to copy
 *
 * Return: number of copied bytes.
 */
size_t intel_uc_fw_copy_rsa(struct intel_uc_fw *uc_fw, void *dst, u32 max_len)
{}

/**
 * intel_uc_fw_dump - dump information about uC firmware
 * @uc_fw: uC firmware
 * @p: the &drm_printer
 *
 * Pretty printer for uC firmware.
 */
void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p)
{}