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

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

#ifndef _INTEL_UC_FW_H_
#define _INTEL_UC_FW_H_

#include <linux/sizes.h>
#include <linux/types.h>
#include "intel_uc_fw_abi.h"
#include "intel_device_info.h"
#include "i915_gem.h"
#include "i915_vma.h"

struct drm_printer;
struct drm_i915_private;
struct intel_gt;

/* Home of GuC, HuC and DMC firmwares */
#define INTEL_UC_FIRMWARE_URL

/*
 * +------------+---------------------------------------------------+
 * |   PHASE    |           FIRMWARE STATUS TRANSITIONS             |
 * +============+===================================================+
 * |            |               UNINITIALIZED                       |
 * +------------+-               /   |   \                         -+
 * |            |   DISABLED <--/    |    \--> NOT_SUPPORTED        |
 * | init_early |                    V                              |
 * |            |                 SELECTED                          |
 * +------------+-               /   |   \                         -+
 * |            |    MISSING <--/    |    \--> ERROR                |
 * |   fetch    |                    V                              |
 * |            |                 AVAILABLE                         |
 * +------------+-                   |   \                         -+
 * |            |                    |    \--> INIT FAIL            |
 * |   init     |                    V                              |
 * |            |        /------> LOADABLE <----<-----------\       |
 * +------------+-       \         /    \        \           \     -+
 * |            |    LOAD FAIL <--<      \--> TRANSFERRED     \     |
 * |   upload   |                  \           /   \          /     |
 * |            |                   \---------/     \--> RUNNING    |
 * +------------+---------------------------------------------------+
 */

enum intel_uc_fw_status {};

enum intel_uc_fw_type {};
#define INTEL_UC_FW_NUM_TYPES

struct intel_uc_fw_ver {};

/*
 * The firmware build process will generate a version header file with major and
 * minor version defined. The versions are built into CSS header of firmware.
 * i915 kernel driver set the minimal firmware version required per platform.
 */
struct intel_uc_fw_file {};

/*
 * This structure encapsulates all the data needed during the process
 * of fetching, caching, and loading the firmware image into the uC.
 */
struct intel_uc_fw {};

/*
 * When we load the uC binaries, we pin them in a reserved section at the top of
 * the GGTT, which is ~18 MBs. On multi-GT systems where the GTs share the GGTT,
 * we also need to make sure that each binary is pinned to a unique location
 * during load, because the different GT can go through the FW load at the same
 * time (see uc_fw_ggtt_offset() for details).
 * Given that the available space is much greater than what is required by the
 * binaries, to keep things simple instead of dynamically partitioning the
 * reserved section to make space for all the blobs we can just reserve a static
 * chunk for each binary.
 */
#define INTEL_UC_RSVD_GGTT_PER_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);
#else
static inline void intel_uc_fw_change_status(struct intel_uc_fw *uc_fw,
					     enum intel_uc_fw_status status)
{
	uc_fw->__status = status;
}
#endif

static inline
const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
{}

static inline int intel_uc_fw_status_to_error(enum intel_uc_fw_status status)
{}

static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
{}

static inline enum intel_uc_fw_status
__intel_uc_fw_status(struct intel_uc_fw *uc_fw)
{}

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

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

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

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

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

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

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

static inline bool intel_uc_fw_is_overridden(const struct intel_uc_fw *uc_fw)
{}

static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw)
{}

static inline u32 __intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw)
{}

/**
 * intel_uc_fw_get_upload_size() - Get size of firmware needed to be uploaded.
 * @uc_fw: uC firmware.
 *
 * Get the size of the firmware and header that will be uploaded to WOPCM.
 *
 * Return: Upload firmware size, or zero on firmware fetch failure.
 */
static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw)
{}

void intel_uc_fw_version_from_gsc_manifest(struct intel_uc_fw_ver *ver,
					   const void *data);
int intel_uc_check_file_version(struct intel_uc_fw *uc_fw, bool *old_ver);
void intel_uc_fw_init_early(struct intel_uc_fw *uc_fw,
			    enum intel_uc_fw_type type,
			    bool needs_ggtt_mapping);
int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw);
void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw);
int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, u32 offset, u32 dma_flags);
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);
size_t intel_uc_fw_copy_rsa(struct intel_uc_fw *uc_fw, void *dst, u32 max_len);
int intel_uc_fw_mark_load_failed(struct intel_uc_fw *uc_fw, int err);
void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p);

#endif