drm/xe/uc: Add GuC/HuC firmware path overrides

When testing a new binary and/or debugging binary-related issues, it is
useful to have the option to change which binary is loaded without
having to update and re-compile the kernel. To support this option, this
patch adds 2 new modparams to override the FW path for GuC and HuC. The
HuC modparam can also be set to an empty string to disable HuC loading.

Note that those modparams only take effect on platforms where we already
have a default FW, so we're sure there is support for FW loading and the
kernel isn't going to explode in an undefined path.

v2: simplify comment (John),
    rebase on s/guc_submission_enabled/uc_enabled

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
pull/477/merge
Daniele Ceraolo Spurio 2023-09-13 16:28:37 -07:00 committed by Rodrigo Vivi
parent 757308471d
commit a455ed0466
3 changed files with 41 additions and 1 deletions

View File

@ -27,6 +27,16 @@ int xe_guc_log_level = 5;
module_param_named(guc_log_level, xe_guc_log_level, int, 0600);
MODULE_PARM_DESC(guc_log_level, "GuC firmware logging level (0=disable, 1..5=enable with verbosity min..max)");
char *xe_guc_firmware_path;
module_param_named_unsafe(guc_firmware_path, xe_guc_firmware_path, charp, 0400);
MODULE_PARM_DESC(guc_firmware_path,
"GuC firmware path to use instead of the default one");
char *xe_huc_firmware_path;
module_param_named_unsafe(huc_firmware_path, xe_huc_firmware_path, charp, 0400);
MODULE_PARM_DESC(huc_firmware_path,
"HuC firmware path to use instead of the default one - empty string disables");
char *xe_param_force_probe = CONFIG_DRM_XE_FORCE_PROBE;
module_param_named_unsafe(force_probe, xe_param_force_probe, charp, 0400);
MODULE_PARM_DESC(force_probe,

View File

@ -10,4 +10,6 @@ extern bool force_execlist;
extern bool enable_display;
extern u32 xe_force_vram_bar_size;
extern int xe_guc_log_level;
extern char *xe_guc_firmware_path;
extern char *xe_huc_firmware_path;
extern char *xe_param_force_probe;

View File

@ -15,6 +15,7 @@
#include "xe_gt.h"
#include "xe_map.h"
#include "xe_mmio.h"
#include "xe_module.h"
#include "xe_uc_fw.h"
/*
@ -210,6 +211,30 @@ uc_fw_auto_select(struct xe_device *xe, struct xe_uc_fw *uc_fw)
}
}
static void
uc_fw_override(struct xe_uc_fw *uc_fw)
{
char *path_override = NULL;
/* empty string disables, but it's not allowed for GuC */
switch (uc_fw->type) {
case XE_UC_FW_TYPE_GUC:
if (xe_guc_firmware_path && *xe_guc_firmware_path)
path_override = xe_guc_firmware_path;
break;
case XE_UC_FW_TYPE_HUC:
path_override = xe_huc_firmware_path;
break;
default:
break;
}
if (path_override) {
uc_fw->path = path_override;
uc_fw->user_overridden = true;
}
}
/**
* xe_uc_fw_copy_rsa - copy fw RSA to buffer
*
@ -347,7 +372,10 @@ int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
if (!xe_uc_fw_is_supported(uc_fw))
return 0;
if (!xe_device_uc_enabled(xe)) {
uc_fw_override(uc_fw);
/* an empty path means the firmware is disabled */
if (!xe_device_uc_enabled(xe) || !(*uc_fw->path)) {
xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_DISABLED);
drm_dbg(&xe->drm, "%s disabled", xe_uc_fw_type_repr(uc_fw->type));
return 0;