The version is obtained via a dedicated MKHI GSC HECI command. The compatibility version is what we want to match against for the GSC, so we need to call the FW version checker after obtaining the version. Since this is the first time we send a GSC HECI command via the GSCCS, this patch also introduces common infrastructure to send such commands to the GSC. Communication with the GSC FW is done via input/output buffers, whose addresses are provided via a GSCCS command. The buffers contain a generic header and a client-specific packet (e.g. PXP, HDCP); the clients don't care about the header format and/or the GSCCS command in the batch, they only care about their client-specific header. This patch therefore introduces helpers that allow the callers to automatically fill in the input header, submit the GSCCS job and decode the output header, to make it so that the caller only needs to worry about their client-specific input and output messages. v3: squash of 2 separate patches ahead of merge, so that the common functions and their first user are added at the same time Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Alan Previn <alan.previn.teres.alexis@intel.com> Cc: Suraj Kandpal <suraj.kandpal@intel.com> Cc: John Harrison <John.C.Harrison@Intel.com> Reviewed-by: John Harrison <John.C.Harrison@Intel.Com> #v1 Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
185 lines
4.5 KiB
C
185 lines
4.5 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
/*
|
|
* Copyright © 2022 Intel Corporation
|
|
*/
|
|
|
|
#ifndef _XE_UC_FW_H_
|
|
#define _XE_UC_FW_H_
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include "xe_macros.h"
|
|
#include "xe_uc_fw_abi.h"
|
|
#include "xe_uc_fw_types.h"
|
|
|
|
struct drm_printer;
|
|
|
|
int xe_uc_fw_init(struct xe_uc_fw *uc_fw);
|
|
size_t xe_uc_fw_copy_rsa(struct xe_uc_fw *uc_fw, void *dst, u32 max_len);
|
|
int xe_uc_fw_upload(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags);
|
|
int xe_uc_fw_check_version_requirements(struct xe_uc_fw *uc_fw);
|
|
void xe_uc_fw_print(struct xe_uc_fw *uc_fw, struct drm_printer *p);
|
|
|
|
static inline u32 xe_uc_fw_rsa_offset(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return sizeof(struct uc_css_header) + uc_fw->ucode_size + uc_fw->css_offset;
|
|
}
|
|
|
|
static inline void xe_uc_fw_change_status(struct xe_uc_fw *uc_fw,
|
|
enum xe_uc_fw_status status)
|
|
{
|
|
uc_fw->__status = status;
|
|
}
|
|
|
|
static inline
|
|
const char *xe_uc_fw_status_repr(enum xe_uc_fw_status status)
|
|
{
|
|
switch (status) {
|
|
case XE_UC_FIRMWARE_NOT_SUPPORTED:
|
|
return "N/A";
|
|
case XE_UC_FIRMWARE_UNINITIALIZED:
|
|
return "UNINITIALIZED";
|
|
case XE_UC_FIRMWARE_DISABLED:
|
|
return "DISABLED";
|
|
case XE_UC_FIRMWARE_SELECTED:
|
|
return "SELECTED";
|
|
case XE_UC_FIRMWARE_MISSING:
|
|
return "MISSING";
|
|
case XE_UC_FIRMWARE_ERROR:
|
|
return "ERROR";
|
|
case XE_UC_FIRMWARE_AVAILABLE:
|
|
return "AVAILABLE";
|
|
case XE_UC_FIRMWARE_INIT_FAIL:
|
|
return "INIT FAIL";
|
|
case XE_UC_FIRMWARE_LOADABLE:
|
|
return "LOADABLE";
|
|
case XE_UC_FIRMWARE_LOAD_FAIL:
|
|
return "LOAD FAIL";
|
|
case XE_UC_FIRMWARE_TRANSFERRED:
|
|
return "TRANSFERRED";
|
|
case XE_UC_FIRMWARE_RUNNING:
|
|
return "RUNNING";
|
|
}
|
|
return "<invalid>";
|
|
}
|
|
|
|
static inline int xe_uc_fw_status_to_error(enum xe_uc_fw_status status)
|
|
{
|
|
switch (status) {
|
|
case XE_UC_FIRMWARE_NOT_SUPPORTED:
|
|
return -ENODEV;
|
|
case XE_UC_FIRMWARE_UNINITIALIZED:
|
|
return -EACCES;
|
|
case XE_UC_FIRMWARE_DISABLED:
|
|
return -EPERM;
|
|
case XE_UC_FIRMWARE_MISSING:
|
|
return -ENOENT;
|
|
case XE_UC_FIRMWARE_ERROR:
|
|
return -ENOEXEC;
|
|
case XE_UC_FIRMWARE_INIT_FAIL:
|
|
case XE_UC_FIRMWARE_LOAD_FAIL:
|
|
return -EIO;
|
|
case XE_UC_FIRMWARE_SELECTED:
|
|
return -ESTALE;
|
|
case XE_UC_FIRMWARE_AVAILABLE:
|
|
case XE_UC_FIRMWARE_LOADABLE:
|
|
case XE_UC_FIRMWARE_TRANSFERRED:
|
|
case XE_UC_FIRMWARE_RUNNING:
|
|
return 0;
|
|
}
|
|
return -EINVAL;
|
|
}
|
|
|
|
static inline const char *xe_uc_fw_type_repr(enum xe_uc_fw_type type)
|
|
{
|
|
switch (type) {
|
|
case XE_UC_FW_TYPE_GUC:
|
|
return "GuC";
|
|
case XE_UC_FW_TYPE_HUC:
|
|
return "HuC";
|
|
case XE_UC_FW_TYPE_GSC:
|
|
return "GSC";
|
|
default:
|
|
return "uC";
|
|
}
|
|
}
|
|
|
|
static inline enum xe_uc_fw_status
|
|
__xe_uc_fw_status(struct xe_uc_fw *uc_fw)
|
|
{
|
|
/* shouldn't call this before checking hw/blob availability */
|
|
XE_WARN_ON(uc_fw->status == XE_UC_FIRMWARE_UNINITIALIZED);
|
|
return uc_fw->status;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_supported(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) != XE_UC_FIRMWARE_NOT_SUPPORTED;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_enabled(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) > XE_UC_FIRMWARE_DISABLED;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_disabled(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) == XE_UC_FIRMWARE_DISABLED;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_available(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) >= XE_UC_FIRMWARE_AVAILABLE;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_loadable(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) >= XE_UC_FIRMWARE_LOADABLE;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_loaded(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) >= XE_UC_FIRMWARE_TRANSFERRED;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_running(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return __xe_uc_fw_status(uc_fw) == XE_UC_FIRMWARE_RUNNING;
|
|
}
|
|
|
|
static inline bool xe_uc_fw_is_overridden(const struct xe_uc_fw *uc_fw)
|
|
{
|
|
return uc_fw->user_overridden;
|
|
}
|
|
|
|
static inline void xe_uc_fw_sanitize(struct xe_uc_fw *uc_fw)
|
|
{
|
|
if (xe_uc_fw_is_loaded(uc_fw))
|
|
xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_LOADABLE);
|
|
}
|
|
|
|
static inline u32 __xe_uc_fw_get_upload_size(struct xe_uc_fw *uc_fw)
|
|
{
|
|
return sizeof(struct uc_css_header) + uc_fw->ucode_size;
|
|
}
|
|
|
|
/**
|
|
* xe_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 xe_uc_fw_get_upload_size(struct xe_uc_fw *uc_fw)
|
|
{
|
|
if (!xe_uc_fw_is_available(uc_fw))
|
|
return 0;
|
|
|
|
return __xe_uc_fw_get_upload_size(uc_fw);
|
|
}
|
|
|
|
#define XE_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
|
|
|
|
#endif
|