Enable HDCP2 via GSC CS command submission
Subsystems (5)
cover Enable HDCP2 via GSC CS command submission
Starting from MTL HDCP will be enabled via the GSC CS route rather than going through the usual MEI route as it did before From now on GSC will be the mei client and all HDCP has to do is add on a gsc header along with its normal payload and send messages to GSC CS who will take care of the rest and loop depending on the reply received
Anshuman Gupta (3):
drm/i915/hdcp: Keep cp fw agonstic naming convention drm/i915/hdcp: HDCP2.x Refactoring to agnotic cp f/w drm/i915/hdcp: Refactor HDCP API structures
Daniele Ceraolo Spurio (5):
drm/i915/uc: Introduce GSC FW
drm/i915/gsc: Skip the version check when fetching the GSC FW drm/i915/gsc: GSC firmware loading
drm/i915/gsc: Do a driver-FLR on unload if GSC was loaded drm/i915/mtl: MTL has one GSC CS on the media GT
Jonathan Cavitt (1):
drm/i915/gsc: Disable GSC engine and power well if FW is not selected
Suraj Kandpal (4):
drm/i915/gsc: Create GSC request submission mechanism drm/i915/hdcp: Fill wired_cmd_in structures at a single place drm/i915/mtl: Adding function to send command to GSC CS drm/i915/mtl: Add HDCP GSC interface
drivers/gpu/drm/i915/Makefile | 5 +- .../gpu/drm/i915/display/intel_display_core.h | 3 +- .../drm/i915/display/intel_display_types.h | 2 +- drivers/gpu/drm/i915/display/intel_hdcp.c | 94 ++- drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 708 +++++++++++++++++ drivers/gpu/drm/i915/display/intel_hdcp_gsc.h | 27 + drivers/gpu/drm/i915/gem/i915_gem_pm.c | 14 +- drivers/gpu/drm/i915/gt/intel_engine.h | 2 + drivers/gpu/drm/i915/gt/intel_engine_cs.c | 18 + drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 9 + drivers/gpu/drm/i915/gt/intel_gt.c | 11 + drivers/gpu/drm/i915/gt/intel_gt.h | 5 + drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 251 ++++++ drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h | 18 + drivers/gpu/drm/i915/gt/uc/intel_gsc_fwif.h | 43 + drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c | 103 +++ drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h | 43 + drivers/gpu/drm/i915/gt/uc/intel_uc.c | 32 + drivers/gpu/drm/i915/gt/uc/intel_uc.h | 5 + drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 77 +- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 8 +- drivers/gpu/drm/i915/i915_params.c | 3 + drivers/gpu/drm/i915/i915_params.h | 1 + drivers/gpu/drm/i915/i915_pci.c | 2 +- drivers/gpu/drm/i915/i915_reg.h | 3 + drivers/gpu/drm/i915/intel_uncore.c | 48 ++ drivers/gpu/drm/i915/intel_uncore.h | 13 + drivers/misc/mei/hdcp/mei_hdcp.c | 190 +---- drivers/misc/mei/hdcp/mei_hdcp.h | 355 +-------- include/drm/i915_cp_fw_hdcp_interface.h | 738 ++++++++++++++++++ include/drm/i915_mei_hdcp_interface.h | 184 ----- 31 files changed, 2257 insertions(+), 758 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_fwif.h create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h create mode 100644 include/drm/i915_cp_fw_hdcp_interface.h delete mode 100644 include/drm/i915_mei_hdcp_interface.h
Signature · 1 line
2.25.1
PATCH 1/13 drm/i915/uc: Introduce GSC FW
From: Daniele Ceraolo Spurio <[email protected]>
On MTL the GSC FW needs to be loaded on the media GT by the graphics driver. We're going to treat it like a new uc_fw, so add the initial defs and init/fini functions for it.
Similarly to the other FWs, the GSC FW path can be overriden via modparam. The modparam can also be used to disable the GSC FW loading by setting it to an empty string.
Note that the new structure has been called intel_gsc_uc to avoid confusion with the existing intel_gsc, which instead represents the heci gsc interfaces.
--- drivers/gpu/drm/i915/Makefile | 3 +- drivers/gpu/drm/i915/gt/intel_gt.h | 5 ++ drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c | 70 +++++++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h | 36 ++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_uc.c | 17 ++++++ drivers/gpu/drm/i915/gt/uc/intel_uc.h | 3 + drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 25 +++++++- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 7 ++- drivers/gpu/drm/i915/i915_params.c | 3 + drivers/gpu/drm/i915/i915_params.h | 1 + 10 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h
drivers/gpu/drm/i915/Makefile +2 -1
@@ -205,7 +205,8 @@ i915-y += gt/uc/intel_uc.o \ gt/uc/intel_guc_submission.o \ gt/uc/intel_huc.o \ gt/uc/intel_huc_debugfs.o \ - gt/uc/intel_huc_fw.o + gt/uc/intel_huc_fw.o \ + gt/uc/intel_gsc_uc.o # graphics system controller (GSC) support i915-y += gt/intel_gsc.o
drivers/gpu/drm/i915/gt/intel_gt.h +5 -0
@@ -39,6 +39,11 @@ static inline struct intel_gt *huc_to_gt(struct intel_huc *huc) return container_of(huc, struct intel_gt, uc.huc); } +static inline struct intel_gt *gsc_uc_to_gt (struct intel_gsc_uc *gsc_uc) +{ + return container_of(gsc_uc, struct intel_gt, uc.gsc); +} +static inline struct intel_gt *gsc_to_gt (struct intel_gsc *gsc) { return container_of(gsc, struct intel_gt, gsc);
drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c new file +70 -0
70 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2022 Intel Corporation +*/ + +#ifndef _INTEL_GSC_UC_H_ +#define _INTEL_GSC_UC_H_ + +#include "intel_uc_fw.h" + +struct intel_gsc_uc { +/* Generic uC firmware management */ +struct intel_uc_fw fw; +}; + +void intel_gsc_uc_init_early (struct intel_gsc_uc *gsc); +int intel_gsc_uc_init (struct intel_gsc_uc *gsc); +void intel_gsc_uc_fini (struct intel_gsc_uc *gsc); + +static inline bool intel_gsc_uc_is_supported (struct intel_gsc_uc *gsc) +{ +return intel_uc_fw_is_supported (&gsc->fw); +} + +static inline bool intel_gsc_uc_is_wanted (struct intel_gsc_uc *gsc) +{ +return intel_uc_fw_is_enabled (&gsc->fw); +} + +static inline bool intel_gsc_uc_is_used (struct intel_gsc_uc *gsc) +{ +GEM_BUG_ON (__intel_uc_fw_status (&gsc->fw) ==INTEL_UC_FIRMWARE_SELECTED ); +return intel_uc_fw_is_available (&gsc->fw); +} + +#endif
drivers/gpu/drm/i915/gt/uc/intel_uc.c +17 -0
@@ -7,6 +7,7 @@#include "gt/intel_gt.h" #include "gt/intel_reset.h" +#include "intel_gsc_uc.h" #include "intel_guc.h" #include "intel_guc_ads.h" #include "intel_guc_submission.h"
@@ -126,6 +127,7 @@ void intel_uc_init_early(struct intel_uc *uc)intel_guc_init_early (&uc->guc);intel_huc_init_early (&uc->huc); +intel_gsc_uc_init_early (&uc->gsc);__confirm_options (uc);
@@ -296,15 +298,26 @@ static void __uc_fetch_firmwares(struct intel_uc *uc) INTEL_UC_FIRMWARE_ERROR); } +if (intel_uc_wants_gsc_uc (uc)) { +drm_dbg (&uc_to_gt (uc)->i915->drm, +"Failed to fetch GuC: %d disabling GSC\n" , err); +intel_uc_fw_change_status (&uc->gsc.fw, +INTEL_UC_FIRMWARE_ERROR ); + } +return ; }if (intel_uc_wants_huc (uc))intel_uc_fw_fetch (&uc->huc.fw); + +if (intel_uc_wants_gsc_uc (uc)) +intel_uc_fw_fetch (&uc->gsc.fw); }static void __uc_cleanup_firmwares (struct intel_uc *uc) { +intel_uc_fw_cleanup_fetch (&uc->gsc.fw);intel_uc_fw_cleanup_fetch (&uc->huc.fw);intel_uc_fw_cleanup_fetch (&uc->guc.fw); }
@@ -330,11 +343,15 @@ static int __uc_init(struct intel_uc *uc)if (intel_uc_uses_huc (uc))intel_huc_init (huc); +if (intel_uc_uses_gsc_uc (uc)) +intel_gsc_uc_init (&uc->gsc); +return 0 ; }static void __uc_fini (struct intel_uc *uc) { +intel_gsc_uc_fini (&uc->gsc);intel_huc_fini (&uc->huc);intel_guc_fini (&uc->guc); }
drivers/gpu/drm/i915/gt/uc/intel_uc.h +3 -0
@@ -6,6 +6,7 @@#ifndef _INTEL_UC_H_#define _INTEL_UC_H_ +#include "intel_gsc_uc.h" #include "intel_guc.h" #include "intel_guc_rc.h" #include "intel_guc_submission.h"
@@ -27,6 +28,7 @@ struct intel_uc_ops {struct intel_uc {struct intel_uc_ops const *ops; +struct intel_gsc_uc gsc;struct intel_guc guc;struct intel_huc huc;
@@ -87,6 +89,7 @@ uc_state_checkers(huc, huc);uc_state_checkers (guc, guc_submission);uc_state_checkers (guc, guc_slpc);uc_state_checkers (guc, guc_rc); +uc_state_checkers (gsc, gsc_uc);#undef uc_state_checkers#undef __uc_state_checker
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +22 -3
@@ -19,11 +19,18 @@static inline struct intel_gt *____uc_fw_to_gt (struct intel_uc_fw *uc_fw,enum intel_uc_fw_type type) { -if (type ==INTEL_UC_FW_TYPE_GUC ) +GEM_BUG_ON (type >=INTEL_UC_FW_NUM_TYPES ); + +switch (type) { +case INTEL_UC_FW_TYPE_GUC : return container_of(uc_fw, struct intel_gt, uc.guc.fw); +case INTEL_UC_FW_TYPE_HUC : + return container_of(uc_fw, struct intel_gt, uc.huc.fw); +case INTEL_UC_FW_TYPE_GSC : + return container_of(uc_fw, struct intel_gt, uc.gsc.fw); + } -GEM_BUG_ON (type !=INTEL_UC_FW_TYPE_HUC ); - return container_of(uc_fw, struct intel_gt, uc.huc.fw); +return NULL ; }static inline struct intel_gt *__uc_fw_to_gt (struct intel_uc_fw *uc_fw)
@@ -246,6 +253,10 @@ __uc_fw_auto_select(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw)int i;bool found; +/* FW is not defined until all the support is in place */ +if (uc_fw->type ==INTEL_UC_FW_TYPE_GSC ) +return ; +/* * The only difference between the ADL GuC FWs is the HWConfig support. * ADL-N does not support HWConfig, so we should use the same binary as
@@ -375,6 +386,11 @@ static const char *__override_huc_firmware_path(struct drm_i915_private *i915)return "" ; } +static const char *__override_gsc_firmware_path (struct drm_i915_private *i915) +{ +return i915->params.gsc_firmware_path; +} +static void __uc_fw_user_override (struct drm_i915_private *i915,struct intel_uc_fw *uc_fw) {const char *path =NULL ;
@@ -386,6 +402,9 @@ static void __uc_fw_user_override(struct drm_i915_private *i915, struct intel_uccase INTEL_UC_FW_TYPE_HUC : path =__override_huc_firmware_path (i915);break ; +case INTEL_UC_FW_TYPE_GSC : + path =__override_gsc_firmware_path (i915); +break ; }if (unlikely (path)) {
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +5 -2
@@ -61,9 +61,10 @@ enum intel_uc_fw_status {enum intel_uc_fw_type {INTEL_UC_FW_TYPE_GUC =0 , -INTEL_UC_FW_TYPE_HUC +INTEL_UC_FW_TYPE_HUC , +INTEL_UC_FW_TYPE_GSC , }; -#define INTEL_UC_FW_NUM_TYPES 2 +#define INTEL_UC_FW_NUM_TYPES 3struct intel_uc_fw_ver {u32 major;
@@ -204,6 +205,8 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)return "GuC" ;case INTEL_UC_FW_TYPE_HUC :return "HuC" ; +case INTEL_UC_FW_TYPE_GSC : +return "GSC" ; }return "uC" ; }
drivers/gpu/drm/i915/i915_params.c +3 -0
@@ -192,6 +192,9 @@ i915_param_named_unsafe(huc_firmware_path, charp, 0400,i915_param_named_unsafe (dmc_firmware_path, charp,0400 ,"DMC firmware path to use instead of the default one" ); +i915_param_named_unsafe (gsc_firmware_path, charp,0400 , +"GSC firmware path to use instead of the default one" ); +i915_param_named_unsafe (enable_dp_mst, bool,0400 ,"Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)" );
drivers/gpu/drm/i915/i915_params.h +1 -0
@@ -64,6 +64,7 @@ struct drm_printer; param(char *, guc_firmware_path, NULL, 0400) \ param(char *, huc_firmware_path, NULL, 0400) \ param(char *, dmc_firmware_path, NULL, 0400) \ + param(char *, gsc_firmware_path, NULL, 0400) \ param(bool, memtest, false, 0400) \ param(int, mmio_debug, -IS_ENABLED(CONFIG_DRM_I915_DEBUG_MMIO), 0600) \param (int, edp_vswing,0 ,0400 ) \
Signature · 1 line
2.25.1
PATCH 2/13 drm/i915/gsc: Skip the version check when fetching the GSC FW
In reply to Suraj KandpalFrom: Daniele Ceraolo Spurio <[email protected]>
The current exectation from the FW side is that the driver will query the GSC FW version after the FW is loaded, similarly to what the mei driver does on DG2. However, we're discussing with the FW team if there is a way to extract the version from the bin file before loading, so we can keep the code the same as for older FWs.
Since the GSC FW version is not currently required for functionality and is only needed for debug purposes, we can skip the FW version for now at fetch time and add it later on when we've agreed on the approach.
--- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 32 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +24 -8
@@ -651,6 +651,26 @@ static bool guc_check_version_range(struct intel_uc_fw *uc_fw)return true; } +static int check_fw_header (struct intel_gt *gt, +const struct firmware *fw, +struct intel_uc_fw *uc_fw) +{ +int err =0 ; + +/* GSC FW version is queried after the FW is loaded */ +if (uc_fw->type ==INTEL_UC_FW_TYPE_GSC ) +return 0 ; + +if (uc_fw->loaded_via_gsc) + err =check_gsc_manifest (fw, uc_fw); +else + err =check_ccs_header (gt, fw, uc_fw); +if (err) +return err; + +return 0 ; +} +/** * intel_uc_fw_fetch - fetch uC firmware * @uc_fw: uC firmware
@@ -720,17 +740,13 @@ int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw)if (err) goto fail; -if (uc_fw->loaded_via_gsc) - err =check_gsc_manifest (fw, uc_fw); -else - err =check_ccs_header (gt, fw, uc_fw); + err =check_fw_header (gt, fw, uc_fw);if (err) goto fail;if (uc_fw->type ==INTEL_UC_FW_TYPE_GUC && !guc_check_version_range (uc_fw)) - goto fail; - -if (uc_fw->file_wanted.ver.major) { + goto fail; +if (uc_fw->file_wanted.ver.major && uc_fw->file_selected.ver.major) {/* Check the file's major version was as it claimed */ if (uc_fw->file_selected.ver.major != uc_fw->file_wanted.ver.major) { drm_notice(&i915->drm, "%s firmware %s: unexpected version: %u.%u != %u.%u\n",
@@ -747,7 +763,7 @@ int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw) } } -if (old_ver) { +if (old_ver && uc_fw->file_selected.ver.major) {/* Preserve the version that was really wanted */ memcpy (&uc_fw->file_wanted, &file_ideal,sizeof (uc_fw->file_wanted));
Signature · 1 line
2.25.1
PATCH 3/13 drm/i915/gsc: GSC firmware loading
In reply to Suraj KandpalFrom: Daniele Ceraolo Spurio <[email protected]>
GSC FW is loaded by submitting a dedicated command via the GSC engine. The memory area used for loading the FW is then re-purposed as local memory for the GSC itself, so we use a separate allocation instead of using the one where we keep the firmware stored for reload.
The GSC is not reset as part of GT reset, so we only need to load it on first boot and S3/S4 exit.
Note that the GSC load takes a lot of time (up to a few hundred ms). This patch loads it serially as part of driver init/resume, but, given that GSC is only required for PM and content-protection features (media C6, PXP, HDCP), we could move the load to a worker thread to unblock non-CP userspace submissions earlier. This will be done as a follow up step, because there are extra init steps required to actually make use of the GSC (including a mei component) and it will be cleaner (and easier to review) if we implement the async load once all the pieces we need for GSC to work are in place. A TODO has been added to the code to mark this intention.
Bspec: 63347, 65346
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gem/i915_gem_pm.c | 14 +- drivers/gpu/drm/i915/gt/intel_engine.h | 2 + drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 7 + drivers/gpu/drm/i915/gt/intel_gt.c | 11 ++ drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 186 +++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h | 13 ++ drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c | 35 +++- drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h | 7 + drivers/gpu/drm/i915/gt/uc/intel_uc.c | 15 ++ drivers/gpu/drm/i915/gt/uc/intel_uc.h | 2 + drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 20 +- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 1 + 13 files changed, 307 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h
drivers/gpu/drm/i915/Makefile +1 -0
@@ -206,6 +206,7 @@ i915-y += gt/uc/intel_uc.o \ gt/uc/intel_huc.o \ gt/uc/intel_huc_debugfs.o \ gt/uc/intel_huc_fw.o \ + gt/uc/intel_gsc_fw.o \ gt/uc/intel_gsc_uc.o # graphics system controller (GSC) support
drivers/gpu/drm/i915/gem/i915_gem_pm.c +13 -1
@@ -232,10 +232,22 @@ void i915_gem_resume(struct drm_i915_private *i915)* guarantee that the context image is complete. So let's just reset * it and start again. */ -for_each_gt (gt, i915, i) +for_each_gt (gt, i915, i) {if (intel_gt_resume (gt)) goto err_wedged; +/* +* TODO: this is a long operation (up to ~200ms) and we don't +* need to complete it before driver load/resume is done, so it +* should be handled in a separate thread to unlock userspace +* submission. However, there are a couple of other pieces that +* are required for full GSC support that will complicate things +* a bit, and it is easier to move everything to a worker at the +* same time, so keep it here for now. +*/ +intel_uc_init_hw_late (>->uc); + } + ret =lmem_restore (i915,I915_TTM_BACKUP_ALLOW_GPU );GEM_WARN_ON (ret);
drivers/gpu/drm/i915/gt/intel_engine.h +2 -0
@@ -172,6 +172,8 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)#define I915_GEM_HWS_MIGRATE (0x42 * sizeof(u32))#define I915_GEM_HWS_PXP 0x60#define I915_GEM_HWS_PXP_ADDR (I915_GEM_HWS_PXP * sizeof(u32)) +#define I915_GEM_HWS_GSC 0x62 +#define I915_GEM_HWS_GSC_ADDR (I915_GEM_HWS_GSC * sizeof(u32))#define I915_GEM_HWS_SCRATCH 0x80#define I915_HWS_CSB_BUF0_INDEX 0x10
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +7 -0
@@ -21,6 +21,7 @@#define INSTR_CLIENT_SHIFT 29#define INSTR_MI_CLIENT 0x0#define INSTR_BC_CLIENT 0x2 +#define INSTR_GSC_CLIENT 0x2/* MTL+ */ #define INSTR_RC_CLIENT 0x3#define INSTR_SUBCLIENT_SHIFT 27#define INSTR_SUBCLIENT_MASK 0x18000000
@@ -432,6 +433,12 @@#define COLOR_BLT ((0x2<<29)|(0x40<<22))#define SRC_COPY_BLT ((0x2<<29)|(0x43<<22)) +#define GSC_INSTR (opcode, data, flags) \ + (__INSTR(INSTR_GSC_CLIENT) | (opcode) << 22 | (data) << 9 | (flags)) + +#define GSC_FW_LOAD GSC_INSTR(1, 0, 2) +#define HECI1_FW_LIMIT_VALID (1<<31) +/* * Used to convert any address to canonical form. * Starting from gen8, some commands (e.g. STATE_BASE_ADDRESS,
drivers/gpu/drm/i915/gt/intel_gt.c +11 -0
@@ -764,6 +764,17 @@ int intel_gt_init(struct intel_gt *gt)intel_pxp_init (>->pxp); +/* +* TODO: this is a long operation (up to ~200ms) and we don't need +* to complete it before driver load/resume is done, so it should +* be handled in a separate thread to unlock userspace submission. +* However, there are a couple of other pieces that are required +* for full GSC support that will complicate things a bit, and it +* is easier to move everything to a worker at the same time, so +* keep it here for now. +*/ +intel_uc_init_hw_late (>->uc); + goto out_fw; err_gt:__intel_gt_disable (gt);
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c new file +186 -0
186 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2022 Intel Corporation +*/ + +#ifndef _INTEL_GSC_FW_H_ +#define _INTEL_GSC_FW_H_ + +struct intel_gsc_uc ; + +int intel_gsc_fw_upload (struct intel_gsc_uc *gsc); + +#endif
drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.c +34 -1
@@ -45,17 +45,46 @@ void intel_gsc_uc_init_early(struct intel_gsc_uc *gsc)int intel_gsc_uc_init (struct intel_gsc_uc *gsc) { -struct drm_i915_private *i915 =gsc_uc_to_gt (gsc)->i915; +static struct lock_class_key gsc_lock; +struct intel_gt *gt =gsc_uc_to_gt (gsc); +struct drm_i915_private *i915 = gt->i915; +struct intel_engine_cs *engine = gt->engine[GSC0 ]; +struct intel_context *ce; +struct i915_vma *vma;int err; err =intel_uc_fw_init (&gsc->fw);if (err) goto out; + vma =intel_guc_allocate_vma (>->uc.guc,SZ_8M ); +if (IS_ERR (vma)) { + err =PTR_ERR (vma); + goto out_fw; + } + + gsc->local = vma; + + ce =intel_engine_create_pinned_context (engine, engine->gt->vm,SZ_4K , +I915_GEM_HWS_GSC_ADDR , + &gsc_lock,"gsc_context" ); +if (IS_ERR (ce)) { +drm_err (>->i915->drm, +"failed to create GSC CS ctx for FW communication\n" ); + err =PTR_ERR (ce); + goto out_vma; + } + + gsc->ce = ce; +intel_uc_fw_change_status (&gsc->fw,INTEL_UC_FIRMWARE_LOADABLE );return 0 ; +out_vma: +i915_vma_unpin_and_release (&gsc->local,0 ); +out_fw: +intel_uc_fw_fini (&gsc->fw); out:i915_probe_error (i915,"failed with %d\n" , err);return err;
@@ -66,5 +95,9 @@ void intel_gsc_uc_fini(struct intel_gsc_uc *gsc)if (!intel_uc_fw_is_loadable (&gsc->fw))return ; +if (gsc->ce) +intel_engine_destroy_pinned_context (fetch_and_zero (&gsc->ce)); + +i915_vma_unpin_and_release (&gsc->local,0 );intel_uc_fw_fini (&gsc->fw); }
drivers/gpu/drm/i915/gt/uc/intel_gsc_uc.h +7 -0
@@ -8,9 +8,16 @@#include "intel_uc_fw.h" +struct i915_vma ; +struct intel_context ; +struct intel_gsc_uc {/* Generic uC firmware management */ struct intel_uc_fw fw; + +/* GSC-specific additions */ +struct i915_vma *local;/* private memory for GSC usage */ +struct intel_context *ce;/* for submission to GSC FW via GSC engine */ };void intel_gsc_uc_init_early (struct intel_gsc_uc *gsc);
drivers/gpu/drm/i915/gt/uc/intel_uc.c +15 -0
@@ -7,6 +7,7 @@#include "gt/intel_gt.h" #include "gt/intel_reset.h" +#include "intel_gsc_fw.h" #include "intel_gsc_uc.h" #include "intel_guc.h" #include "intel_guc_ads.h"
@@ -593,6 +594,19 @@ static void __uc_fini_hw(struct intel_uc *uc)__uc_sanitize (uc); } +/* +* Firmwares loaded via the GSC engine require the submission back-end to have +* been initialized, so can only be loaded late in the probe/resume process. +* TODO move to worker +*/ +static int __uc_init_hw_late (struct intel_uc *uc) +{ +if (!intel_uc_uses_gsc_uc (uc)) +return 0 ; + +return intel_gsc_fw_upload (&uc->gsc); +} +/** * intel_uc_reset_prepare - Prepare for reset * @uc: the intel_uc structure
@@ -752,5 +766,6 @@ static const struct intel_uc_ops uc_ops_on = { .fini = __uc_fini, .init_hw = __uc_init_hw, + .init_hw_late = __uc_init_hw_late, .fini_hw = __uc_fini_hw, };
drivers/gpu/drm/i915/gt/uc/intel_uc.h +2 -0
@@ -23,6 +23,7 @@ struct intel_uc_ops {int (*init)(struct intel_uc *uc);void (*fini)(struct intel_uc *uc);int (*init_hw)(struct intel_uc *uc); +int (*init_hw_late)(struct intel_uc *uc);void (*fini_hw)(struct intel_uc *uc); };
@@ -112,6 +113,7 @@ intel_uc_ops_function(cleanup_firmwares, fini_fw, void, );intel_uc_ops_function (init, init, int,0 ); intel_uc_ops_function(fini, fini, void, );intel_uc_ops_function (init_hw, init_hw, int,0 ); +intel_uc_ops_function (init_hw_late, init_hw_late, int,0 ); intel_uc_ops_function(fini_hw, fini_hw, void, );#undef intel_uc_ops_function
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +15 -5
@@ -925,6 +925,20 @@ static int uc_fw_xfer(struct intel_uc_fw *uc_fw, u32 dst_offset, u32 dma_flags)return ret; } +int intel_uc_fw_mark_load_failed (struct intel_uc_fw *uc_fw,int err) +{ +struct intel_gt *gt =__uc_fw_to_gt (uc_fw); + +GEM_BUG_ON (!intel_uc_fw_is_loadable (uc_fw)); + +i915_probe_error (gt->i915,"Failed to load %s firmware %s (%d)\n" , +intel_uc_fw_type_repr (uc_fw->type), uc_fw->file_selected.path, + err); +intel_uc_fw_change_status (uc_fw,INTEL_UC_FIRMWARE_LOAD_FAIL ); + +return err; +} +/** * intel_uc_fw_upload - load uC firmware using custom loader * @uc_fw: uC firmware
@@ -961,11 +975,7 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, u32 dst_offset, u32 dma_flags)return 0 ; fail: -i915_probe_error (gt->i915,"Failed to load %s firmware %s (%d)\n" , -intel_uc_fw_type_repr (uc_fw->type), uc_fw->file_selected.path, - err); -intel_uc_fw_change_status (uc_fw,INTEL_UC_FIRMWARE_LOAD_FAIL ); -return err; +return intel_uc_fw_mark_load_failed (uc_fw, err); }static inline bool uc_fw_need_rsa_in_memory (struct intel_uc_fw *uc_fw)
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1 -0
@@ -289,6 +289,7 @@ 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);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
Signature · 1 line
2.25.1
PATCH 4/13 drm/i915/gsc: Do a driver-FLR on unload if GSC was loaded
In reply to Suraj KandpalFrom: Daniele Ceraolo Spurio <[email protected]>
If the GSC was loaded, the only way to stop it during the driver unload flow is to do a driver-FLR.
The driver-FLR is not the same as PCI config space FLR in that it doesn't reset the SGUnit and doesn't modify the PCI config space. Thus, it doesn't require a re-enumeration of the PCI BARs. However, the driver-FLR does cause a memory wipe of graphics memory on all discrete GPU platforms or a wipe limited to stolen memory on the integrated GPU platforms.
We perform the FLR as the last action before releasing the MMIO bar, so that we don't have to care about the consequences of the reset on the unload flow.
--- drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 9 +++++ drivers/gpu/drm/i915/i915_reg.h | 3 ++ drivers/gpu/drm/i915/intel_uncore.c | 45 +++++++++++++++++++++++ drivers/gpu/drm/i915/intel_uncore.h | 13 +++++++ 4 files changed, 70 insertions(+)
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +9 -0
@@ -173,6 +173,15 @@ int intel_gsc_fw_upload(struct intel_gsc_uc *gsc)if (err) goto fail; +/* +* Once the GSC FW is loaded, the only way to kill it on driver unload +* is to do a driver FLR. Given this is a very disruptive action, we +* want to do it as the last action before releasing the access to the +* MMIO bar, which means we need to do it as part of the primary uncore +* cleanup. +*/ +intel_uncore_set_flr_on_fini (>->i915->uncore); +/* FW is not fully operational until we enable SW proxy */ intel_uc_fw_change_status (gsc_fw,INTEL_UC_FIRMWARE_TRANSFERRED );
drivers/gpu/drm/i915/i915_reg.h +3 -0
@@ -118,6 +118,9 @@#define GU_CNTL _MMIO(0x101010)#define LMEM_INIT REG_BIT(7) +#define DRIVERFLR REG_BIT(31) +#define GU_DEBUG _MMIO(0x101018) +#define DRIVERFLR_STATUS REG_BIT(31)#define GEN6_STOLEN_RESERVED _MMIO(0x1082C0)#define GEN6_STOLEN_RESERVED_ADDR_MASK (0xFFF << 20)
drivers/gpu/drm/i915/intel_uncore.c +45 -0
57 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uncore.h +13 -0
@@ -153,6 +153,7 @@ struct intel_uncore {#define UNCORE_HAS_FPGA_DBG_UNCLAIMED BIT(1)#define UNCORE_HAS_DBG_UNCLAIMED BIT(2)#define UNCORE_HAS_FIFO BIT(3) +#define UNCORE_NEEDS_FLR_ON_FINI BIT(3)const struct intel_forcewake_range *fw_domains_table;unsigned int fw_domains_table_entries;
@@ -223,6 +224,18 @@ intel_uncore_has_fifo(const struct intel_uncore *uncore)return uncore->flags &UNCORE_HAS_FIFO ; } +static inline bool +intel_uncore_needs_flr_on_fini (const struct intel_uncore *uncore) +{ +return uncore->flags &UNCORE_NEEDS_FLR_ON_FINI ; +} + +static inline bool +intel_uncore_set_flr_on_fini (struct intel_uncore *uncore) +{ +return uncore->flags |=UNCORE_NEEDS_FLR_ON_FINI ; +} +void intel_uncore_mmio_debug_init_early (struct drm_i915_private *i915);void intel_uncore_init_early (struct intel_uncore *uncore,struct intel_gt *gt);
Signature · 1 line
2.25.1
PATCH 5/13 drm/i915/gsc: Disable GSC engine and power well if FW is not selected
In reply to Suraj KandpalFrom: Jonathan Cavitt <[email protected]>
The GSC CS is only used for communicating with the GSC FW, so no need to initialize it if we're not going to use the FW. If we're not using neither the engine nor the microcontoller, then we can also disable the power well.
IMPORTANT: lack of GSC FW breaks media C6 due to opposing requirements between CS setup and forcewake idleness. See in-code comment for detail.
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 18 ++++++++++++++++++ drivers/gpu/drm/i915/intel_uncore.c | 3 +++ 2 files changed, 21 insertions(+)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +18 -0
@@ -894,6 +894,24 @@ static intel_engine_mask_t init_engine_mask(struct intel_gt *gt)engine_mask_apply_compute_fuses (gt);engine_mask_apply_copy_fuses (gt); +/* +* The only use of the GSC CS is to load and communicate with the GSC +* FW, so we have no use for it if we don't have the FW. +* +* IMPORTANT: in cases where we don't have the GSC FW, we have a +* catch-22 situation that breaks media C6 due to 2 requirements: +* 1) once turned on, the GSC power well will not go to sleep unless the +* GSC FW is loaded. +* 2) to enable idling (which is required for media C6) we need to +* initialize the IDLE_MSG register for the GSC CS and do at least 1 +* submission, which will wake up the GSC power well. +*/ +if (__HAS_ENGINE (info->engine_mask,GSC0 ) && !intel_uc_wants_gsc_uc (>->uc)) { +drm_notice (>->i915->drm, +"No GSC FW selected, disabling GSC CS and media C6\n" ); + info->engine_mask &= ~BIT (GSC0 ); + } +return info->engine_mask; }
drivers/gpu/drm/i915/intel_uncore.c +3 -0
@@ -2701,6 +2701,9 @@ void intel_uncore_prune_engine_fw_domains(struct intel_uncore *uncore,if (fw_domains &BIT (domain_id))fw_domain_fini (uncore, domain_id); } + +if ((fw_domains &BIT (FW_DOMAIN_ID_GSC )) && !HAS_ENGINE (gt,GSC0 )) +fw_domain_fini (uncore,FW_DOMAIN_ID_GSC ); }static void driver_flr (struct intel_uncore *uncore)
Signature · 1 line
2.25.1
PATCH 6/13 drm/i915/mtl: MTL has one GSC CS on the media GT
In reply to Suraj KandpalFrom: Daniele Ceraolo Spurio <[email protected]>
Now that we have the GSC FW support code as a user to the GSC CS, we can add the relevant flag to the engine mask. Note that the engine will still be disabled until we define the GSC FW binary file.
--- drivers/gpu/drm/i915/i915_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_pci.c +1 -1
@@ -1125,7 +1125,7 @@ static const struct intel_gt_definition xelpmp_extra_gt[] = { .type = GT_MEDIA, .name = "Standalone Media GT", .gsi_offset = MTL_MEDIA_GSI_BASE, - .engine_mask = BIT(VECS0) | BIT(VCS0) | BIT(VCS2), + .engine_mask = BIT(VECS0) | BIT(VCS0) | BIT(VCS2) | BIT(GSC0), }, {} };
Signature · 1 line
2.25.1
PATCH 7/13 drm/i915/gsc: Create GSC request submission mechanism
In reply to Suraj KandpalHDCP and PXP will require a common function to allow it to submit commands to the gsc cs. Also adding the gsc mtl header that needs to be added on to the existing payloads of HDCP and PXP.
--- drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 + drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c | 62 +++++++++++++++++++- drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h | 5 ++ drivers/gpu/drm/i915/gt/uc/intel_gsc_fwif.h | 42 +++++++++++++ 4 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/uc/intel_gsc_fwif.h
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +2 -0
@@ -439,6 +439,8 @@#define GSC_FW_LOAD GSC_INSTR(1, 0, 2)#define HECI1_FW_LIMIT_VALID (1<<31) +#define GSC_HECI_CMD_PKT GSC_INSTR(0, 0, 6) +/* * Used to convert any address to canonical form. * Starting from gen8, some commands (e.g. STATE_BASE_ADDRESS,
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.c +59 -3
91 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_gsc_fw.h +5 -0
@@ -6,8 +6,13 @@#ifndef _INTEL_GSC_FW_H_#define _INTEL_GSC_FW_H_ +#include <linux/types.h> +struct intel_gsc_uc ;int intel_gsc_fw_upload (struct intel_gsc_uc *gsc); +int intel_gsc_fw_heci_send (struct intel_gsc_uc *gsc,u64 addr_in,u32 size_in, +u64 addr_out,u32 size_out); +#endif
drivers/gpu/drm/i915/gt/uc/intel_gsc_fwif.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 8/13 drm/i915/hdcp: Keep cp fw agonstic naming convention
In reply to Suraj KandpalFrom: Anshuman Gupta <[email protected]>
Change the include/drm/i915_mei_hdcp_interface.h to include/drm/i915_cp_fw_hdcp_interface.h
---
drivers/gpu/drm/i915/display/intel_display_types.h | 2 +-
drivers/misc/mei/hdcp/mei_hdcp.c | 2 +-
...915_mei_hdcp_interface.h => i915_cp_fw_hdcp_interface.h} | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
rename include/drm/{i915_mei_hdcp_interface.h => i915_cp_fw_hdcp_interface.h} (97%)drivers/gpu/drm/i915/display/intel_display_types.h +1 -1
@@ -43,7 +43,7 @@#include <drm/drm_rect.h> #include <drm/drm_vblank.h> #include <drm/drm_vblank_work.h> -#include <drm/i915_mei_hdcp_interface.h> +#include <drm/i915_cp_fw_hdcp_interface.h> #include <media/cec-notifier.h> #include "i915_vma.h"
drivers/misc/mei/hdcp/mei_hdcp.c +1 -1
@@ -23,7 +23,7 @@#include <linux/component.h> #include <drm/drm_connector.h> #include <drm/i915_component.h> -#include <drm/i915_mei_hdcp_interface.h> +#include <drm/i915_cp_fw_hdcp_interface.h> #include "mei_hdcp.h"
include/drm/i915_cp_fw_hdcp_interface.h renamed from include/drm/i915_mei_hdcp_interface.h +3 -3
@@ -6,8 +6,8 @@* Ramalingam C <[email protected]> */ -#ifndef _I915_MEI_HDCP_INTERFACE_H_ -#define _I915_MEI_HDCP_INTERFACE_H_ +#ifndef _I915_CP_FW_HDCP_INTERFACE_H_ +#define _I915_CP_FW_HDCP_INTERFACE_H_#include <linux/mutex.h> #include <linux/device.h>
@@ -181,4 +181,4 @@ struct i915_hdcp_comp_master { struct mutex mutex; }; -#endif /* _I915_MEI_HDCP_INTERFACE_H_ */ +#endif /* _I915_CP_FW_HDCP_INTERFACE_H_ */
Signature · 1 line
2.25.1
PATCH 9/13 drm/i915/hdcp: HDCP2.x Refactoring to agnotic cp f/w
In reply to Suraj KandpalFrom: Anshuman Gupta <[email protected]>
As now we have more then one type of content protection secrity firmware. Let change the i915_cp_fw_hdcp_interface.h header naming convention to suit generic f/w type. %s/MEI_/FW_
%s/mei_fw/cp_fw
%s/mei_dev/fw_dev
As interface to CP FW can be either a non i915 component or i915 intergral component, change structure name Accordingly. %s/i915_hdcp_comp_master/i915_hdcp_fw_master %s/i915_hdcp_component_ops/i915_hdcp_fw_ops
--- .../gpu/drm/i915/display/intel_display_core.h | 3 +- drivers/gpu/drm/i915/display/intel_hdcp.c | 66 ++++++++--------- drivers/misc/mei/hdcp/mei_hdcp.c | 12 ++-- include/drm/i915_cp_fw_hdcp_interface.h | 70 +++++++++---------- 4 files changed, 76 insertions(+), 75 deletions(-)
drivers/gpu/drm/i915/display/intel_display_core.h +2 -1
@@ -16,6 +16,7 @@#include <drm/drm_connector.h> #include <drm/drm_modeset_lock.h> +#include "i915/i915_cp_fw_hdcp_interface.h" #include "intel_cdclk.h" #include "intel_display.h" #include "intel_display_power.h"
@@ -368,7 +369,7 @@ struct intel_display { } gmbus;struct { -struct i915_hdcp_comp_master *master; +struct i915_hdcp_fw_master *master;bool comp_added;/* Mutex to protect the above hdcp component related values. */
drivers/gpu/drm/i915/display/intel_hdcp.c +33 -33
234 lines not on this page · raw message
drivers/misc/mei/hdcp/mei_hdcp.c +6 -6
@@ -715,7 +715,7 @@ mei_hdcp_close_session(struct device *dev, struct hdcp_port_data *data)return 0 ; } -static const struct i915_hdcp_component_ops mei_hdcp_ops = { +static const struct i915_hdcp_fw_ops mei_hdcp_ops = { .owner =THIS_MODULE , .initiate_hdcp2_session = mei_hdcp_initiate_session, .verify_receiver_cert_prepare_km =
@@ -735,13 +735,13 @@ static const struct i915_hdcp_component_ops mei_hdcp_ops = {static int mei_component_master_bind (struct device *dev) {struct mei_cl_device *cldev =to_mei_cl_device (dev); -struct i915_hdcp_comp_master *comp_master = +struct i915_hdcp_fw_master *comp_master =mei_cldev_get_drvdata (cldev);int ret;dev_dbg (dev,"%s\n" , __func__); comp_master->ops = &mei_hdcp_ops; - comp_master->mei_dev = dev; + comp_master->fw_dev = dev; ret =component_bind_all (dev, comp_master);if (ret <0 )return ret;
@@ -752,7 +752,7 @@ static int mei_component_master_bind(struct device *dev)static void mei_component_master_unbind (struct device *dev) {struct mei_cl_device *cldev =to_mei_cl_device (dev); -struct i915_hdcp_comp_master *comp_master = +struct i915_hdcp_fw_master *comp_master =mei_cldev_get_drvdata (cldev);dev_dbg (dev,"%s\n" , __func__);
@@ -801,7 +801,7 @@ static int mei_hdcp_component_match(struct device *dev, int subcomponent,static int mei_hdcp_probe (struct mei_cl_device *cldev,const struct mei_cl_device_id *id) { -struct i915_hdcp_comp_master *comp_master; +struct i915_hdcp_fw_master *comp_master;struct component_match *master_match;int ret;
@@ -846,7 +846,7 @@ static int mei_hdcp_probe(struct mei_cl_device *cldev,static void mei_hdcp_remove (struct mei_cl_device *cldev) { -struct i915_hdcp_comp_master *comp_master = +struct i915_hdcp_fw_master *comp_master =mei_cldev_get_drvdata (cldev);int ret;
include/drm/i915_cp_fw_hdcp_interface.h +35 -35
102 lines not on this page · raw message
Signature · 1 line
2.25.1