2017-10-04 15:33:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2014-2017 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INTEL_UC_FW_H_
|
|
|
|
#define _INTEL_UC_FW_H_
|
|
|
|
|
2019-06-26 14:40:19 +00:00
|
|
|
#include <linux/types.h>
|
2019-07-26 18:42:10 +00:00
|
|
|
#include "intel_uc_fw_abi.h"
|
2019-08-07 17:00:29 +00:00
|
|
|
#include "intel_device_info.h"
|
2019-07-13 10:00:08 +00:00
|
|
|
#include "i915_gem.h"
|
2019-06-26 14:40:19 +00:00
|
|
|
|
2017-10-17 09:44:49 +00:00
|
|
|
struct drm_printer;
|
2017-10-04 15:33:25 +00:00
|
|
|
struct drm_i915_private;
|
2019-07-25 00:18:12 +00:00
|
|
|
struct intel_gt;
|
2017-10-04 15:33:25 +00:00
|
|
|
|
2017-10-16 14:47:20 +00:00
|
|
|
/* Home of GuC, HuC and DMC firmwares */
|
2018-04-30 22:59:28 +00:00
|
|
|
#define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915"
|
2017-10-16 14:47:19 +00:00
|
|
|
|
2017-10-04 15:33:25 +00:00
|
|
|
enum intel_uc_fw_status {
|
2019-08-02 18:40:52 +00:00
|
|
|
INTEL_UC_FIRMWARE_NOT_SUPPORTED = -1, /* no uc HW or disabled */
|
2019-07-13 10:00:08 +00:00
|
|
|
INTEL_UC_FIRMWARE_UNINITIALIZED = 0, /* used to catch checks done too early */
|
2019-07-25 00:18:09 +00:00
|
|
|
INTEL_UC_FIRMWARE_SELECTED, /* selected the blob we want to load */
|
2019-08-02 18:40:52 +00:00
|
|
|
INTEL_UC_FIRMWARE_MISSING, /* blob not found on the system */
|
2019-08-07 18:37:59 +00:00
|
|
|
INTEL_UC_FIRMWARE_ERROR, /* invalid format or version */
|
2019-07-25 00:18:09 +00:00
|
|
|
INTEL_UC_FIRMWARE_AVAILABLE, /* blob found and copied in mem */
|
2019-08-02 18:40:52 +00:00
|
|
|
INTEL_UC_FIRMWARE_FAIL, /* failed to xfer or init/auth the fw */
|
2019-07-25 00:18:09 +00:00
|
|
|
INTEL_UC_FIRMWARE_TRANSFERRED, /* dma xfer done */
|
|
|
|
INTEL_UC_FIRMWARE_RUNNING /* init/auth done */
|
2017-10-04 15:33:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum intel_uc_fw_type {
|
2019-07-25 00:18:08 +00:00
|
|
|
INTEL_UC_FW_TYPE_GUC = 0,
|
2017-10-04 15:33:25 +00:00
|
|
|
INTEL_UC_FW_TYPE_HUC
|
|
|
|
};
|
2019-07-25 00:18:08 +00:00
|
|
|
#define INTEL_UC_FW_NUM_TYPES 2
|
2017-10-04 15:33:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 {
|
2019-07-26 18:42:10 +00:00
|
|
|
enum intel_uc_fw_type type;
|
|
|
|
enum intel_uc_fw_status status;
|
2017-10-04 15:33:25 +00:00
|
|
|
const char *path;
|
2019-07-29 11:26:12 +00:00
|
|
|
bool user_overridden;
|
2017-10-04 15:33:25 +00:00
|
|
|
size_t size;
|
|
|
|
struct drm_i915_gem_object *obj;
|
|
|
|
|
2017-10-16 14:47:13 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-10-06 08:49:40 +00:00
|
|
|
u16 major_ver_wanted;
|
|
|
|
u16 minor_ver_wanted;
|
|
|
|
u16 major_ver_found;
|
|
|
|
u16 minor_ver_found;
|
2017-10-04 15:33:25 +00:00
|
|
|
|
2017-10-06 08:49:40 +00:00
|
|
|
u32 rsa_size;
|
|
|
|
u32 ucode_size;
|
2017-10-04 15:33:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline
|
|
|
|
const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
2019-07-25 00:18:09 +00:00
|
|
|
case INTEL_UC_FIRMWARE_NOT_SUPPORTED:
|
|
|
|
return "N/A";
|
2019-07-13 10:00:08 +00:00
|
|
|
case INTEL_UC_FIRMWARE_UNINITIALIZED:
|
|
|
|
return "UNINITIALIZED";
|
2019-07-25 00:18:09 +00:00
|
|
|
case INTEL_UC_FIRMWARE_SELECTED:
|
|
|
|
return "SELECTED";
|
2019-08-02 18:40:52 +00:00
|
|
|
case INTEL_UC_FIRMWARE_MISSING:
|
|
|
|
return "MISSING";
|
2019-08-07 18:37:59 +00:00
|
|
|
case INTEL_UC_FIRMWARE_ERROR:
|
|
|
|
return "ERROR";
|
2019-07-25 00:18:09 +00:00
|
|
|
case INTEL_UC_FIRMWARE_AVAILABLE:
|
|
|
|
return "AVAILABLE";
|
2019-08-02 18:40:52 +00:00
|
|
|
case INTEL_UC_FIRMWARE_FAIL:
|
|
|
|
return "FAIL";
|
2019-07-25 00:18:09 +00:00
|
|
|
case INTEL_UC_FIRMWARE_TRANSFERRED:
|
|
|
|
return "TRANSFERRED";
|
|
|
|
case INTEL_UC_FIRMWARE_RUNNING:
|
|
|
|
return "RUNNING";
|
2017-10-04 15:33:25 +00:00
|
|
|
}
|
|
|
|
return "<invalid>";
|
|
|
|
}
|
|
|
|
|
2019-08-11 19:51:29 +00:00
|
|
|
static inline int intel_uc_fw_status_to_error(enum intel_uc_fw_status status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
|
|
|
case INTEL_UC_FIRMWARE_NOT_SUPPORTED:
|
|
|
|
case INTEL_UC_FIRMWARE_UNINITIALIZED:
|
|
|
|
return -EPERM;
|
|
|
|
case INTEL_UC_FIRMWARE_MISSING:
|
|
|
|
return -ENOENT;
|
|
|
|
case INTEL_UC_FIRMWARE_ERROR:
|
|
|
|
return -ENOEXEC;
|
|
|
|
case INTEL_UC_FIRMWARE_FAIL:
|
|
|
|
return -EIO;
|
|
|
|
case INTEL_UC_FIRMWARE_SELECTED:
|
|
|
|
case INTEL_UC_FIRMWARE_AVAILABLE:
|
|
|
|
case INTEL_UC_FIRMWARE_TRANSFERRED:
|
|
|
|
case INTEL_UC_FIRMWARE_RUNNING:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-04 15:33:25 +00:00
|
|
|
static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case INTEL_UC_FW_TYPE_GUC:
|
|
|
|
return "GuC";
|
|
|
|
case INTEL_UC_FW_TYPE_HUC:
|
|
|
|
return "HuC";
|
|
|
|
}
|
|
|
|
return "uC";
|
|
|
|
}
|
|
|
|
|
2019-07-25 00:18:09 +00:00
|
|
|
static inline enum intel_uc_fw_status
|
|
|
|
__intel_uc_fw_status(struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
|
|
|
/* shouldn't call this before checking hw/blob availability */
|
|
|
|
GEM_BUG_ON(uc_fw->status == INTEL_UC_FIRMWARE_UNINITIALIZED);
|
|
|
|
return uc_fw->status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool intel_uc_fw_is_available(struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
|
|
|
return __intel_uc_fw_status(uc_fw) >= INTEL_UC_FIRMWARE_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2018-10-02 21:54:28 +00:00
|
|
|
static inline bool intel_uc_fw_is_loaded(struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
2019-07-25 00:18:09 +00:00
|
|
|
return __intel_uc_fw_status(uc_fw) >= INTEL_UC_FIRMWARE_TRANSFERRED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool intel_uc_fw_is_running(struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
|
|
|
return __intel_uc_fw_status(uc_fw) == INTEL_UC_FIRMWARE_RUNNING;
|
2018-10-02 21:54:28 +00:00
|
|
|
}
|
|
|
|
|
2019-07-13 10:00:08 +00:00
|
|
|
static inline bool intel_uc_fw_supported(struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
2019-07-25 00:18:09 +00:00
|
|
|
return __intel_uc_fw_status(uc_fw) != INTEL_UC_FIRMWARE_NOT_SUPPORTED;
|
2019-07-13 10:00:08 +00:00
|
|
|
}
|
|
|
|
|
2019-07-29 11:26:12 +00:00
|
|
|
static inline bool intel_uc_fw_is_overridden(const struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
|
|
|
return uc_fw->user_overridden;
|
|
|
|
}
|
|
|
|
|
2018-03-12 13:03:07 +00:00
|
|
|
static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw)
|
|
|
|
{
|
2018-10-02 21:54:28 +00:00
|
|
|
if (intel_uc_fw_is_loaded(uc_fw))
|
2019-07-25 00:18:09 +00:00
|
|
|
uc_fw->status = INTEL_UC_FIRMWARE_AVAILABLE;
|
2018-03-12 13:03:07 +00:00
|
|
|
}
|
|
|
|
|
2018-03-14 00:32:50 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2019-07-25 00:18:09 +00:00
|
|
|
if (!intel_uc_fw_is_available(uc_fw))
|
2018-03-14 00:32:50 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-07-26 18:42:10 +00:00
|
|
|
return sizeof(struct uc_css_header) + uc_fw->ucode_size;
|
2018-03-14 00:32:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-25 00:18:08 +00:00
|
|
|
void intel_uc_fw_init_early(struct intel_uc_fw *uc_fw,
|
2019-08-07 17:00:29 +00:00
|
|
|
enum intel_uc_fw_type type, bool supported,
|
|
|
|
enum intel_platform platform, u8 rev);
|
2019-08-07 17:00:30 +00:00
|
|
|
int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw, struct drm_i915_private *i915);
|
2019-04-19 23:00:11 +00:00
|
|
|
void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw);
|
2019-07-25 00:18:12 +00:00
|
|
|
int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, struct intel_gt *gt,
|
2019-07-25 00:18:13 +00:00
|
|
|
u32 wopcm_offset, u32 dma_flags);
|
2019-04-19 23:00:13 +00:00
|
|
|
int intel_uc_fw_init(struct intel_uc_fw *uc_fw);
|
|
|
|
void intel_uc_fw_fini(struct intel_uc_fw *uc_fw);
|
2019-07-25 00:18:10 +00:00
|
|
|
size_t intel_uc_fw_copy_rsa(struct intel_uc_fw *uc_fw, void *dst, u32 max_len);
|
2017-10-26 17:36:55 +00:00
|
|
|
void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p);
|
2017-10-04 15:33:25 +00:00
|
|
|
|
|
|
|
#endif
|