HuC Loading Patches
Subsystems (3)
cover HuC Loading Patches
These patches add HuC loading support. The GuC is required to authenticate the HuC. The userspace patches that check for a fully loaded HuC firmware and use it can be found at:
https://lists.freedesktop.org/archives/libva/2016-September/004554.html
https://lists.freedesktop.org/archives/libva/2016-September/004555.html
More information regarding the HuC, batch commands that configure the HuC etc can be found at-
https://01.org/sites/default/files/documentation/intel-gfx-prm-osrc-skl-vol02a-commandreference-instructions-huc.pdf
https://www.x.org/docs/intel/CHV/intel-gfx-prm-osrc-chv-bsw-vol10-hevc.pdf
v2: rebased.
v3: rebased. Changed the code following the review comments.
v4: Added action_lock initialization fix provided by Arek (Hiler Arkadiusz) to the first patch in the series- Make the GuC fw loading helper functions general.
v5: rebased on top of drm-tip. The patch series is now in sync with GuC code reorganization efforts by Arek-
https://patchwork.freedesktop.org/series/15896/
Anusha Srivatsa (2):
drm/i915/huc: Add BXT HuC Loading Support
drm/i915/HuC: Add KBL huC loading Support
Peter Antoine (6):
drm/i915/guc: Make the GuC fw loading helper functions general drm/i915/huc: Unified css_header struct for GuC and HuC drm/i914/huc: Add HuC fw loading support drm/i915/huc: Add debugfs for HuC loading status check drm/i915/huc: Support HuC authentication drm/i915/get_params: Add HuC status to getparams
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_debugfs.c | 43 +++- drivers/gpu/drm/i915/i915_drv.c | 9 +- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_guc_reg.h | 3 + drivers/gpu/drm/i915/i915_guc_submission.c | 67 ++++++- drivers/gpu/drm/i915/intel_guc_fwif.h | 22 ++- drivers/gpu/drm/i915/intel_guc_loader.c | 196 +++++++++--------- drivers/gpu/drm/i915/intel_huc.h | 43 ++++ drivers/gpu/drm/i915/intel_huc_loader.c | 306 +++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_uc.h | 47 +++-- include/uapi/drm/i915_drm.h | 1 + 12 files changed, 620 insertions(+), 122 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_huc.h create mode 100644 drivers/gpu/drm/i915/intel_huc_loader.c
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/8 drm/i915/guc: Make the GuC fw loading helper functions general
From: Peter Antoine <[email protected]>
Rename some of the GuC fw loading code to make them more general. We will utilise them for HuC loading as well.
s/intel_guc_fw/intel_uc_fw/g s/GUC_FIRMWARE/UC_FIRMWARE/g
Struct intel_guc_fw is renamed to intel_uc_fw. Prefix of tts members, such as 'guc' or 'guc_fw' either is renamed to 'uc' or removed for same purpose.
v2: rebased on top of nightly.
reapplied the search/replace as upstream code as changed.
v3: rebased again on drm-nightly.
v4: removed G from messages in shared fw fetch function.
v5: rebased.
v7: rebased.
v8: rebased.
v9: rebased.
v10: rebased.
v11: rebased.
v12: rebased on top of drm-tip
--- drivers/gpu/drm/i915/i915_debugfs.c | 12 +-- drivers/gpu/drm/i915/i915_guc_submission.c | 4 +- drivers/gpu/drm/i915/intel_guc_loader.c | 155 +++++++++++++++-------------- drivers/gpu/drm/i915/intel_uc.h | 40 ++++---- 4 files changed, 107 insertions(+), 104 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +6 -6
@@ -2337,7 +2337,7 @@ static int i915_llc(struct seq_file *m, void *data)static int i915_guc_load_status_info (struct seq_file *m,void *data) {struct drm_i915_private *dev_priv =node_to_i915 (m->private); -struct intel_guc_fw *guc_fw = &dev_priv->guc.guc_fw; +struct intel_uc_fw *guc_fw = &dev_priv->guc.guc_fw;u32 tmp, i;if (!HAS_GUC_UCODE (dev_priv))
@@ -2345,15 +2345,15 @@ static int i915_guc_load_status_info(struct seq_file *m, void *data)seq_printf (m,"GuC firmware status:\n" );seq_printf (m,"\tpath: %s\n" , - guc_fw->guc_fw_path); + guc_fw->uc_fw_path);seq_printf (m,"\tfetch: %s\n" , -intel_guc_fw_status_repr (guc_fw->guc_fw_fetch_status)); +intel_uc_fw_status_repr (guc_fw->fetch_status));seq_printf (m,"\tload: %s\n" , -intel_guc_fw_status_repr (guc_fw->guc_fw_load_status)); +intel_uc_fw_status_repr (guc_fw->load_status));seq_printf (m,"\tversion wanted: %d.%d\n" , - guc_fw->guc_fw_major_wanted, guc_fw->guc_fw_minor_wanted); + guc_fw->major_ver_wanted, guc_fw->minor_ver_wanted);seq_printf (m,"\tversion found: %d.%d\n" , - guc_fw->guc_fw_major_found, guc_fw->guc_fw_minor_found); + guc_fw->major_ver_found, guc_fw->minor_ver_found);seq_printf (m,"\theader: offset is %d; size = %d\n" , guc_fw->header_offset, guc_fw->header_size); seq_printf(m, "\tuCode: offset is %d; size = %d\n",
drivers/gpu/drm/i915/i915_guc_submission.c +2 -2
@@ -1494,7 +1494,7 @@ int intel_guc_suspend(struct drm_device *dev)struct i915_gem_context *ctx;u32 data[3 ]; -if (guc->guc_fw.guc_fw_load_status !=GUC_FIRMWARE_SUCCESS ) +if (guc->guc_fw.load_status !=UC_FIRMWARE_SUCCESS )return 0 ;gen9_disable_guc_interrupts (dev_priv);
@@ -1522,7 +1522,7 @@ int intel_guc_resume(struct drm_device *dev)struct i915_gem_context *ctx;u32 data[3 ]; -if (guc->guc_fw.guc_fw_load_status !=GUC_FIRMWARE_SUCCESS ) +if (guc->guc_fw.load_status !=UC_FIRMWARE_SUCCESS )return 0 ;if (i915.guc_log_level >=0 )
drivers/gpu/drm/i915/intel_guc_loader.c +78 -77
340 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uc.h +21 -19
@@ -91,29 +91,31 @@ struct i915_guc_client {uint64_t submissions[I915_NUM_ENGINES ]; }; -enum intel_guc_fw_status { -GUC_FIRMWARE_FAIL =-1 , -GUC_FIRMWARE_NONE =0 , -GUC_FIRMWARE_PENDING , -GUC_FIRMWARE_SUCCESS +enum intel_uc_fw_status { +UC_FIRMWARE_FAIL =-1 , +UC_FIRMWARE_NONE =0 , +UC_FIRMWARE_PENDING , +UC_FIRMWARE_SUCCESS };/* * This structure encapsulates all the data needed during the process * of fetching, caching, and loading the firmware image into the GuC. */ -struct intel_guc_fw { -const char * guc_fw_path; -size_t guc_fw_size; -struct drm_i915_gem_object * guc_fw_obj; -enum intel_guc_fw_status guc_fw_fetch_status; -enum intel_guc_fw_status guc_fw_load_status; - -uint16_t guc_fw_major_wanted; -uint16_t guc_fw_minor_wanted; -uint16_t guc_fw_major_found; -uint16_t guc_fw_minor_found; - +struct intel_uc_fw { +struct drm_device *uc_dev; +const char *uc_fw_path; +size_t uc_fw_size; +struct drm_i915_gem_object *uc_fw_obj; +enum intel_uc_fw_status fetch_status; +enum intel_uc_fw_status load_status; + +uint16_t major_ver_wanted; +uint16_t minor_ver_wanted; +uint16_t major_ver_found; +uint16_t minor_ver_found; + +uint32_t fw_type;uint32_t header_size;uint32_t header_offset;uint32_t rsa_size;
@@ -139,7 +141,7 @@ struct intel_guc_log { };struct intel_guc { -struct intel_guc_fw guc_fw; +struct intel_uc_fw guc_fw;struct intel_guc_log log;/* intel_guc_recv interrupt related state */
@@ -181,7 +183,7 @@ int intel_guc_log_control(struct intel_guc *guc, u32 control_val);extern void intel_guc_init (struct drm_device *dev);extern int intel_guc_setup (struct drm_device *dev);extern void intel_guc_fini (struct drm_device *dev); -extern const char *intel_guc_fw_status_repr (enum intel_guc_fw_status status); +extern const char *intel_uc_fw_status_repr (enum intel_uc_fw_status status);extern int intel_guc_suspend (struct drm_device *dev);extern int intel_guc_resume (struct drm_device *dev);
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/8 drm/i915/huc: Unified css_header struct for GuC and HuC
In reply to Anusha SrivatsaFrom: Peter Antoine <[email protected]>
HuC firmware css header has almost exactly same definition as GuC firmware except for the sw_version. Also, add a new member fw_type into intel_uc_fw to indicate what kind of fw it is. So, the loader will pull right sw_version from header.
v2: rebased on-top of drm-intel-nightly
v3: rebased on-top of drm-intel-nightly (again).
v4: rebased + spaces.
v7: rebased.
v8: rebased.
v9: rebased. Rename device_id to guc_branch_client_version, make guc_sw_version a union. <Jeff Mcgee>. Put UC_FW_TYPE_GUC and UC_FW_TYPE_HUC into an enum.
v10: rebased.
v11: rebased.
v12: rebased on top of drm-tip.
--- drivers/gpu/drm/i915/intel_guc_fwif.h | 21 +++++++++++++---- drivers/gpu/drm/i915/intel_guc_loader.c | 41 ++++++++++++++++++++++----------- drivers/gpu/drm/i915/intel_uc.h | 5 ++++ 3 files changed, 50 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/intel_guc_fwif.h +17 -4
@@ -154,7 +154,7 @@* The GuC firmware layout looks like this: * * +-------------------------------+ -* | guc_css_header | +* | uc_css_header | * | | * | contains major/minor version | * +-------------------------------+
@@ -181,9 +181,16 @@* 3. Length info of each component can be found in header, in dwords. * 4. Modulus and exponent key are not required by driver. They may not appear * in fw. So driver will load a truncated firmware in this case. +* +* HuC firmware layout is same as GuC firmware. +* +* HuC firmware css header is different. However, the only difference is where +* the version information is saved. The uc_css_header is unified to support +* both. Driver should get HuC version from uc_css_header.huc_sw_version, while +* uc_css_header.guc_sw_version for GuC. */ -struct guc_css_header { +struct uc_css_header {uint32_t module_type;/* header_size includes all non-uCode bits, including css_header, rsa * key, modulus key and exponent data. */
@@ -214,8 +221,14 @@ struct guc_css_header {char username[8 ];char buildnumber[12 ]; -uint32_t device_id; -uint32_t guc_sw_version; +union { +uint32_t guc_branch_client_version; +uint32_t huc_sw_version; + }; +union { +uint32_t guc_sw_version; +uint32_t huc_reserved; + };uint32_t prod_preprod_fw;uint32_t reserved[12 ];uint32_t header_info;
drivers/gpu/drm/i915/intel_guc_loader.c +28 -13
75 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uc.h +5 -0
@@ -98,6 +98,11 @@ enum intel_uc_fw_status { UC_FIRMWARE_SUCCESS }; +enum { +UC_FW_TYPE_GUC , +UC_FW_TYPE_HUC +}; +/* * This structure encapsulates all the data needed during the process * of fetching, caching, and loading the firmware image into the GuC.
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/8] drm/i915/huc: Unified css_header struct for GuC and HuC
Quoted 49 lines · Anusha Srivatsa
From: Peter Antoine <[email protected]>
HuC firmware css header has almost exactly same definition as GuC firmware except for the
sw_version. Also, add a new memberfw_typeintointel_uc_fwto indicate what kind of fw it is. So, the loader will pull rightsw_versionfrom header.v2: rebased on-top of drm-intel-nightly
v3: rebased on-top of drm-intel-nightly (again).
v4: rebased + spaces.
v7: rebased.
v8: rebased.
v9: rebased. Renamedevice_idtoguc_branch_client_version, makeguc_sw_versiona union. <Jeff Mcgee>. PutUC_FW_TYPE_GUCandUC_FW_TYPE_HUCinto an enum.
v10: rebased.
v11: rebased.
v12: rebased on top of drm-tip.Tested-by Xiang Haihao <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Signed-off-by Alex Dai <[email protected]>Signed-off-by Peter Antoine <[email protected]>Reviewed-by Dave Gordon <[email protected]>Reviewed-by Jeff McGee <[email protected]>--- drivers/gpu/drm/i915/intel_guc_fwif.h | 21 +++++++++++++---- drivers/gpu/drm/i915/intel_guc_loader.c | 41 ++++++++++++++++++++++----------- drivers/gpu/drm/i915/intel_uc.h | 5 ++++ 3 files changed, 50 insertions(+), 17 deletions(-)drivers/gpu/drm/i915/intel_guc_fwif.h +2
-1@@ -154,7 +154,7 @@* The GuC firmware layout looks like this: * * +-------------------------------+ -* | guc_css_header | +* | uc_css_header | * | | * | contains major/minor version | * +-------------------------------+ @@ -181,9 +181,16 @@* 3. Length info of each component can be found in header, in dwords. * 4. Modulus and exponent key are not required by driver. They may not appear * in fw. So driver will load a truncated firmware in this case. +*
drivers/gpu/drm/i915/intel_guc_fwif.h line 193
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +7
-1+* HuC firmware layout is same as GuC firmware. +* +* HuC firmware css header is different. However, the only difference is where +* the version information is saved. The uc_css_header is unified to support +* both. Driver should get HuC version from uc_css_header.huc_sw_version, while +* uc_css_header.guc_sw_version for GuC. */ -struct guc_css_header { +struct uc_css_header {
I think we should either move most of this stuff to intel_uc.{c,h} or rename the file to intel_uc_fwif.h.
Anyway, this file contains information on top that this is automatically generated and your changes might be lost...
The file was introduced and then *manually edited* *multiple times* by *many people*, without any signs of changes lost or file being regenerated.
I think we can, at least, drop the warning. I am in favor of drooping the file completely though.
If something would change, we can assume it would be done by hand anyway.
Jeff, Sagar: any thought on that?
Quoted 125 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +8
-2uint32_t module_type;/* header_size includes all non-uCode bits, including css_header, rsa * key, modulus key and exponent data. */ @@ -214,8 +221,14 @@ struct guc_css_header {char username[8 ];char buildnumber[12 ]; -uint32_t device_id; -uint32_t guc_sw_version; +union { +uint32_t guc_branch_client_version; +uint32_t huc_sw_version; + }; +union { +uint32_t guc_sw_version; +uint32_t huc_reserved; + };uint32_t prod_preprod_fw;uint32_t reserved[12 ];uint32_t header_info;drivers/gpu/drm/i915/intel_guc_loader.c +28
-13@@ -593,7 +593,7 @@ void intel_uc_fw_fetch(struct drm_device *dev, struct intel_uc_fw *uc_fw)struct pci_dev *pdev = dev->pdev;struct drm_i915_gem_object *obj;const struct firmware *fw =NULL ; -struct guc_css_header *css; +struct uc_css_header *css;size_t size;int err;@@ -610,19 +610,19 @@ void intel_uc_fw_fetch(struct drm_device *dev, struct intel_uc_fw *uc_fw) uc_fw->uc_fw_path, fw);/* Check the size of the blob before examining buffer contents */ -if (fw->size <sizeof (struct guc_css_header )) { +if (fw->size <sizeof (struct uc_css_header )) {DRM_NOTE ("Firmware header is missing\n" ); goto fail; } - css = (struct guc_css_header *)fw->data; + css = (struct uc_css_header *)fw->data;/* Firmware bits always start from header */ uc_fw->header_offset =0 ; uc_fw->header_size = (css->header_size_dw - css->modulus_size_dw - css->key_size_dw - css->exponent_size_dw) *sizeof (u32); -if (uc_fw->header_size !=sizeof (struct guc_css_header )) { +if (uc_fw->header_size !=sizeof (struct uc_css_header )) {DRM_NOTE ("CSS header definition mismatch\n" ); goto fail; }@@ -646,21 +646,36 @@ void intel_uc_fw_fetch(struct drm_device *dev, struct intel_uc_fw *uc_fw) goto fail; } -/* Header and uCode will be loaded to WOPCM. Size of the two. */ - size = uc_fw->header_size + uc_fw->ucode_size; -if (size >guc_wopcm_size (to_i915 (dev))) { -DRM_NOTE ("Firmware is too large to fit in WOPCM\n" ); - goto fail; - } -/* * The GuC firmware image has the version number embedded at a well-known * offset within the firmware blob; note that major / minor version are * TWO bytes each (i.e. u16), although all pointers and offsets are defined * in terms of bytes (u8). */ - uc_fw->major_ver_found = css->guc_sw_version >>16 ; - uc_fw->minor_ver_found = css->guc_sw_version &0xFFFF ; +switch (uc_fw->fw_type) { +case UC_FW_TYPE_GUC : +/* Header and uCode will be loaded to WOPCM. Size of the two. */ + size = uc_fw->header_size + uc_fw->ucode_size; + +/* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */ +if (size >guc_wopcm_size (to_i915 (dev))) { +DRM_ERROR ("Firmware is too large to fit in WOPCM\n" ); + goto fail; + } + uc_fw->major_ver_found = css->guc_sw_version >>16 ; + uc_fw->minor_ver_found = css->guc_sw_version &0xFFFF ; +break ; + +case UC_FW_TYPE_HUC : + uc_fw->major_ver_found = css->huc_sw_version >>16 ; + uc_fw->minor_ver_found = css->huc_sw_version &0xFFFF ; +break ; + +default : +DRM_ERROR ("Unknown firmware type %d\n" , uc_fw->fw_type); + err = -ENOEXEC ; + goto fail; + }if (uc_fw->major_ver_found != uc_fw->major_ver_wanted || uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) {drivers/gpu/drm/i915/intel_uc.h +5
-0@@ -98,6 +98,11 @@ enum intel_uc_fw_status { UC_FIRMWARE_SUCCESS }; +enum { +UC_FW_TYPE_GUC , +UC_FW_TYPE_HUC +}; +/* * This structure encapsulates all the data needed during the process * of fetching, caching, and loading the firmware image into the GuC. Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Cheers, Arek _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/8] drm/i915/huc: Unified css_header struct for GuC and HuC
Quoted 81 lines
-----Original Message-----
From: Hiler, Arkadiusz
Sent: Thursday, December 1, 2016 4:23 AM
To: Srivatsa, Anusha <[email protected]>
Cc: [email protected]; Mcgee, Jeff <[email protected]>; Kamble, Sagar A <[email protected]>
Subject: Re: [Intel-gfx] [PATCH 2/8] drm/i915/huc: Unifiedcss_headerstruct for GuC and HuCQuoted 25 lines · Anusha Srivatsa
From: Peter Antoine <[email protected]>
HuC firmware css header has almost exactly same definition as GuC firmware except for the
sw_version. Also, add a new memberfw_typeintointel_uc_fwto indicate what kind of fw it is. So, the loader will pull rightsw_versionfrom header.v2: rebased on-top of drm-intel-nightly
v3: rebased on-top of drm-intel-nightly (again).
v4: rebased + spaces.
v7: rebased.
v8: rebased.
v9: rebased. Renamedevice_idtoguc_branch_client_version, makeguc_sw_versiona union. <Jeff Mcgee>. PutUC_FW_TYPE_GUCandUC_FW_TYPE_HUCinto an enum.
v10: rebased.
v11: rebased.
v12: rebased on top of drm-tip.Tested-by Xiang Haihao <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Signed-off-by Alex Dai <[email protected]>Signed-off-by Peter Antoine <[email protected]>Reviewed-by Dave Gordon <[email protected]>Reviewed-by Jeff McGee <[email protected]>Quoted 3 lines
--- drivers/gpu/drm/i915/intel_guc_fwif.h | 21 +++++++++++++---- drivers/gpu/drm/i915/intel_guc_loader.c | 41 ++++++++++++++++++++++-----------
Quoted 18 lines
drivers/gpu/drm/i915/intel_uc.h | 5 ++++ 3 files changed, 50 insertions(+), 17 deletions(-)drivers/gpu/drm/i915/intel_guc_fwif.h +1
-1@@ -154,7 +154,7 @@* The GuC firmware layout looks like this: * * +-------------------------------+ -* | guc_css_header | +* | uc_css_header | * | | * | contains major/minor version | * +-------------------------------+ drivers/gpu/drm/i915/intel_guc_fwif.h line 182
Quoted 2 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +0
-0@@ -181,9 +181,16 @@* 3. Length info of each component can be found in header, in dwords. * 4. Modulus and exponent key are not required by driver. They may not appear
Quoted 5 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +4
-0* in fw. So driver will load a truncated firmware in this case. +* +* HuC firmware layout is same as GuC firmware. +* +* HuC firmware css header is different. However, the only difference drivers/gpu/drm/i915/intel_guc_fwif.h line 193
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +7
-1+is where +* the version information is saved. The uc_css_header is unified to +support +* both. Driver should get HuC version from +uc_css_header.huc_sw_version, while +* uc_css_header.guc_sw_version for GuC. */ -struct guc_css_header { +struct uc_css_header {I think we should either move most of this stuff to intel_uc.{c,h} or rename the file to
intel_uc_fwif.h.
Quoted 8 lines
Anyway, this file contains information on top that this is automatically generated and your changes might be lost...
The file was introduced and then *manually edited* *multiple times* by *many people*, without any signs of changes lost or file being regenerated.
I think we can, at least, drop the warning. I am in favor of drooping the file completely though.
So, basically move all these struct and union declarations to intel_uc.h?
Quoted 133 lines
If something would change, we can assume it would be done by hand anyway.
Jeff, Sagar: any thought on that?
drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev, struct
Quoted 26 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +0
-0uint32_t module_type;/* header_size includes all non-uCode bits, including css_header, rsa * key, modulus key and exponent data. */ @@ -214,8 +221,14 @@struct
guc_css_header{drivers/gpu/drm/i915/intel_guc_fwif.h +8
-2char username[8 ];char buildnumber[12 ]; -uint32_t device_id; -uint32_t guc_sw_version; +union { +uint32_t guc_branch_client_version; +uint32_t huc_sw_version; + }; +union { +uint32_t guc_sw_version; +uint32_t huc_reserved; + };uint32_t prod_preprod_fw;uint32_t reserved[12 ];uint32_t header_info;drivers/gpu/drm/i915/intel_guc_loader.c +0
-0@@ -593,7 +593,7 @@ void intel_uc_fw_fetch(struct drm_device *dev, struct
intel_uc_fw*uc_fw)drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev,
Quoted 9 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1
-1struct pci_dev *pdev = dev->pdev;struct drm_i915_gem_object *obj;const struct firmware *fw =NULL ; -struct guc_css_header *css; +struct uc_css_header *css;size_t size;int err;@@ -610,19 +610,19 @@ void intel_uc_fw_fetch(struct drm_device *dev,struct
intel_uc_fw*uc_fw)drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev,
Quoted 23 lines
drivers/gpu/drm/i915/intel_guc_loader.c +3
-3uc_fw->uc_fw_path, fw);/* Check the size of the blob before examining buffer contents */ -if (fw->size <sizeof (struct guc_css_header )) { +if (fw->size <sizeof (struct uc_css_header )) {DRM_NOTE ("Firmware header is missing\n" ); goto fail; } - css = (struct guc_css_header *)fw->data; + css = (struct uc_css_header *)fw->data;/* Firmware bits always start from header */ uc_fw->header_offset =0 ; uc_fw->header_size = (css->header_size_dw - css->modulus_size_dw - css->key_size_dw - css->exponent_size_dw) *sizeof (u32); -if (uc_fw->header_size !=sizeof (struct guc_css_header )) { +if (uc_fw->header_size !=sizeof (struct uc_css_header )) {DRM_NOTE ("CSS header definition mismatch\n" ); goto fail; }@@ -646,21 +646,36 @@ void intel_uc_fw_fetch(struct drm_device *dev,struct
intel_uc_fw*uc_fw)drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev, struct intel_uc_fw *uc_fw)
Quoted 12 lines
drivers/gpu/drm/i915/intel_guc_loader.c +0
-7goto fail; } -/* Header and uCode will be loaded to WOPCM. Size of the two. */ - size = uc_fw->header_size + uc_fw->ucode_size; -if (size >guc_wopcm_size (to_i915 (dev))) { -DRM_NOTE ("Firmware is too large to fit in WOPCM\n" ); - goto fail; - } -/* * The GuC firmware image has the version number embedded at a well- known
drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev, struct intel_uc_fw *uc_fw)
Quoted 9 lines
drivers/gpu/drm/i915/intel_guc_loader.c +3
-2* offset within the firmware blob; note that major / minor version are * TWO bytes each (i.e. u16), although all pointers and offsets are defined * in terms of bytes (u8). */ - uc_fw->major_ver_found = css->guc_sw_version >>16 ; - uc_fw->minor_ver_found = css->guc_sw_version &0xFFFF ; +switch (uc_fw->fw_type) { +case UC_FW_TYPE_GUC : +/* Header and uCode will be loaded to WOPCM. Size of the two. */
drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev, struct intel_uc_fw *uc_fw)
Quoted 3 lines
drivers/gpu/drm/i915/intel_guc_loader.c +3
-0+ size = uc_fw->header_size + uc_fw->ucode_size; + +/* Top 32k of WOPCM is reserved (8K stack + 24k RC6 context). */
drivers/gpu/drm/i915/intel_guc_loader.c void intel_uc_fw_fetch(struct drm_device *dev, · line 662
Quoted 2 lines
drivers/gpu/drm/i915/intel_guc_loader.c +2
-0+if (size >guc_wopcm_size (to_i915 (dev))) { + DRM_ERROR("Firmware is too large to fit inWOPCM\n");
Quoted 38 lines
drivers/gpu/drm/i915/intel_guc_loader.c +16
-0+ goto fail; + } + uc_fw->major_ver_found = css->guc_sw_version >>16 ; + uc_fw->minor_ver_found = css->guc_sw_version &0xFFFF ; +break ; + +case UC_FW_TYPE_HUC : + uc_fw->major_ver_found = css->huc_sw_version >>16 ; + uc_fw->minor_ver_found = css->huc_sw_version &0xFFFF ; +break ; + +default : +DRM_ERROR ("Unknown firmware type %d\n" , uc_fw->fw_type); + err = -ENOEXEC ; + goto fail; + }if (uc_fw->major_ver_found != uc_fw->major_ver_wanted || uc_fw->minor_ver_found < uc_fw->minor_ver_wanted) { diff --git
a/drivers/gpu/drm/i915/intel_uc.hb/drivers/gpu/drm/i915/intel_uc.hindex a1c771f..1616cac 100644drivers/gpu/drm/i915/intel_uc.h +5
-1@@ -98,6 +98,11 @@ enum intel_uc_fw_status { UC_FIRMWARE_SUCCESS }; +enum { +UC_FW_TYPE_GUC , +UC_FW_TYPE_HUC +}; +/* * This structure encapsulates all the data needed during the process * of fetching, caching, and loading the firmware image into the GuC. -- 2.7.4
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/8 drm/i915/huc: Add HuC fw loading support
In reply to Anusha SrivatsaThe HuC loading process is similar to GuC. The intel_uc_fw_fetch() is used for both cases.
HuC loading needs to be before GuC loading. The WOPCM setting must be done early before loading any of them.
v2: rebased on-top of drm-intel-nightly.
removed if(HAS_GUC()) before the guc call. (D.Gordon) update huc_version number of format.
v3: rebased to drm-intel-nightly, changed the file name format to
match the one in the huc package.
Changed dev->dev_private to to_i915()
v4: moved function back to where it was.
change wait_for_atomic to wait_for.
v5: rebased + comment changes.
v7: rebased.
v8: rebased.
v9: rebased. Changed the year in the copyright message to reflect the right year.Correct the comments,remove the unwanted WARN message, replace drm_gem_object_unreference() with i915_gem_object_put().Make the prototypes in intel_huc.h non-extern.
v10: rebased. Update the file construction done by HuC. It is similar to GuC.Adopted the approach used in-
https://patchwork.freedesktop.org/patch/104355/ <Tvrtko Ursulin>
v11: Fix warnings remove old declaration
v12: Change dev to dev_priv in macro definition.
Corrected comments.
v13: rebased.
v14: rebased on top of drm-tip
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_guc_reg.h | 3 + drivers/gpu/drm/i915/intel_guc_loader.c | 6 +- drivers/gpu/drm/i915/intel_huc.h | 42 +++++ drivers/gpu/drm/i915/intel_huc_loader.c | 267 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_uc.h | 2 + 8 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_huc.h create mode 100644 drivers/gpu/drm/i915/intel_huc_loader.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -57,6 +57,7 @@ i915-y += i915_cmd_parser.o \ # general-purpose microcontroller (GuC) support i915-y += intel_uc.o \ intel_guc_loader.o \ + intel_huc_loader.o \ i915_guc_submission.o # autogenerated null render state
drivers/gpu/drm/i915/i915_drv.c +3 -1
@@ -603,6 +603,7 @@ static int i915_load_modeset_init(struct drm_device *dev)if (ret) goto cleanup_irq; +intel_huc_init (dev);intel_guc_init (dev); ret =i915_gem_init (dev);
@@ -630,6 +631,7 @@ static int i915_load_modeset_init(struct drm_device *dev)DRM_ERROR ("failed to idle hardware; continuing to unload!\n" );i915_gem_fini (dev_priv); cleanup_irq: +intel_huc_fini (dev);intel_guc_fini (dev);drm_irq_uninstall (dev);intel_teardown_gmbus (dev);
@@ -1326,7 +1328,7 @@ void i915_driver_unload(struct drm_device *dev)/* Flush any outstanding unpin_work. */ drain_workqueue (dev_priv->wq); - +intel_huc_fini (dev);intel_guc_fini (dev);i915_gem_fini (dev_priv);intel_fbc_cleanup_cfb (dev_priv);
drivers/gpu/drm/i915/i915_drv.h +3 -1
@@ -56,6 +56,7 @@#include "intel_bios.h" #include "intel_dpll_mgr.h" #include "intel_uc.h" +#include "intel_huc.h" #include "intel_lrc.h" #include "intel_ringbuffer.h"
@@ -1933,6 +1934,7 @@ struct drm_i915_private {struct intel_gvt *gvt; +struct intel_huc huc;struct intel_guc guc;struct intel_csr csr;
@@ -2698,7 +2700,7 @@ intel_info(const struct drm_i915_private *dev_priv)#define HAS_GUC (dev_priv) ((dev_priv)->info.has_guc)#define HAS_GUC_UCODE (dev_priv) (HAS_GUC(dev_priv))#define HAS_GUC_SCHED (dev_priv) (HAS_GUC(dev_priv)) - +#define HAS_HUC_UCODE (dev_priv) (HAS_GUC(dev_priv))#define HAS_RESOURCE_STREAMER (dev_priv) ((dev_priv)->info.has_resource_streamer)#define HAS_POOLED_EU (dev_priv) ((dev_priv)->info.has_pooled_eu)
drivers/gpu/drm/i915/i915_guc_reg.h +3 -0
@@ -61,9 +61,12 @@#define DMA_ADDRESS_SPACE_GTT (8 << 16)#define DMA_COPY_SIZE _MMIO(0xc310)#define DMA_CTRL _MMIO(0xc314) +#define HUC_UKERNEL (1<<9)#define UOS_MOVE (1<<4)#define START_DMA (1<<0)#define DMA_GUC_WOPCM_OFFSET _MMIO(0xc340) +#define HUC_LOADING_AGENT_VCR (0<<1) +#define HUC_LOADING_AGENT_GUC (1<<1)#define GUC_WOPCM_OFFSET_VALUE 0x80000/* 512KB */ #define GUC_MAX_IDLE_COUNT _MMIO(0xC3E4)
drivers/gpu/drm/i915/intel_guc_loader.c +3 -3
@@ -309,8 +309,8 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,I915_WRITE (DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM );/* Finally start the DMA */ -I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA )); - +I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA ) | +_MASKED_BIT_DISABLE (HUC_UKERNEL ));/* * Wait for the DMA to complete & the GuC to start up. * NB: Docs recommend not using the interrupt for completion.
@@ -334,7 +334,7 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,return ret; } -static u32 guc_wopcm_size (struct drm_i915_private *dev_priv) +u32 guc_wopcm_size (struct drm_i915_private *dev_priv) {u32 wopcm_size =GUC_WOPCM_TOP ;
drivers/gpu/drm/i915/intel_huc.h new file +42 -0
42 lines not on this page · raw message
drivers/gpu/drm/i915/intel_huc_loader.c new file +267 -0
267 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uc.h +2 -0
@@ -191,6 +191,8 @@ extern void intel_guc_fini(struct drm_device *dev);extern const char *intel_uc_fw_status_repr (enum intel_uc_fw_status status);extern int intel_guc_suspend (struct drm_device *dev);extern int intel_guc_resume (struct drm_device *dev); +void intel_uc_fw_fetch (struct drm_device *dev,struct intel_uc_fw *uc_fw); +u32 guc_wopcm_size (struct drm_i915_private *dev_priv);/* i915_guc_submission.c */ int i915_guc_submission_init (struct drm_i915_private *dev_priv);
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/8] drm/i915/huc: Add HuC fw loading support
Hi,
Quoted 21 lines · Anusha Srivatsa
The HuC loading process is similar to GuC. The
intel_uc_fw_fetch()is used for both cases.HuC loading needs to be before GuC loading. The WOPCM setting must be done early before loading any of them.
v2: rebased on-top of drm-intel-nightly.
removed if(HAS_GUC()) before the guc call. (D.Gordon) updatehuc_versionnumber of format.
v3: rebased to drm-intel-nightly, changed the file name format to
match the one in the huc package.
Changeddev->dev_privatetoto_i915()
v4: moved function back to where it was.
changewait_for_atomictowait_for.
v5: rebased + comment changes.
v7: rebased.
v8: rebased.
v9: rebased. Changed the year in the copyright message to reflect the right year.Correct the comments,remove the unwanted WARN message, replacedrm_gem_object_unreference()with i915_gem_object_put().Make the prototypes inintel_huc.hnon-extern.
Quoted 8 lines
v10: rebased. Update the file construction done by HuC. It is similar to GuC.Adopted the approach used in-
https://patchwork.freedesktop.org/patch/104355/ <Tvrtko Ursulin>
v11: Fix warnings remove old declaration
v12: Change dev todev_privin macro definition.
Corrected comments.
v13: rebased.
v14: rebased on top of drm-tip
I thought we basically agreed to add i915.enable_huc (default=yes) and hide i915.enable_guc_loading, making it automatically turn on if either huc or guc submission are enabled?
Regards,
Tvrtko
Quoted 458 lines
Cc Tvrtko Ursulin <[email protected]>Tested-by Xiang Haihao <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Signed-off-by Alex Dai <[email protected]>Signed-off-by Peter Antoine <[email protected]>Reviewed-by Dave Gordon <[email protected]>--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_guc_reg.h | 3 + drivers/gpu/drm/i915/intel_guc_loader.c | 6 +- drivers/gpu/drm/i915/intel_huc.h | 42 +++++ drivers/gpu/drm/i915/intel_huc_loader.c | 267 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_uc.h | 2 + 8 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_huc.h create mode 100644 drivers/gpu/drm/i915/intel_huc_loader.cdrivers/gpu/drm/i915/Makefile +1
-0@@ -57,6 +57,7 @@ i915-y += i915_cmd_parser.o \ # general-purpose microcontroller (GuC) support i915-y += intel_uc.o \ intel_guc_loader.o \ + intel_huc_loader.o \ i915_guc_submission.o # autogenerated null render statedrivers/gpu/drm/i915/i915_drv.c +3
-1@@ -603,6 +603,7 @@ static int i915_load_modeset_init(struct drm_device *dev)if (ret) goto cleanup_irq; +intel_huc_init (dev);intel_guc_init (dev); ret =i915_gem_init (dev);@@ -630,6 +631,7 @@ static int i915_load_modeset_init(struct drm_device *dev)DRM_ERROR ("failed to idle hardware; continuing to unload!\n" );i915_gem_fini (dev_priv); cleanup_irq: +intel_huc_fini (dev);intel_guc_fini (dev);drm_irq_uninstall (dev);intel_teardown_gmbus (dev);@@ -1326,7 +1328,7 @@ void i915_driver_unload(struct drm_device *dev)/* Flush any outstanding unpin_work. */ drain_workqueue (dev_priv->wq); - +intel_huc_fini (dev);intel_guc_fini (dev);i915_gem_fini (dev_priv);intel_fbc_cleanup_cfb (dev_priv);drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -56,6 +56,7 @@#include "intel_bios.h" #include "intel_dpll_mgr.h" #include "intel_uc.h" +#include "intel_huc.h" #include "intel_lrc.h" #include "intel_ringbuffer.h" @@ -1933,6 +1934,7 @@ struct drm_i915_private {struct intel_gvt *gvt; +struct intel_huc huc;struct intel_guc guc;struct intel_csr csr;@@ -2698,7 +2700,7 @@ intel_info(const struct drm_i915_private *dev_priv)#define HAS_GUC (dev_priv) ((dev_priv)->info.has_guc)#define HAS_GUC_UCODE (dev_priv) (HAS_GUC(dev_priv))#define HAS_GUC_SCHED (dev_priv) (HAS_GUC(dev_priv)) - +#define HAS_HUC_UCODE (dev_priv) (HAS_GUC(dev_priv))#define HAS_RESOURCE_STREAMER (dev_priv) ((dev_priv)->info.has_resource_streamer)#define HAS_POOLED_EU (dev_priv) ((dev_priv)->info.has_pooled_eu)drivers/gpu/drm/i915/i915_guc_reg.h +3
-0@@ -61,9 +61,12 @@#define DMA_ADDRESS_SPACE_GTT (8 << 16)#define DMA_COPY_SIZE _MMIO(0xc310)#define DMA_CTRL _MMIO(0xc314) +#define HUC_UKERNEL (1<<9)#define UOS_MOVE (1<<4)#define START_DMA (1<<0)#define DMA_GUC_WOPCM_OFFSET _MMIO(0xc340) +#define HUC_LOADING_AGENT_VCR (0<<1) +#define HUC_LOADING_AGENT_GUC (1<<1)#define GUC_WOPCM_OFFSET_VALUE 0x80000/* 512KB */ #define GUC_MAX_IDLE_COUNT _MMIO(0xC3E4)drivers/gpu/drm/i915/intel_guc_loader.c +3
-3@@ -309,8 +309,8 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,I915_WRITE (DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM );/* Finally start the DMA */ -I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA )); - +I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA ) | +_MASKED_BIT_DISABLE (HUC_UKERNEL ));/* * Wait for the DMA to complete & the GuC to start up. * NB: Docs recommend not using the interrupt for completion. @@ -334,7 +334,7 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,return ret; } -static u32 guc_wopcm_size (struct drm_i915_private *dev_priv) +u32 guc_wopcm_size (struct drm_i915_private *dev_priv) {u32 wopcm_size =GUC_WOPCM_TOP ;drivers/gpu/drm/i915/intel_huc.h new file +42
-0@@ -0,0 +1,42 @@ +/* +* Copyright © 2016 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_HUC_H_ +#define _INTEL_HUC_H_ + +#include "intel_uc.h" + +#define HUC_STATUS2 _MMIO(0xD3B0) +#define HUC_FW_VERIFIED (1<<7) + +struct intel_huc { +/* Generic uC firmware management */ +struct intel_uc_fw huc_fw; + +/* HuC-specific additions */ +}; + +void intel_huc_init (struct drm_device *dev); +void intel_huc_fini (struct drm_device *dev); +int intel_huc_load (struct drm_device *dev); +#endif drivers/gpu/drm/i915/intel_huc_loader.c new file +267
-0@@ -0,0 +1,267 @@ +/* +* Copyright © 2016 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. +* +*/ +#include <linux/firmware.h> +#include "i915_drv.h" +#include "intel_huc.h" + +/** +* DOC: HuC Firmware +* +* Motivation: +* GEN9 introduces a new dedicated firmware for usage in media HEVC (High +* Efficiency Video Coding) operations. Userspace can use the firmware +* capabilities by adding HuC specific commands to batch buffers. +* +* Implementation: +* The same firmware loader is used as the GuC. However, the actual +* loading to HW is deferred until GEM initialization is done. +* +* Note that HuC firmware loading must be done before GuC loading. +*/ + +#define SKL_FW_MAJOR 01 +#define SKL_FW_MINOR 07 +#define SKL_BLD_NUM 1398 + +#define HUC_FW_PATH (platform, major, minor, bld_num) \ + "i915/" __stringify(platform) "_huc_ver" __stringify(major) "_" \ + __stringify(minor) "_" __stringify(bld_num) ".bin" + +#define I915_SKL_HUC_UCODE HUC_FW_PATH(skl, SKL_FW_MAJOR, \ + SKL_FW_MINOR, SKL_BLD_NUM) +MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); + +/** +* huc_ucode_xfer() - DMA's the firmware +* @dev_priv: the drm device +* +* This function takes the gem object containing the firmware, sets up the DMA +* engine MMIO, triggers the DMA operation and waits for it to finish. +* +* Transfer the firmware image to RAM for execution by the microcontroller. +* +* Return: 0 on success, non-zero on failure +*/ + +static int huc_ucode_xfer (struct drm_i915_private *dev_priv) +{ +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; +struct i915_vma *vma; +unsigned long offset =0 ; +u32 size; +int ret; + + ret =i915_gem_object_set_to_gtt_domain (huc_fw->uc_fw_obj, false); +if (ret) { +DRM_DEBUG_DRIVER ("set-domain failed %d\n" , ret); +return ret; + } + + vma =i915_gem_object_ggtt_pin (huc_fw->uc_fw_obj,NULL ,0 ,0 ,0 ); +if (IS_ERR (vma)) { +DRM_DEBUG_DRIVER ("pin failed %d\n" , (int )PTR_ERR (vma)); +return PTR_ERR (vma); + } + +/* Invalidate GuC TLB to let GuC take the latest updates to GTT. */ +I915_WRITE (GEN8_GTCR ,GEN8_GTCR_INVALIDATE ); + +intel_uncore_forcewake_get (dev_priv,FORCEWAKE_ALL ); + +/* init WOPCM */ +I915_WRITE (GUC_WOPCM_SIZE ,guc_wopcm_size (dev_priv)); +I915_WRITE (DMA_GUC_WOPCM_OFFSET ,GUC_WOPCM_OFFSET_VALUE | +HUC_LOADING_AGENT_GUC ); + +/* Set the source address for the uCode */ + offset =i915_ggtt_offset (vma) + huc_fw->header_offset; +I915_WRITE (DMA_ADDR_0_LOW ,lower_32_bits (offset)); +I915_WRITE (DMA_ADDR_0_HIGH ,upper_32_bits (offset) &0xFFFF ); + +/* Hardware doesn't look at destination address for HuC. Set it to 0, +* but still program the correct address space. +*/ +I915_WRITE (DMA_ADDR_1_LOW ,0 ); +I915_WRITE (DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM ); + + size = huc_fw->header_size + huc_fw->ucode_size; +I915_WRITE (DMA_COPY_SIZE , size); + +/* Start the DMA */ +I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (HUC_UKERNEL |START_DMA )); + +/* Wait for DMA to finish */ + ret =wait_for ((I915_READ (DMA_CTRL ) &START_DMA ) ==0 ,100 ); + +DRM_DEBUG_DRIVER ("HuC DMA transfer wait over with ret %d\n" , ret); + +intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL ); + +/* +* We keep the object pages for reuse during resume. But we can unpin it +* now that DMA has completed, so it doesn't continue to take up space. +*/ +i915_vma_unpin (vma); + +return ret; +} + +/** +* intel_huc_init() - initiate HuC firmware loading request +* @dev: the drm device +* +* Called early during driver load, but after GEM is initialised. The loading +* will continue only when driver explicitly specify firmware name and version. +* All other cases are considered as UC_FIRMWARE_NONE either because HW is not +* capable or driver yet support it. And there will be no error message for +* UC_FIRMWARE_NONE cases. +* +* The DMA-copying to HW is done later when intel_huc_load() is called. +*/ +void intel_huc_init (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_huc *huc = &dev_priv->huc; +struct intel_uc_fw *huc_fw = &huc->huc_fw; +const char *fw_path =NULL ; + + huc_fw->uc_dev = dev; + huc_fw->uc_fw_path =NULL ; + huc_fw->fetch_status =UC_FIRMWARE_NONE ; + huc_fw->load_status =UC_FIRMWARE_NONE ; + huc_fw->fw_type =UC_FW_TYPE_HUC ; + +if (!HAS_HUC_UCODE (dev_priv)) +return ; + +if (IS_SKYLAKE (dev_priv)) { + fw_path =I915_SKL_HUC_UCODE ; + huc_fw->major_ver_wanted =SKL_FW_MAJOR ; + huc_fw->minor_ver_wanted =SKL_FW_MINOR ; + } + + huc_fw->uc_fw_path = fw_path; + huc_fw->fetch_status =UC_FIRMWARE_PENDING ; + +DRM_DEBUG_DRIVER ("HuC firmware pending, path %s\n" , fw_path); + +intel_uc_fw_fetch (dev, huc_fw); +} + +/** +* intel_huc_load() - load HuC uCode to device +* @dev: the drm device +* +* Called from gem_init_hw() during driver loading and also after a GPU reset. +* Be note that HuC loading must be done before GuC loading. +* +* The firmware image should have already been fetched into memory by the +* earlier call to intel_huc_init(), so here we need only check that +* is succeeded, and then transfer the image to the h/w. +* +* Return: non-zero code on error +*/ +int intel_huc_load (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; +int err; + +if (huc_fw->fetch_status ==UC_FIRMWARE_NONE ) +return 0 ; + +DRM_DEBUG_DRIVER ("%s fw status: fetch %s, load %s\n" , + huc_fw->uc_fw_path, +intel_uc_fw_status_repr (huc_fw->fetch_status), +intel_uc_fw_status_repr (huc_fw->load_status)); + +if (huc_fw->fetch_status ==UC_FIRMWARE_SUCCESS && + huc_fw->load_status ==UC_FIRMWARE_FAIL ) +return -ENOEXEC ; + + huc_fw->load_status =UC_FIRMWARE_PENDING ; + +switch (huc_fw->fetch_status) { +case UC_FIRMWARE_FAIL : +/* something went wrong :( */ + err = -EIO ; + goto fail; + +case UC_FIRMWARE_NONE : +case UC_FIRMWARE_PENDING : +default : +/* "can't happen" */ +WARN_ONCE (1 ,"HuC fw %s invalid fetch_status %s [%d]\n" , + huc_fw->uc_fw_path, +intel_uc_fw_status_repr (huc_fw->fetch_status), + huc_fw->fetch_status); + err = -ENXIO ; + goto fail; + +case UC_FIRMWARE_SUCCESS : +break ; + } + + err =huc_ucode_xfer (dev_priv); +if (err) + goto fail; + + huc_fw->load_status =UC_FIRMWARE_SUCCESS ; + +DRM_DEBUG_DRIVER ("%s fw status: fetch %s, load %s\n" , + huc_fw->uc_fw_path, +intel_uc_fw_status_repr (huc_fw->fetch_status), +intel_uc_fw_status_repr (huc_fw->load_status)); + +return 0 ; + +fail: +if (huc_fw->load_status ==UC_FIRMWARE_PENDING ) + huc_fw->load_status =UC_FIRMWARE_FAIL ; + +DRM_ERROR ("Failed to complete HuC uCode load with ret %d\n" , err); + +return err; +} + +/** +* intel_huc_fini() - clean up resources allocated for HuC +* @dev: the drm device +* +* Cleans up by releasing the huc firmware GEM obj. +*/ +void intel_huc_fini (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; + +mutex_lock (&dev->struct_mutex); +if (huc_fw->uc_fw_obj) +i915_gem_object_put (huc_fw->uc_fw_obj); + huc_fw->uc_fw_obj =NULL ; +mutex_unlock (&dev->struct_mutex); + + huc_fw->fetch_status =UC_FIRMWARE_NONE ; +} +drivers/gpu/drm/i915/intel_uc.h +0
-0
drivers/gpu/drm/i915/intel_uc.h extern void intel_guc_fini(struct drm_device *dev); · line 198
Quoted 8 lines
drivers/gpu/drm/i915/intel_uc.h +2
-0@@ -191,6 +191,8 @@ extern void intel_guc_fini(struct drm_device *dev);extern const char *intel_uc_fw_status_repr (enum intel_uc_fw_status status);extern int intel_guc_suspend (struct drm_device *dev);extern int intel_guc_resume (struct drm_device *dev); +void intel_uc_fw_fetch (struct drm_device *dev,struct intel_uc_fw *uc_fw); +u32 guc_wopcm_size (struct drm_i915_private *dev_priv);/* i915_guc_submission.c */ int i915_guc_submission_init (struct drm_i915_private *dev_priv);
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/8] drm/i915/huc: Add HuC fw loading support
Quoted 42 lines
-----Original Message-----
From: Tvrtko Ursulin [mailto:[email protected]]
Sent: Thursday, December 1, 2016 5:24 AM
To: Srivatsa, Anusha <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH 3/8] drm/i915/huc: Add HuC fw loading supportHi,
Quoted 21 lines · Anusha Srivatsa
The HuC loading process is similar to GuC. The
intel_uc_fw_fetch()is used for both cases.HuC loading needs to be before GuC loading. The WOPCM setting must be done early before loading any of them.
v2: rebased on-top of drm-intel-nightly.
removed if(HAS_GUC()) before the guc call. (D.Gordon) updatehuc_versionnumber of format.
v3: rebased to drm-intel-nightly, changed the file name format to
match the one in the huc package.
Changeddev->dev_privatetoto_i915()
v4: moved function back to where it was.
changewait_for_atomictowait_for.
v5: rebased + comment changes.
v7: rebased.
v8: rebased.
v9: rebased. Changed the year in the copyright message to reflect the right year.Correct the comments,remove the unwanted WARN message, replacedrm_gem_object_unreference()with i915_gem_object_put().Make the prototypes inintel_huc.hnon-extern.Quoted 8 lines
v10: rebased. Update the file construction done by HuC. It is similar to GuC.Adopted the approach used in-
https://patchwork.freedesktop.org/patch/104355/ <Tvrtko Ursulin>
v11: Fix warnings remove old declaration
v12: Change dev todev_privin macro definition.
Corrected comments.
v13: rebased.
v14: rebased on top of drm-tip
Quoted 3 lines
I thought we basically agreed to add i915.enable_huc (default=yes) and hide i915.enable_guc_loading, making it automatically turn on if either huc or guc submission are enabled?
Yes, I will be sending the patch for the same soon.
Quoted 512 lines
Regards,
Tvrtko
Quoted 7 lines
Cc Tvrtko Ursulin <[email protected]>Tested-by Xiang Haihao <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Signed-off-by Alex Dai <[email protected]>Signed-off-by Peter Antoine <[email protected]>Reviewed-by Dave Gordon <[email protected]>Quoted 8 lines
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 4 +- drivers/gpu/drm/i915/i915_guc_reg.h | 3 + drivers/gpu/drm/i915/intel_guc_loader.c | 6 +- drivers/gpu/drm/i915/intel_huc.h | 42 +++++ drivers/gpu/drm/i915/intel_huc_loader.c | 267++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/i915_drv.c static int i915_load_modeset_init(struct drm_device
Quoted 21 lines
drivers/gpu/drm/i915/intel_uc.h | 2 + 8 files changed, 324 insertions(+), 5 deletions(-) create mode100644
drivers/gpu/drm/i915/intel_huc.hcreate mode 100644drivers/gpu/drm/i915/intel_huc_loader.c(quoted diff) +0
-0b/drivers/gpu/drm/i915/Makefile index 3c30916..01d4f4b 100644
drivers/gpu/drm/i915/Makefile +1
-0@@ -57,6 +57,7 @@ i915-y += i915_cmd_parser.o \ # general-purpose microcontroller (GuC) support i915-y += intel_uc.o \ intel_guc_loader.o \ + intel_huc_loader.o \ i915_guc_submission.o # autogenerated null render state(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_drv.cindex 8dac298..075d9ce 100644drivers/gpu/drm/i915/i915_drv.c +0
-0@@ -603,6 +603,7 @@ static int i915_load_modeset_init(struct drm_device*dev)
drivers/gpu/drm/i915/i915_drv.c static int i915_load_modeset_init(struct drm_device
Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.c +1
-0if (ret) goto cleanup_irq; +intel_huc_init (dev);intel_guc_init (dev); ret =i915_gem_init (dev);@@ -630,6 +631,7 @@ static int i915_load_modeset_init(struct drm_device*dev)
drivers/gpu/drm/i915/intel_guc_loader.c static int guc_ucode_xfer_dma(struct drm_i915_private
Quoted 70 lines
drivers/gpu/drm/i915/i915_drv.c +2
-1DRM_ERROR ("failed to idle hardware; continuing to unload!\n" );i915_gem_fini (dev_priv); cleanup_irq: +intel_huc_fini (dev);intel_guc_fini (dev);drm_irq_uninstall (dev);intel_teardown_gmbus (dev);@@ -1326,7 +1328,7 @@ void i915_driver_unload(struct drm_device *dev)/* Flush any outstanding unpin_work. */ drain_workqueue (dev_priv->wq); - +intel_huc_fini (dev);intel_guc_fini (dev);i915_gem_fini (dev_priv);intel_fbc_cleanup_cfb (dev_priv);(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_drv.hindex 297ad03..8edfae6 100644drivers/gpu/drm/i915/i915_drv.h +3
-1@@ -56,6 +56,7 @@#include "intel_bios.h" #include "intel_dpll_mgr.h" #include "intel_uc.h" +#include "intel_huc.h" #include "intel_lrc.h" #include "intel_ringbuffer.h" @@ -1933,6 +1934,7 @@ struct drm_i915_private {struct intel_gvt *gvt; +struct intel_huc huc;struct intel_guc guc;struct intel_csr csr;@@ -2698,7 +2700,7 @@ intel_info(const struct drm_i915_private *dev_priv)#define HAS_GUC (dev_priv) ((dev_priv)->info.has_guc)#define HAS_GUC_UCODE (dev_priv) (HAS_GUC(dev_priv))#define HAS_GUC_SCHED (dev_priv) (HAS_GUC(dev_priv)) - +#define HAS_HUC_UCODE (dev_priv) (HAS_GUC(dev_priv))#define HAS_RESOURCE_STREAMER (dev_priv) ((dev_priv)->info.has_resource_streamer)#define
HAS_POOLED_EU(dev_priv)((dev_priv)->info.has_pooled_eu)drivers/gpu/drm/i915/i915_guc_reg.h +3
-0@@ -61,9 +61,12 @@#define DMA_ADDRESS_SPACE_GTT (8 << 16)#define DMA_COPY_SIZE _MMIO(0xc310)#define DMA_CTRL _MMIO(0xc314) +#define HUC_UKERNEL (1<<9)#define UOS_MOVE (1<<4)#define START_DMA (1<<0)#define DMA_GUC_WOPCM_OFFSET _MMIO(0xc340) +#define HUC_LOADING_AGENT_VCR (0<<1) +#define HUC_LOADING_AGENT_GUC (1<<1)#define GUC_WOPCM_OFFSET_VALUE 0x80000/* 512KB */ #define GUC_MAX_IDLE_COUNT _MMIO(0xC3E4)drivers/gpu/drm/i915/intel_guc_loader.c +0
-0@@ -309,8 +309,8 @@ static int guc_ucode_xfer_dma(struct drm_i915_private
*dev_priv,drivers/gpu/drm/i915/intel_guc_loader.c static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,
Quoted 4 lines
drivers/gpu/drm/i915/intel_guc_loader.c +0
-1I915_WRITE (DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM );/* Finally start the DMA */ - I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(UOS_MOVE |
START_DMA));drivers/gpu/drm/i915/intel_guc_loader.c static int guc_ucode_xfer_dma(struct drm_i915_private · line 312
Quoted 2 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1
-1- + I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(UOS_MOVE |
START_DMA) |drivers/gpu/drm/i915/intel_guc_loader.c static int guc_ucode_xfer_dma(struct drm_i915_private
Quoted 5 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1
-0+ _MASKED_BIT_DISABLE(HUC_UKERNEL));/* * Wait for the DMA to complete & the GuC to start up. * NB: Docs recommend not using the interrupt for completion. @@ -334,7 +334,7 @@ static int guc_ucode_xfer_dma(struct drm_i915_private
*dev_priv,Quoted 31 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1
-1return ret; } -static u32 guc_wopcm_size (struct drm_i915_private *dev_priv) +u32 guc_wopcm_size (struct drm_i915_private *dev_priv) {u32 wopcm_size =GUC_WOPCM_TOP ;drivers/gpu/drm/i915/intel_huc.h new file +16
-0@@ -0,0 +1,42 @@ +/* +* Copyright © 2016 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 drivers/gpu/drm/i915/intel_huc.h line 26
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc.h new file +10
-0+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 NOEVENT
drivers/gpu/drm/i915/intel_huc.h line 28
Quoted 2 lines
drivers/gpu/drm/i915/intel_huc.h new file +2
-0+SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES
Quoted 49 lines
drivers/gpu/drm/i915/intel_huc.h new file +26
-0+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_HUC_H_ +#define _INTEL_HUC_H_ + +#include "intel_uc.h" + +#define HUC_STATUS2 _MMIO(0xD3B0) +#define HUC_FW_VERIFIED (1<<7) + +struct intel_huc { +/* Generic uC firmware management */ +struct intel_uc_fw huc_fw; + +/* HuC-specific additions */ +}; + +void intel_huc_init (struct drm_device *dev);void +intel_huc_fini (struct drm_device *dev);int intel_huc_load (struct +drm_device *dev);#endif drivers/gpu/drm/i915/intel_huc_loader.c new file +16
-0@@ -0,0 +1,267 @@ +/* +* Copyright © 2016 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 drivers/gpu/drm/i915/intel_huc_loader.c line 26
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +10
-0+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 NOEVENT
drivers/gpu/drm/i915/intel_huc_loader.c line 28
Quoted 2 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +2
-0+SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES
Quoted 70 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +70
-0+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. +* +*/ +#include <linux/firmware.h> +#include "i915_drv.h" +#include "intel_huc.h" + +/** +* DOC: HuC Firmware +* +* Motivation: +* GEN9 introduces a new dedicated firmware for usage in media HEVC +(High +* Efficiency Video Coding) operations. Userspace can use the +firmware +* capabilities by adding HuC specific commands to batch buffers. +* +* Implementation: +* The same firmware loader is used as the GuC. However, the actual +* loading to HW is deferred until GEM initialization is done. +* +* Note that HuC firmware loading must be done before GuC loading. +*/ + +#define SKL_FW_MAJOR 01 +#define SKL_FW_MINOR 07 +#define SKL_BLD_NUM 1398 + +#define HUC_FW_PATH (platform, major, minor, bld_num) \ + "i915/" __stringify(platform) "_huc_ver" __stringify(major) "_" \ + __stringify(minor) "_" __stringify(bld_num) ".bin" + +#define I915_SKL_HUC_UCODE HUC_FW_PATH(skl, SKL_FW_MAJOR, \ + SKL_FW_MINOR, SKL_BLD_NUM) +MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); + +/** +* huc_ucode_xfer() - DMA's the firmware +* @dev_priv: the drm device +* +* This function takes the gem object containing the firmware, sets +up the DMA +* engine MMIO, triggers the DMA operation and waits for it to finish. +* +* Transfer the firmware image to RAM for execution by the microcontroller. +* +* Return: 0 on success, non-zero on failure */ + +static int huc_ucode_xfer (struct drm_i915_private *dev_priv) { +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; +struct i915_vma *vma; +unsigned long offset =0 ; +u32 size; +int ret; + + ret =i915_gem_object_set_to_gtt_domain (huc_fw->uc_fw_obj, false); +if (ret) { +DRM_DEBUG_DRIVER ("set-domain failed %d\n" , ret); +return ret; + } + + vma =i915_gem_object_ggtt_pin (huc_fw->uc_fw_obj,NULL ,0 ,0 ,0 ); +if (IS_ERR (vma)) { +DRM_DEBUG_DRIVER ("pin failed %d\n" , (int )PTR_ERR (vma)); +return PTR_ERR (vma);drivers/gpu/drm/i915/intel_huc_loader.c
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +10
-0+ } + +/* Invalidate GuC TLB to let GuC take the latest updates to GTT. */ +I915_WRITE (GEN8_GTCR ,GEN8_GTCR_INVALIDATE ); + +intel_uncore_forcewake_get (dev_priv,FORCEWAKE_ALL ); + +/* init WOPCM */ +I915_WRITE (GUC_WOPCM_SIZE ,guc_wopcm_size (dev_priv)); + I915_WRITE(DMA_GUC_WOPCM_OFFSET,
GUC_WOPCM_OFFSET_VALUE|Quoted 8 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +8
-0+ HUC_LOADING_AGENT_GUC); + +/* Set the source address for the uCode */ + offset =i915_ggtt_offset (vma) + huc_fw->header_offset; +I915_WRITE (DMA_ADDR_0_LOW ,lower_32_bits (offset)); +I915_WRITE (DMA_ADDR_0_HIGH ,upper_32_bits (offset) &0xFFFF ); + +/* Hardware doesn't look at destination address for HuC. Set it to 0, drivers/gpu/drm/i915/intel_huc_loader.c
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +10
-0+* but still program the correct address space. +*/ +I915_WRITE (DMA_ADDR_1_LOW ,0 ); +I915_WRITE (DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM ); + + size = huc_fw->header_size + huc_fw->ucode_size; +I915_WRITE (DMA_COPY_SIZE , size); + +/* Start the DMA */ + I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(HUC_UKERNEL |
START_DMA));Quoted 168 lines
drivers/gpu/drm/i915/intel_huc_loader.c new file +155
-0+ +/* Wait for DMA to finish */ + ret =wait_for ((I915_READ (DMA_CTRL ) &START_DMA ) ==0 ,100 ); + +DRM_DEBUG_DRIVER ("HuC DMA transfer wait over with ret %d\n" , ret); + +intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL ); + +/* +* We keep the object pages for reuse during resume. But we can unpin it +* now that DMA has completed, so it doesn't continue to take up space. +*/ +i915_vma_unpin (vma); + +return ret; +} + +/** +* intel_huc_init() - initiate HuC firmware loading request +* @dev: the drm device +* +* Called early during driver load, but after GEM is initialised. The +loading +* will continue only when driver explicitly specify firmware name and version. +* All other cases are considered as UC_FIRMWARE_NONE either because +HW is not +* capable or driver yet support it. And there will be no error +message for +* UC_FIRMWARE_NONE cases. +* +* The DMA-copying to HW is done later when intel_huc_load() is called. +*/ +void intel_huc_init (struct drm_device *dev) { +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_huc *huc = &dev_priv->huc; +struct intel_uc_fw *huc_fw = &huc->huc_fw; +const char *fw_path =NULL ; + + huc_fw->uc_dev = dev; + huc_fw->uc_fw_path =NULL ; + huc_fw->fetch_status =UC_FIRMWARE_NONE ; + huc_fw->load_status =UC_FIRMWARE_NONE ; + huc_fw->fw_type =UC_FW_TYPE_HUC ; + +if (!HAS_HUC_UCODE (dev_priv)) +return ; + +if (IS_SKYLAKE (dev_priv)) { + fw_path =I915_SKL_HUC_UCODE ; + huc_fw->major_ver_wanted =SKL_FW_MAJOR ; + huc_fw->minor_ver_wanted =SKL_FW_MINOR ; + } + + huc_fw->uc_fw_path = fw_path; + huc_fw->fetch_status =UC_FIRMWARE_PENDING ; + +DRM_DEBUG_DRIVER ("HuC firmware pending, path %s\n" , fw_path); + +intel_uc_fw_fetch (dev, huc_fw); +} + +/** +* intel_huc_load() - load HuC uCode to device +* @dev: the drm device +* +* Called from gem_init_hw() during driver loading and also after a GPU reset. +* Be note that HuC loading must be done before GuC loading. +* +* The firmware image should have already been fetched into memory by +the +* earlier call to intel_huc_init(), so here we need only check that +* is succeeded, and then transfer the image to the h/w. +* +* Return: non-zero code on error +*/ +int intel_huc_load (struct drm_device *dev) { +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; +int err; + +if (huc_fw->fetch_status ==UC_FIRMWARE_NONE ) +return 0 ; + +DRM_DEBUG_DRIVER ("%s fw status: fetch %s, load %s\n" , + huc_fw->uc_fw_path, +intel_uc_fw_status_repr (huc_fw->fetch_status), +intel_uc_fw_status_repr (huc_fw->load_status)); + +if (huc_fw->fetch_status ==UC_FIRMWARE_SUCCESS && + huc_fw->load_status ==UC_FIRMWARE_FAIL ) +return -ENOEXEC ; + + huc_fw->load_status =UC_FIRMWARE_PENDING ; + +switch (huc_fw->fetch_status) { +case UC_FIRMWARE_FAIL : +/* something went wrong :( */ + err = -EIO ; + goto fail; + +case UC_FIRMWARE_NONE : +case UC_FIRMWARE_PENDING : +default : +/* "can't happen" */ +WARN_ONCE (1 ,"HuC fw %s invalid fetch_status %s [%d]\n" , + huc_fw->uc_fw_path, +intel_uc_fw_status_repr (huc_fw->fetch_status), + huc_fw->fetch_status); + err = -ENXIO ; + goto fail; + +case UC_FIRMWARE_SUCCESS : +break ; + } + + err =huc_ucode_xfer (dev_priv); +if (err) + goto fail; + + huc_fw->load_status =UC_FIRMWARE_SUCCESS ; + +DRM_DEBUG_DRIVER ("%s fw status: fetch %s, load %s\n" , + huc_fw->uc_fw_path, +intel_uc_fw_status_repr (huc_fw->fetch_status), +intel_uc_fw_status_repr (huc_fw->load_status)); + +return 0 ; + +fail: +if (huc_fw->load_status ==UC_FIRMWARE_PENDING ) + huc_fw->load_status =UC_FIRMWARE_FAIL ; + +DRM_ERROR ("Failed to complete HuC uCode load with ret %d\n" , err); + +return err; +} + +/** +* intel_huc_fini() - clean up resources allocated for HuC +* @dev: the drm device +* +* Cleans up by releasing the huc firmware GEM obj. +*/ +void intel_huc_fini (struct drm_device *dev) { +struct drm_i915_private *dev_priv =to_i915 (dev); +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; + +mutex_lock (&dev->struct_mutex); +if (huc_fw->uc_fw_obj) +i915_gem_object_put (huc_fw->uc_fw_obj); + huc_fw->uc_fw_obj =NULL ; +mutex_unlock (&dev->struct_mutex); + + huc_fw->fetch_status =UC_FIRMWARE_NONE ; } +(quoted diff) +0
-0
b/drivers/gpu/drm/i915/intel_uc.hindex 1616cac..9321225 100644drivers/gpu/drm/i915/intel_uc.h +0
-0@@ -191,6 +191,8 @@ extern void intel_guc_fini(struct drm_device *dev); extern const char *intel_uc_fw_status_repr(enum
intel_uc_fw_statusstatus); extern intintel_guc_suspend(struct drm_device *dev); extern intintel_guc_resume(struct drm_device *dev);drivers/gpu/drm/i915/intel_uc.h +3
-0+void intel_uc_fw_fetch (struct drm_device *dev,struct intel_uc_fw +*uc_fw); +u32 guc_wopcm_size (struct drm_i915_private *dev_priv);
Quoted 3 lines
Quoted 3 lines
/*
i915_guc_submission.c*/
inti915_guc_submission_init(struct drm_i915_private *dev_priv);
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/8 drm/i915/huc: Add BXT HuC Loading Support
In reply to Anusha SrivatsaThis patch adds the HuC Loading for the BXT by using the updated file construction.
Version 1.7 of the HuC firmware.
v2: rebased.
v3: rebased on top of drm-tip
--- drivers/gpu/drm/i915/intel_huc_loader.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/intel_huc_loader.c +11 -0
@@ -40,6 +40,10 @@* Note that HuC firmware loading must be done before GuC loading. */ +#define BXT_FW_MAJOR 01 +#define BXT_FW_MINOR 07 +#define BXT_BLD_NUM 1398 +#define SKL_FW_MAJOR 01#define SKL_FW_MINOR 07#define SKL_BLD_NUM 1398
@@ -52,6 +56,9 @@ SKL_FW_MINOR, SKL_BLD_NUM)MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); +#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_FW_MAJOR, \ + BXT_FW_MINOR, BXT_BLD_NUM) +MODULE_FIRMWARE (I915_BXT_HUC_UCODE );/** * huc_ucode_xfer() - DMA's the firmware * @dev_priv: the drm device
@@ -159,6 +166,10 @@ void intel_huc_init(struct drm_device *dev) fw_path =I915_SKL_HUC_UCODE ; huc_fw->major_ver_wanted =SKL_FW_MAJOR ; huc_fw->minor_ver_wanted =SKL_FW_MINOR ; + }else if (IS_BROXTON (dev_priv)) { + fw_path =I915_BXT_HUC_UCODE ; + huc_fw->major_ver_wanted =BXT_FW_MAJOR ; + huc_fw->minor_ver_wanted =BXT_FW_MINOR ; } huc_fw->uc_fw_path = fw_path;
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/8] drm/i915/huc: Add BXT HuC Loading Support
Quoted 42 lines · Anusha Srivatsa
This patch adds the HuC Loading for the BXT by using the updated file construction.
Version 1.7 of the HuC firmware.
v2: rebased.
v3: rebased on top of drm-tipCc Jeff Mcgee <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Reviewed-by Jeff McGee <[email protected]>--- drivers/gpu/drm/i915/intel_huc_loader.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/i915/intel_huc_loader.c +7
-0@@ -40,6 +40,10 @@* Note that HuC firmware loading must be done before GuC loading. */ +#define BXT_FW_MAJOR 01 +#define BXT_FW_MINOR 07 +#define BXT_BLD_NUM 1398 +#define SKL_FW_MAJOR 01#define SKL_FW_MINOR 07#define SKL_BLD_NUM 1398@@ -52,6 +56,9 @@ SKL_FW_MINOR, SKL_BLD_NUM)MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); +#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_FW_MAJOR, \ + BXT_FW_MINOR, BXT_BLD_NUM) +MODULE_FIRMWARE (I915_BXT_HUC_UCODE );/** * huc_ucode_xfer() - DMA's the firmware * @dev_priv: the drm device
drivers/gpu/drm/i915/intel_huc_loader.c void intel_huc_init(struct drm_device *dev) · line 175
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_loader.c +4
-0@@ -159,6 +166,10 @@ void intel_huc_init(struct drm_device *dev) fw_path =I915_SKL_HUC_UCODE ; huc_fw->major_ver_wanted =SKL_FW_MAJOR ; huc_fw->minor_ver_wanted =SKL_FW_MINOR ; + }else if (IS_BROXTON (dev_priv)) { + fw_path =I915_BXT_HUC_UCODE ; + huc_fw->major_ver_wanted =BXT_FW_MAJOR ; + huc_fw->minor_ver_wanted =BXT_FW_MINOR ; } huc_fw->uc_fw_path = fw_path;
Build number in the file name still worries me. Last time I've asked about it the thread kind of died off so I will re-state it.
My concern is that if we will be getting firmware releases with the same major-minor but different build numbers, then embedding the build number into the driver prevents loading of a newer firmware unless the kernel is also updated.
I am not sure if that is what we want. Perhaps it is not expected at all that will happen in production so it is not a concern?
Or if it could happen, perhaps we should either push back on the scheme - drop the build number and bump the minor in all cases, or alternatively for our purposes drop the build number from the driver and have a symlinked scheme on disk?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/8] drm/i915/huc: Add BXT HuC Loading Support
Quoted 75 lines
-----Original Message-----
From: Tvrtko Ursulin [mailto:[email protected]]
Sent: Thursday, December 1, 2016 5:11 AM
To: Srivatsa, Anusha <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH 4/8] drm/i915/huc: Add BXT HuC Loading SupportQuoted 43 lines · Anusha Srivatsa
This patch adds the HuC Loading for the BXT by using the updated file construction.
Version 1.7 of the HuC firmware.
v2: rebased.
v3: rebased on top of drm-tipCc Jeff Mcgee <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Reviewed-by Jeff McGee <[email protected]>--- drivers/gpu/drm/i915/intel_huc_loader.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/i915/intel_huc_loader.c +7
-0@@ -40,6 +40,10 @@* Note that HuC firmware loading must be done before GuC loading. */ +#define BXT_FW_MAJOR 01 +#define BXT_FW_MINOR 07 +#define BXT_BLD_NUM 1398 +#define SKL_FW_MAJOR 01#define SKL_FW_MINOR 07#define SKL_BLD_NUM 1398@@ -52,6 +56,9 @@ SKL_FW_MINOR, SKL_BLD_NUM)MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); +#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_FW_MAJOR, \ + BXT_FW_MINOR, BXT_BLD_NUM) +MODULE_FIRMWARE (I915_BXT_HUC_UCODE );/** * huc_ucode_xfer() - DMA's the firmware * @dev_priv: the drm device drivers/gpu/drm/i915/intel_huc_loader.c void intel_huc_init(struct drm_device *dev) · line 175
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_loader.c +4
-0@@ -159,6 +166,10 @@ void intel_huc_init(struct drm_device *dev) fw_path =I915_SKL_HUC_UCODE ; huc_fw->major_ver_wanted =SKL_FW_MAJOR ; huc_fw->minor_ver_wanted =SKL_FW_MINOR ; + }else if (IS_BROXTON (dev_priv)) { + fw_path =I915_BXT_HUC_UCODE ; + huc_fw->major_ver_wanted =BXT_FW_MAJOR ; + huc_fw->minor_ver_wanted =BXT_FW_MINOR ; } huc_fw->uc_fw_path = fw_path;Build number in the file name still worries me. Last time I've asked about it the thread kind of died off so I will re-state it.
My concern is that if we will be getting firmware releases with the same major- minor but different build numbers, then embedding the build number into the driver prevents loading of a newer firmware unless the kernel is also updated.
I am not sure if that is what we want. Perhaps it is not expected at all that will happen in production so it is not a concern?
Quoted 8 lines
Or if it could happen, perhaps we should either push back on the scheme
- drop the build number and bump the minor in all cases, or alternatively for our purposes drop the build number from the driver and have a symlinked scheme on disk?Regards,
Tvrtko
Hi Tvrtko,
Sincere apologies for responding so late. According to my understanding, Jeff correct me if I am wrong, we are finalizing the firmware version number for every kernel version. So a certain kernel will have only one possible firware major-minor and build number for a certain platform.
I have cc-ed Jeff in this thread so he can add his comment on build number. Jeff, any comments?
Regards,
Anusha
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/8] drm/i915/huc: Add BXT HuC Loading Support
Quoted 84 lines · Anusha
Quoted 75 lines
-----Original Message-----
From: Tvrtko Ursulin [mailto:[email protected]]
Sent: Thursday, December 1, 2016 5:11 AM
To: Srivatsa, Anusha <[email protected]>; intel- [email protected]
Subject: Re: [Intel-gfx] [PATCH 4/8] drm/i915/huc: Add BXT HuC Loading SupportQuoted 43 lines · Anusha Srivatsa
This patch adds the HuC Loading for the BXT by using the updated file construction.
Version 1.7 of the HuC firmware.
v2: rebased.
v3: rebased on top of drm-tipCc Jeff Mcgee <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Reviewed-by Jeff McGee <[email protected]>--- drivers/gpu/drm/i915/intel_huc_loader.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/i915/intel_huc_loader.c +7
-0@@ -40,6 +40,10 @@* Note that HuC firmware loading must be done before GuC loading. */ +#define BXT_FW_MAJOR 01 +#define BXT_FW_MINOR 07 +#define BXT_BLD_NUM 1398 +#define SKL_FW_MAJOR 01#define SKL_FW_MINOR 07#define SKL_BLD_NUM 1398@@ -52,6 +56,9 @@ SKL_FW_MINOR, SKL_BLD_NUM)MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); +#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_FW_MAJOR, \ + BXT_FW_MINOR, BXT_BLD_NUM) +MODULE_FIRMWARE (I915_BXT_HUC_UCODE );/** * huc_ucode_xfer() - DMA's the firmware * @dev_priv: the drm device drivers/gpu/drm/i915/intel_huc_loader.c void intel_huc_init(struct drm_device *dev) · line 175
Quoted 10 lines
drivers/gpu/drm/i915/intel_huc_loader.c +4
-0@@ -159,6 +166,10 @@ void intel_huc_init(struct drm_device *dev) fw_path =I915_SKL_HUC_UCODE ; huc_fw->major_ver_wanted =SKL_FW_MAJOR ; huc_fw->minor_ver_wanted =SKL_FW_MINOR ; + }else if (IS_BROXTON (dev_priv)) { + fw_path =I915_BXT_HUC_UCODE ; + huc_fw->major_ver_wanted =BXT_FW_MAJOR ; + huc_fw->minor_ver_wanted =BXT_FW_MINOR ; } huc_fw->uc_fw_path = fw_path;Build number in the file name still worries me. Last time I've asked about it the thread kind of died off so I will re-state it.
My concern is that if we will be getting firmware releases with the same major- minor but different build numbers, then embedding the build number into the driver prevents loading of a newer firmware unless the kernel is also updated.
I am not sure if that is what we want. Perhaps it is not expected at all that will happen in production so it is not a concern?
Quoted 8 lines
Or if it could happen, perhaps we should either push back on the scheme
- drop the build number and bump the minor in all cases, or alternatively for our purposes drop the build number from the driver and have a symlinked scheme on disk?Regards,
Tvrtko
Quoted 7 lines
Hi Tvrtko,
Sincere apologies for responding so late. According to my understanding, Jeff correct me if I am wrong, we are finalizing the firmware version number for every kernel version. So a certain kernel will have only one possible firware major-minor and build number for a certain platform.I have cc-ed Jeff in this thread so he can add his comment on build number. Jeff, any comments?
Regards,
Anusha
Sorry for delayed response. I'm checking with HuC firmware team on their intended release model.
-Jeff
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/8 drm/i915/HuC: Add KBL huC loading Support
In reply to Anusha SrivatsaThis patch adds the support to load HuC on KBL
Version 2.0
v2: rebased.
v3: rebased on top of drm-tip
--- drivers/gpu/drm/i915/intel_huc_loader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/i915/intel_huc_loader.c +16 -0
@@ -48,6 +48,10 @@#define SKL_FW_MINOR 07#define SKL_BLD_NUM 1398 +#define KBL_FW_MAJOR 02 +#define KBL_FW_MINOR 00 +#define KBL_BLD_NUM 1810 +#define HUC_FW_PATH (platform, major, minor, bld_num) \ "i915/" __stringify(platform) "_huc_ver" __stringify(major) "_" \ __stringify(minor) "_" __stringify(bld_num) ".bin"
@@ -59,6 +63,11 @@ MODULE_FIRMWARE(I915_SKL_HUC_UCODE);#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_FW_MAJOR, \ BXT_FW_MINOR, BXT_BLD_NUM)MODULE_FIRMWARE (I915_BXT_HUC_UCODE ); + +#define I915_KBL_HUC_UCODE HUC_FW_PATH(kbl, KBL_FW_MAJOR, \ + KBL_FW_MINOR, KBL_BLD_NUM) +MODULE_FIRMWARE (I915_KBL_HUC_UCODE ); +/** * huc_ucode_xfer() - DMA's the firmware * @dev_priv: the drm device
@@ -170,8 +179,15 @@ void intel_huc_init(struct drm_device *dev) fw_path =I915_BXT_HUC_UCODE ; huc_fw->major_ver_wanted =BXT_FW_MAJOR ; huc_fw->minor_ver_wanted =BXT_FW_MINOR ; + }else if (IS_KABYLAKE (dev_priv)) { + fw_path =I915_KBL_HUC_UCODE ; + huc_fw->major_ver_wanted =KBL_FW_MAJOR ; + huc_fw->minor_ver_wanted =KBL_FW_MINOR ; } +if (fw_path ==NULL ) +return ; + huc_fw->uc_fw_path = fw_path; huc_fw->fetch_status =UC_FIRMWARE_PENDING ;
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/8 drm/i915/huc: Add debugfs for HuC loading status check
In reply to Anusha SrivatsaFrom: Peter Antoine <[email protected]>
Add debugfs entry for HuC loading status check.
v2: rebase on-top of drm-intel-nightly.
v3: rebased again.
v7: rebased.
v8: rebased.
v9: rebased.
v10: rebased.
v11: rebased on top of drm-tip
--- drivers/gpu/drm/i915/i915_debugfs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +31 -0
@@ -2334,6 +2334,36 @@ static int i915_llc(struct seq_file *m, void *data)return 0 ; } +static int i915_huc_load_status_info (struct seq_file *m,void *data) +{ +struct drm_i915_private *dev_priv =node_to_i915 (m->private); +struct intel_uc_fw *huc_fw = &dev_priv->huc.huc_fw; + +if (!HAS_HUC_UCODE (dev_priv)) +return 0 ; + +seq_puts (m,"HuC firmware status:\n" ); +seq_printf (m,"\tpath: %s\n" , huc_fw->uc_fw_path); +seq_printf (m,"\tfetch: %s\n" , +intel_uc_fw_status_repr (huc_fw->fetch_status)); +seq_printf (m,"\tload: %s\n" , +intel_uc_fw_status_repr (huc_fw->load_status)); +seq_printf (m,"\tversion wanted: %d.%d\n" , + huc_fw->major_ver_wanted, huc_fw->minor_ver_wanted); +seq_printf (m,"\tversion found: %d.%d\n" , + huc_fw->major_ver_found, huc_fw->minor_ver_found); +seq_printf (m,"\theader: offset is %d; size = %d\n" , + huc_fw->header_offset, huc_fw->header_size); +seq_printf (m,"\tuCode: offset is %d; size = %d\n" , + huc_fw->ucode_offset, huc_fw->ucode_size); +seq_printf (m,"\tRSA: offset is %d; size = %d\n" , + huc_fw->rsa_offset, huc_fw->rsa_size); + +seq_printf (m,"\nHuC status 0x%08x:\n" ,I915_READ (HUC_STATUS2 )); + +return 0 ; +} +static int i915_guc_load_status_info (struct seq_file *m,void *data) {struct drm_i915_private *dev_priv =node_to_i915 (m->private);
@@ -5402,6 +5432,7 @@ static const struct drm_info_list i915_debugfs_list[] = { {"i915_guc_info", i915_guc_info, 0}, {"i915_guc_load_status", i915_guc_load_status_info, 0}, {"i915_guc_log_dump", i915_guc_log_dump, 0}, + {"i915_huc_load_status", i915_huc_load_status_info, 0}, {"i915_frequency_info", i915_frequency_info, 0}, {"i915_hangcheck_info", i915_hangcheck_info, 0}, {"i915_drpc_info", i915_drpc_info, 0},
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/8 drm/i915/huc: Support HuC authentication
In reply to Anusha SrivatsaFrom: Peter Antoine <[email protected]>
The HuC authentication is done by host2guc call. The HuC RSA keys are sent to GuC for authentication.
v2: rebased on top of drm-intel-nightly.
changed name format and upped version 1.7.
v3: rebased on top of drm-intel-nightly.
v4: changed wait_for_automic to wait_for
v5: rebased.
v7: rebased.
v8: rebased.
v9: rebased. Rename intel_huc_auh() to intel_guc_auth_huc() and place the prototype in intel_guc.h,correct the comments.
v10: rebased.
v11: rebased.
v12: rebased on top of drm-tip
--- drivers/gpu/drm/i915/i915_guc_submission.c | 63 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_guc_fwif.h | 1 + drivers/gpu/drm/i915/intel_guc_loader.c | 2 + 3 files changed, 66 insertions(+)
drivers/gpu/drm/i915/i915_guc_submission.c +63 -0
@@ -26,6 +26,7 @@#include <linux/relay.h> #include "i915_drv.h" #include "intel_uc.h" +#include "intel_huc.h" /** * DOC: GuC-based command submission
@@ -1638,3 +1639,65 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)return ret; } + +/** +* intel_guc_auth_huc() - authenticate ucode +* @dev: the drm device +* +* Triggers a HuC fw authentication request to the GuC via host-2-guc +* interface. +*/ +void intel_guc_auth_huc (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_guc *guc = &dev_priv->guc; +struct intel_huc *huc = &dev_priv->huc; +struct i915_vma *vma; +int ret; +u32 data[2 ]; + +/* Bypass the case where there is no HuC firmware */ +if (huc->huc_fw.fetch_status ==UC_FIRMWARE_NONE || + huc->huc_fw.load_status ==UC_FIRMWARE_NONE ) +return ; + +if (guc->guc_fw.load_status !=UC_FIRMWARE_SUCCESS ) { +DRM_ERROR ("HuC: GuC fw wasn't loaded. Can't authenticate" ); +return ; + } + +if (huc->huc_fw.load_status !=UC_FIRMWARE_SUCCESS ) { +DRM_ERROR ("HuC: fw wasn't loaded. Nothing to authenticate" ); +return ; + } + + vma =i915_gem_object_ggtt_pin (huc->huc_fw.uc_fw_obj,NULL ,0 ,0 ,0 ); +if (IS_ERR (vma)) { +DRM_DEBUG_DRIVER ("pin failed %d\n" , (int )PTR_ERR (vma)); +return ; + } + + +/* Invalidate GuC TLB to let GuC take the latest updates to GTT. */ +I915_WRITE (GEN8_GTCR ,GEN8_GTCR_INVALIDATE ); + +/* Specify auth action and where public signature is. */ + data[0 ] =HOST2GUC_ACTION_AUTHENTICATE_HUC ; + data[1 ] =i915_ggtt_offset (vma) + huc->huc_fw.rsa_offset; + + ret =host2guc_action (guc, data,ARRAY_SIZE (data)); +if (ret) { +DRM_ERROR ("HuC: GuC did not ack Auth request\n" ); + goto out; + } + +/* Check authentication status, it should be done by now */ + ret =wait_for ((I915_READ (HUC_STATUS2 ) &HUC_FW_VERIFIED ) >0 ,50 ); +if (ret) { +DRM_ERROR ("HuC: Authentication failed\n" ); + goto out; + } + +out: +i915_vma_unpin (vma); +}
drivers/gpu/drm/i915/intel_guc_fwif.h +1 -0
@@ -513,6 +513,7 @@ enum intel_guc_action {INTEL_GUC_ACTION_EXIT_S_STATE =0x502 ,INTEL_GUC_ACTION_SLPC_REQUEST =0x3003 ,INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING =0x0E000 , +HOST2GUC_ACTION_AUTHENTICATE_HUC =0x4000 , INTEL_GUC_ACTION_LIMIT };
drivers/gpu/drm/i915/intel_guc_loader.c +2 -0
@@ -529,6 +529,8 @@ int intel_guc_setup(struct drm_device *dev)intel_uc_fw_status_repr (guc_fw->fetch_status), intel_uc_fw_status_repr(guc_fw->load_status)); +intel_guc_auth_huc (dev); +if (i915.enable_guc_submission) {if (i915.guc_log_level >=0 )gen9_enable_guc_interrupts (dev_priv);
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 7/8] drm/i915/huc: Support HuC authentication
Quoted 45 lines · Anusha Srivatsa
From: Peter Antoine <[email protected]>
The HuC authentication is done by host2guc call. The HuC RSA keys are sent to GuC for authentication.
v2: rebased on top of drm-intel-nightly.
changed name format and upped version 1.7.
v3: rebased on top of drm-intel-nightly.
v4: changedwait_for_automictowait_for
v5: rebased.
v7: rebased.
v8: rebased.
v9: rebased. Renameintel_huc_auh()tointel_guc_auth_huc()and place the prototype in intel_guc.h,correct the comments.
v10: rebased.
v11: rebased.
v12: rebased on top of drm-tipTested-by Xiang Haihao <[email protected]>Signed-off-by Anusha Srivatsa <[email protected]>Signed-off-by Alex Dai <[email protected]>Signed-off-by Peter Antoine <[email protected]>Reviewed-by Dave Gordon <[email protected]>Reviewed-by Jeff McGee <[email protected]>--- drivers/gpu/drm/i915/i915_guc_submission.c | 63 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_guc_fwif.h | 1 + drivers/gpu/drm/i915/intel_guc_loader.c | 2 + 3 files changed, 66 insertions(+)drivers/gpu/drm/i915/i915_guc_submission.c +1
-0@@ -26,6 +26,7 @@#include <linux/relay.h> #include "i915_drv.h" #include "intel_uc.h" +#include "intel_huc.h" /** * DOC: GuC-based command submission @@ -1638,3 +1639,65 @@ int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)return ret;
drivers/gpu/drm/i915/i915_guc_submission.c int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val) · line 1650
Quoted 10 lines
drivers/gpu/drm/i915/i915_guc_submission.c +9
-0} + +/** +* intel_guc_auth_huc() - authenticate ucode +* @dev: the drm device +* +* Triggers a HuC fw authentication request to the GuC via host-2-guc +* interface. +*/ +void intel_guc_auth_huc (struct drm_device *dev)
This should belong to intel_uc.c
Quoted 25 lines
drivers/gpu/drm/i915/i915_guc_submission.c +25
-0+{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct intel_guc *guc = &dev_priv->guc; +struct intel_huc *huc = &dev_priv->huc; +struct i915_vma *vma; +int ret; +u32 data[2 ]; + +/* Bypass the case where there is no HuC firmware */ +if (huc->huc_fw.fetch_status ==UC_FIRMWARE_NONE || + huc->huc_fw.load_status ==UC_FIRMWARE_NONE ) +return ; + +if (guc->guc_fw.load_status !=UC_FIRMWARE_SUCCESS ) { +DRM_ERROR ("HuC: GuC fw wasn't loaded. Can't authenticate" ); +return ; + } + +if (huc->huc_fw.load_status !=UC_FIRMWARE_SUCCESS ) { +DRM_ERROR ("HuC: fw wasn't loaded. Nothing to authenticate" ); +return ; + } + + vma =i915_gem_object_ggtt_pin (huc->huc_fw.uc_fw_obj,NULL ,0 ,0 ,0 ); +if (IS_ERR (vma)) {
drivers/gpu/drm/i915/i915_guc_submission.c int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val) · line 1685
Quoted 10 lines
drivers/gpu/drm/i915/i915_guc_submission.c +10
-0+DRM_DEBUG_DRIVER ("pin failed %d\n" , (int )PTR_ERR (vma)); +return ; + } + + +/* Invalidate GuC TLB to let GuC take the latest updates to GTT. */ +I915_WRITE (GEN8_GTCR ,GEN8_GTCR_INVALIDATE ); + +/* Specify auth action and where public signature is. */ + data[0 ] =HOST2GUC_ACTION_AUTHENTICATE_HUC ;
s/HOST2GUC/INTEL_GUC/
drivers/gpu/drm/i915/i915_guc_submission.c int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val) · line 1688
Quoted 3 lines
drivers/gpu/drm/i915/i915_guc_submission.c +3
-0+ data[1 ] =i915_ggtt_offset (vma) + huc->huc_fw.rsa_offset; + + ret =host2guc_action (guc, data,ARRAY_SIZE (data));
s/host2guc_action/intel_guc_send/
Quoted 20 lines
drivers/gpu/drm/i915/i915_guc_submission.c +15
-0+if (ret) { +DRM_ERROR ("HuC: GuC did not ack Auth request\n" ); + goto out; + } + +/* Check authentication status, it should be done by now */ + ret =wait_for ((I915_READ (HUC_STATUS2 ) &HUC_FW_VERIFIED ) >0 ,50 ); +if (ret) { +DRM_ERROR ("HuC: Authentication failed\n" ); + goto out; + } + +out: +i915_vma_unpin (vma); +}drivers/gpu/drm/i915/intel_guc_fwif.h +0
-0
drivers/gpu/drm/i915/intel_guc_fwif.h enum intel_guc_action { · line 516
Quoted 4 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +1
-0@@ -513,6 +513,7 @@ enum intel_guc_action {INTEL_GUC_ACTION_EXIT_S_STATE =0x502 ,INTEL_GUC_ACTION_SLPC_REQUEST =0x3003 ,INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING =0x0E000 , + HOST2GUC_ACTION_AUTHENTICATE_HUC = 0x4000,
s/HOST2GUC/INTEL_GUC/
drivers/gpu/drm/i915/intel_guc_loader.c int intel_guc_setup(struct drm_device *dev) · line 533
Quoted 13 lines
drivers/gpu/drm/i915/intel_guc_fwif.h +0
-0INTEL_GUC_ACTION_LIMIT };drivers/gpu/drm/i915/intel_guc_loader.c +2
-0@@ -529,6 +529,8 @@ int intel_guc_setup(struct drm_device *dev)intel_uc_fw_status_repr (guc_fw->fetch_status), intel_uc_fw_status_repr(guc_fw->load_status)); +intel_guc_auth_huc (dev); +
You do not have this symbol declared in any header, it's not visible in this compilation unit.
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_loader.c +0
-0if (i915.enable_guc_submission) {if (i915.guc_log_level >=0 )gen9_enable_guc_interrupts (dev_priv);Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Cheers, Arek _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/8 drm/i915/get_params: Add HuC status to getparams
In reply to Anusha SrivatsaFrom: Peter Antoine <[email protected]>
This patch will allow for getparams to return the status of the HuC. As the HuC has to be validated by the GuC this patch uses the validated status to show when the HuC is loaded and ready for use. You cannot use the loaded status as with the GuC as the HuC is verified after it is loaded and is not usable until it is verified.
v2: removed the forewakes as the registers are already force-woken.
(T.Ursulin)
v4: rebased.
v5: rebased on top of drm-tip.
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/intel_huc.h | 1 + drivers/gpu/drm/i915/intel_huc_loader.c | 12 ++++++++++++ include/uapi/drm/i915_drm.h | 1 + 4 files changed, 19 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -49,6 +49,8 @@#include "i915_trace.h" #include "i915_vgpu.h" #include "intel_drv.h" +#include "intel_uc.h" +#include "intel_huc.h" static struct drm_driver driver;
@@ -350,6 +352,9 @@ static int i915_getparam(struct drm_device *dev, void *data,*/ value =1 ;break ; +case I915_PARAM_HAS_HUC : + value =intel_is_huc_valid (dev_priv); +break ;default :DRM_DEBUG ("Unknown parameter %d\n" , param->param);return -EINVAL ;
drivers/gpu/drm/i915/intel_huc.h +1 -0
@@ -39,4 +39,5 @@ struct intel_huc {void intel_huc_init (struct drm_device *dev);void intel_huc_fini (struct drm_device *dev);int intel_huc_load (struct drm_device *dev); +int intel_is_huc_valid (struct drm_i915_private *dev_priv);#endif
drivers/gpu/drm/i915/intel_huc_loader.c +12 -0
@@ -292,3 +292,15 @@ void intel_huc_fini(struct drm_device *dev) huc_fw->fetch_status =UC_FIRMWARE_NONE ; } +/** +* intel_is_huc_valid() - Check to see if the HuC is fully loaded. +* @dev_priv: drm device to check. +* +* This function will return true if the guc has been loaded and +* has valid firmware. The simplest way of doing this is to check +* if the HuC has been validated, if so it must have been loaded. +*/ +int intel_is_huc_valid (struct drm_i915_private *dev_priv) +{ +return ((I915_READ (HUC_STATUS2 ) &HUC_FW_VERIFIED ) !=0 ); +}
include/uapi/drm/i915_drm.h +1 -0
@@ -395,6 +395,7 @@ typedef struct drm_i915_irq_wait {* priorities and the driver will attempt to execute batches in priority order. */ #define I915_PARAM_HAS_SCHEDULER 41 +#define I915_PARAM_HAS_HUC 42 typedef struct drm_i915_getparam { __s32 param;
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 8/8] drm/i915/get_params: Add HuC status to getparams
Quoted 8 lines · Anusha Srivatsa
From: Peter Antoine <[email protected]>
This patch will allow for getparams to return the status of the HuC. As the HuC has to be validated by the GuC this patch uses the validated status to show when the HuC is loaded and ready for use. You cannot use the loaded status as with the GuC as the HuC is verified after it is loaded and is not usable until it is verified.
Quoted 6 lines
v2: removed the forewakes as the registers are already force-woken.
(T.Ursulin)v4: rebased.
v5: rebased on top of drm-tip.Signed-off-by Peter Antoine <[email protected]>
Quoted 79 lines
--- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/intel_huc.h | 1 + drivers/gpu/drm/i915/intel_huc_loader.c | 12 ++++++++++++ include/uapi/drm/i915_drm.h | 1 + 4 files changed, 19 insertions(+)drivers/gpu/drm/i915/i915_drv.c +5
-0@@ -49,6 +49,8 @@#include "i915_trace.h" #include "i915_vgpu.h" #include "intel_drv.h" +#include "intel_uc.h" +#include "intel_huc.h" static struct drm_driver driver;@@ -350,6 +352,9 @@ static int i915_getparam(struct drm_device *dev, void *data,*/ value =1 ;break ; +case I915_PARAM_HAS_HUC : + value =intel_is_huc_valid (dev_priv); +break ;default :DRM_DEBUG ("Unknown parameter %d\n" , param->param);return -EINVAL ;drivers/gpu/drm/i915/intel_huc.h +1
-0@@ -39,4 +39,5 @@ struct intel_huc {void intel_huc_init (struct drm_device *dev);void intel_huc_fini (struct drm_device *dev);int intel_huc_load (struct drm_device *dev); +int intel_is_huc_valid (struct drm_i915_private *dev_priv);#endif drivers/gpu/drm/i915/intel_huc_loader.c +12
-0@@ -292,3 +292,15 @@ void intel_huc_fini(struct drm_device *dev) huc_fw->fetch_status =UC_FIRMWARE_NONE ; } +/** +* intel_is_huc_valid() - Check to see if the HuC is fully loaded. +* @dev_priv: drm device to check. +* +* This function will return true if the guc has been loaded and +* has valid firmware. The simplest way of doing this is to check +* if the HuC has been validated, if so it must have been loaded. +*/ +int intel_is_huc_valid (struct drm_i915_private *dev_priv) +{ +return ((I915_READ (HUC_STATUS2 ) &HUC_FW_VERIFIED ) !=0 ); +}include/uapi/drm/i915_drm.h +1
-0@@ -395,6 +395,7 @@ typedef struct drm_i915_irq_wait {* priorities and the driver will attempt to execute batches in priority order. */ #define I915_PARAM_HAS_SCHEDULER 41 +#define I915_PARAM_HAS_HUC 42 typedef struct drm_i915_getparam { __s32 param;Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Cheers, Arek _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for HuC Loading Patches
In reply to Anusha Srivatsa== Series Details ==
== Series Details ==
Series: HuC Loading Patches
URL : https://patchwork.freedesktop.org/series/16188/
State : failure
== Summary ==
CC [M] drivers/gpu/drm/i915/gvt/opregion.o CC [M] drivers/gpu/drm/i915/gvt/mmio.o CC [M] drivers/gpu/drm/i915/gvt/display.o CC [M] drivers/gpu/drm/i915/gvt/edid.o CC [M] drivers/gpu/drm/i915/gvt/execlist.o CC [M] drivers/gpu/drm/i915/gvt/scheduler.o CC [M] drivers/gpu/drm/i915/gvt/sched_policy.o CC [M] drivers/gpu/drm/i915/gvt/render.o CC [M] drivers/gpu/drm/i915/gvt/cmd_parser.o LD [M] drivers/misc/mei/mei-me.o LD drivers/tty/serial/8250/8250.o LD drivers/usb/storage/usb-storage.o LD drivers/misc/built-in.o LD drivers/usb/storage/built-in.o LD net/ipv6/ipv6.o LD [M] sound/pci/hda/snd-hda-codec-generic.o LD sound/pci/built-in.o LD drivers/pci/pcie/aer/aerdriver.o LD drivers/md/dm-mod.o LD drivers/pci/pcie/aer/built-in.o LD drivers/pci/pcie/built-in.o LD net/ipv6/built-in.o LD [M] drivers/usb/serial/usbserial.o LD sound/built-in.o LD [M] drivers/gpu/drm/vgem/vgem.o
drivers/gpu/drm/i915/intel_guc_loader.c: In function ‘intel_guc_setup’:drivers/gpu/drm/i915/intel_guc_loader.c:532:2: error: implicit declaration of function ‘intel_guc_auth_huc’ [-Werror=implicit-function-declaration]
intel_guc_auth_huc(dev);
^
LD drivers/usb/gadget/libcomposite.odrivers/gpu/drm/i915/i915_guc_submission.c: In function ‘intel_guc_auth_huc’:drivers/gpu/drm/i915/i915_guc_submission.c:1688:8: error: implicit declaration of function ‘host2guc_action’ [-Werror=implicit-function-declaration]
ret = host2guc_action(guc, data, ARRAY_SIZE(data));
^
LD drivers/usb/gadget/udc/udc-core.o
LD drivers/usb/gadget/udc/built-in.o
LD drivers/usb/gadget/built-in.o
LD drivers/scsi/scsi_mod.o
LD drivers/thermal/thermal_sys.o
LD drivers/video/fbdev/core/fb.o
LD drivers/video/fbdev/core/built-in.o
LD drivers/thermal/built-in.o
LD [M] drivers/net/ethernet/broadcom/genet/genet.o
LD drivers/video/fbdev/built-in.o
LD drivers/iommu/built-in.o
LD drivers/spi/built-in.o
AR lib/lib.a
LD drivers/tty/serial/8250/8250_base.o EXPORTS lib/lib-ksyms.o
LD drivers/tty/serial/8250/built-in.o
cc1: all warnings being treated as errors
LD lib/built-in.oscripts/Makefile.build:293: recipe for target 'drivers/gpu/drm/i915/intel_guc_loader.o' failed make[4]: *** [drivers/gpu/drm/i915/intel_guc_loader.o] Error 1
make[4]: *** Waiting for unfinished jobs....
LD [M] drivers/net/ethernet/intel/igbvf/igbvf.o
cc1: all warnings being treated as errorsscripts/Makefile.build:293: recipe for target 'drivers/gpu/drm/i915/i915_guc_submission.o' failed make[4]: *** [drivers/gpu/drm/i915/i915_guc_submission.o] Error 1
LD drivers/tty/serial/built-in.o LD drivers/pci/built-in.o LD drivers/gpu/drm/drm.o LD drivers/usb/core/usbcore.o LD drivers/scsi/sd_mod.o LD drivers/scsi/built-in.o LD drivers/usb/core/built-in.o LD drivers/video/console/built-in.o LD drivers/video/built-in.o LD [M] drivers/net/ethernet/intel/e1000/e1000.o LD fs/btrfs/btrfs.o LD net/ipv4/built-in.o CC arch/x86/kernel/cpu/capflags.o LD arch/x86/kernel/cpu/built-in.o LD fs/btrfs/built-in.o LD arch/x86/kernel/built-in.o LD drivers/usb/host/xhci-hcd.o LD drivers/md/md-mod.o LD arch/x86/built-in.o LD drivers/md/built-in.o LD drivers/tty/vt/built-in.o LD drivers/tty/built-in.o LD net/core/built-in.o LD net/built-in.o LD drivers/usb/host/built-in.o LD drivers/usb/built-in.o LD [M] drivers/net/ethernet/intel/igb/igb.o LD fs/ext4/ext4.o LD fs/ext4/built-in.o LD fs/built-in.o LD [M] drivers/net/ethernet/intel/e1000e/e1000e.o LD drivers/net/ethernet/built-in.o LD drivers/net/built-in.o
scripts/Makefile.build:544: recipe for target 'drivers/gpu/drm/i915' failed make[3]: *** [drivers/gpu/drm/i915] Error 2 scripts/Makefile.build:544: recipe for target 'drivers/gpu/drm' failed make[2]: *** [drivers/gpu/drm] Error 2 scripts/Makefile.build:544: recipe for target 'drivers/gpu' failed make[1]: *** [drivers/gpu] Error 2
Makefile:986: recipe for target 'drivers' failed
make: *** [drivers] Error 2
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx